From 1d10b94e420220f38be2f062e8fdf2c7790330d5 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 May 2024 22:15:47 +0000 Subject: [PATCH 1/4] Add fixes to entrypoint and regions --- infra/main.bicep | 15 +-------------- src/entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/infra/main.bicep b/infra/main.bicep index 2fbba05f..b89b07cb 100644 --- a/infra/main.bicep +++ b/infra/main.bicep @@ -17,25 +17,12 @@ param principalId string = '' @minLength(1) @description('Location for the OpenAI resource') +// Look for gpt-35-turbo 0125 on the availability table: // https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models#standard-deployment-model-availability @allowed([ - 'australiaeast' - 'brazilsouth' 'canadaeast' - 'eastus' - 'eastus2' - 'francecentral' - 'japaneast' 'northcentralus' - 'norwayeast' - 'southafricanorth' 'southcentralus' - 'southindia' - 'swedencentral' - 'switzerlandnorth' - 'uksouth' - 'westeurope' - 'westus' ]) @metadata({ azd: { diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 6ae183cd..f3c4cea8 100644 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -1,3 +1,3 @@ #!/bin/bash set -e -python3 -m gunicorn fastapi_app:create_app() \ No newline at end of file +python3 -m gunicorn "fastapi_app:create_app()" \ No newline at end of file From 18486126c29c0169c7eb3c026e697bf12c7bd5d8 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 May 2024 22:29:43 +0000 Subject: [PATCH 2/4] Password is optional in env --- src/fastapi_app/postgres_engine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fastapi_app/postgres_engine.py b/src/fastapi_app/postgres_engine.py index fd3a2959..5094ee0b 100644 --- a/src/fastapi_app/postgres_engine.py +++ b/src/fastapi_app/postgres_engine.py @@ -41,7 +41,7 @@ async def create_postgres_engine_from_env(azure_credential=None) -> AsyncEngine: host=os.environ["POSTGRES_HOST"], username=os.environ["POSTGRES_USERNAME"], database=os.environ["POSTGRES_DATABASE"], - password=os.environ["POSTGRES_PASSWORD"], + password=os.environ.get("POSTGRES_PASSWORD"), sslmode=os.environ.get("POSTGRES_SSL"), azure_credential=azure_credential, ) From 5031c2f755a484cdb3059b007dc087d7a611c38c Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 May 2024 22:54:45 +0000 Subject: [PATCH 3/4] Use uvicorn instead of fastapi command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b25c775..44e26965 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ Since the local app uses OpenAI models, you should first deploy it for the optim 2. Run the FastAPI backend: ```shell - fastapi dev src/api/main.py + python3 -m uvicorn fastapi_app:create_app --factory --reload ``` Or you can run "Backend" in the VS Code Run & Debug menu. From 4226309d56b16186ba0697234b76f27a42b889b1 Mon Sep 17 00:00:00 2001 From: Pamela Fox Date: Tue, 14 May 2024 23:01:48 +0000 Subject: [PATCH 4/4] Fix query rewriting extraction --- src/fastapi_app/query_rewriter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fastapi_app/query_rewriter.py b/src/fastapi_app/query_rewriter.py index a02157ee..68229e1a 100644 --- a/src/fastapi_app/query_rewriter.py +++ b/src/fastapi_app/query_rewriter.py @@ -68,7 +68,7 @@ def extract_search_arguments(chat_completion: ChatCompletion): if function.name == "search_database": arg = json.loads(function.arguments) search_query = arg.get("search_query") - if "price_filter" in arg: + if "price_filter" in arg and arg["price_filter"]: price_filter = arg["price_filter"] filters.append( { @@ -77,7 +77,7 @@ def extract_search_arguments(chat_completion: ChatCompletion): "value": price_filter["value"], } ) - if "brand_filter" in arg: + if "brand_filter" in arg and arg["brand_filter"]: brand_filter = arg["brand_filter"] filters.append( {