From dc78da64618ef084724f6db8e77471f42512710c Mon Sep 17 00:00:00 2001 From: Anton Dubovik Date: Fri, 28 Jun 2024 15:03:55 +0000 Subject: [PATCH] fix: supported path-like deployment ids --- aidial_adapter_dial/app.py | 4 ++-- .../local/generate_config_from_listing.sh | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/aidial_adapter_dial/app.py b/aidial_adapter_dial/app.py index e766d8d..0fd5ad1 100644 --- a/aidial_adapter_dial/app.py +++ b/aidial_adapter_dial/app.py @@ -123,7 +123,7 @@ async def parse( ) -@app.post("/openai/deployments/{deployment_id}/embeddings") +@app.post("/openai/deployments/{deployment_id:path}/embeddings") @dial_exception_decorator async def embeddings_proxy(request: Request, deployment_id: str): body = await request.json() @@ -136,7 +136,7 @@ async def embeddings_proxy(request: Request, deployment_id: str): return response.to_dict() -@app.post("/openai/deployments/{deployment_id}/chat/completions") +@app.post("/openai/deployments/{deployment_id:path}/chat/completions") @dial_exception_decorator async def chat_completions_proxy(request: Request, deployment_id: str): diff --git a/docker-compose/local/generate_config_from_listing.sh b/docker-compose/local/generate_config_from_listing.sh index e0e36b8..32410e8 100755 --- a/docker-compose/local/generate_config_from_listing.sh +++ b/docker-compose/local/generate_config_from_listing.sh @@ -2,14 +2,31 @@ set -e +get_python_cmd() { + # Check if python is defined + if command -v python &> /dev/null + then + echo "python" + elif command -v python3 &> /dev/null + then + echo "python3" + else + echo "Error: Neither python nor python3 is installed." >&2 + return 1 + fi +} + cd ../generate-config +PYTHON_CMD=$(get_python_cmd) || exit 1 + echo "Installing Python dependencies..." -python -m venv .venv +$PYTHON_CMD -m venv .venv source .venv/bin/activate pip install -r requirements.txt > /dev/null echo "Generating config file..." -python app.py --local-app-port=5005 $@ > ../local/core/config.json +mkdir -p ../local/core +$PYTHON_CMD app.py --local-app-port=5005 $@ > ../local/core/config.json echo "Config file saved to ./core/config.json" \ No newline at end of file