diff --git a/.env-template b/.env-template index 11a0b7e5..09c738fb 100644 --- a/.env-template +++ b/.env-template @@ -2,7 +2,7 @@ OPENAI_API_KEY= EMBEDDINGS_KEY= #For Azure -AZURE_OPENAI_API_BASE= -AZURE_OPENAI_API_VERSION= +OPENAI_API_BASE= +OPENAI_API_VERSION= AZURE_DEPLOYMENT_NAME= AZURE_EMBEDDINGS_DEPLOYMENT_NAME= \ No newline at end of file diff --git a/application/.env_sample b/application/.env_sample index e256c404..af270ee1 100644 --- a/application/.env_sample +++ b/application/.env_sample @@ -6,7 +6,7 @@ MONGO_URI=mongodb://localhost:27017/docsgpt API_URL=http://localhost:7091 #For OPENAI on Azure -AZURE_OPENAI_API_BASE= -AZURE_OPENAI_API_VERSION= +OPENAI_API_BASE= +OPENAI_API_VERSION= AZURE_DEPLOYMENT_NAME= AZURE_EMBEDDINGS_DEPLOYMENT_NAME= \ No newline at end of file diff --git a/application/app.py b/application/app.py index 99ab8e00..156e34a7 100644 --- a/application/app.py +++ b/application/app.py @@ -167,12 +167,12 @@ def complete_stream(question, docsearch, chat_history, api_key, conversation_id) if is_azure_configured(): logger.debug("in Azure") openai.api_type = "azure" - openai.api_version = settings.AZURE_OPENAI_API_VERSION - openai.api_base = settings.AZURE_OPENAI_API_BASE + openai.api_version = settings.OPENAI_API_VERSION + openai.api_base = settings.OPENAI_API_BASE llm = AzureChatOpenAI( openai_api_key=api_key, - openai_api_base=settings.AZURE_OPENAI_API_BASE, - openai_api_version=settings.AZURE_OPENAI_API_VERSION, + openai_api_base=settings.OPENAI_API_BASE, + openai_api_version=settings.OPENAI_API_VERSION, deployment_name=settings.AZURE_DEPLOYMENT_NAME, ) else: @@ -283,7 +283,7 @@ def stream(): def is_azure_configured(): - return settings.AZURE_OPENAI_API_BASE and settings.AZURE_OPENAI_API_VERSION and settings.AZURE_DEPLOYMENT_NAME + return settings.OPENAI_API_BASE and settings.OPENAI_API_VERSION and settings.AZURE_DEPLOYMENT_NAME @app.route("/api/answer", methods=["POST"]) @@ -321,8 +321,8 @@ def api_answer(): logger.debug("in Azure") llm = AzureChatOpenAI( openai_api_key=api_key, - openai_api_base=settings.AZURE_OPENAI_API_BASE, - openai_api_version=settings.AZURE_OPENAI_API_VERSION, + openai_api_base=settings.OPENAI_API_BASE, + openai_api_version=settings.OPENAI_API_VERSION, deployment_name=settings.AZURE_DEPLOYMENT_NAME, ) else: diff --git a/application/core/settings.py b/application/core/settings.py index c63f362c..34c8c023 100644 --- a/application/core/settings.py +++ b/application/core/settings.py @@ -16,8 +16,8 @@ class Settings(BaseSettings): API_KEY: str = None # LLM api key EMBEDDINGS_KEY: str = None # api key for embeddings (if using openai, just copy API_KEY - AZURE_OPENAI_API_BASE: str = None # azure openai api base url - AZURE_OPENAI_API_VERSION: str = None # azure openai api version + OPENAI_API_BASE: str = None # azure openai api base url + OPENAI_API_VERSION: str = None # azure openai api version AZURE_DEPLOYMENT_NAME: str = None # azure deployment name for answering AZURE_EMBEDDINGS_DEPLOYMENT_NAME: str = None # azure deployment name for embeddings diff --git a/docker-compose-azure.yaml b/docker-compose-azure.yaml index edebfc5e..a015eef2 100644 --- a/docker-compose-azure.yaml +++ b/docker-compose-azure.yaml @@ -20,8 +20,8 @@ services: - CELERY_RESULT_BACKEND=redis://redis:6379/1 - MONGO_URI=mongodb://mongo:27017/docsgpt - OPENAI_API_KEY=$OPENAI_API_KEY - - AZURE_OPENAI_API_BASE=$AZURE_OPENAI_API_BASE - - AZURE_OPENAI_API_VERSION=$AZURE_OPENAI_API_VERSION + - OPENAI_API_BASE=$OPENAI_API_BASE + - OPENAI_API_VERSION=$OPENAI_API_VERSION - AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME - AZURE_EMBEDDINGS_DEPLOYMENT_NAME=$AZURE_EMBEDDINGS_DEPLOYMENT_NAME ports: @@ -45,8 +45,8 @@ services: - MONGO_URI=mongodb://mongo:27017/docsgpt - API_URL=http://backend:7091 - OPENAI_API_KEY=$OPENAI_API_KEY - - AZURE_OPENAI_API_BASE=$AZURE_OPENAI_API_BASE - - AZURE_OPENAI_API_VERSION=$AZURE_OPENAI_API_VERSION + - OPENAI_API_BASE=$OPENAI_API_BASE + - OPENAI_API_VERSION=$OPENAI_API_VERSION - AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME - AZURE_EMBEDDINGS_DEPLOYMENT_NAME=$AZURE_EMBEDDINGS_DEPLOYMENT_NAME depends_on: diff --git a/run-with-docker-compose.sh b/run-with-docker-compose.sh index b65aa5d8..4c892298 100755 --- a/run-with-docker-compose.sh +++ b/run-with-docker-compose.sh @@ -2,7 +2,7 @@ source .env -if [[ -n "$AZURE_OPENAI_API_BASE" ]] && [[ -n "$AZURE_OPENAI_API_VERSION" ]] && [[ -n "$AZURE_DEPLOYMENT_NAME" ]] && [[ -n "$AZURE_EMBEDDINGS_DEPLOYMENT_NAME" ]]; then +if [[ -n "$OPENAI_API_BASE" ]] && [[ -n "$OPENAI_API_VERSION" ]] && [[ -n "$AZURE_DEPLOYMENT_NAME" ]] && [[ -n "$AZURE_EMBEDDINGS_DEPLOYMENT_NAME" ]]; then echo "Running Azure Configuration" docker-compose -f docker-compose-azure.yaml build && docker-compose -f docker-compose-azure.yaml up else diff --git a/scripts/parser/open_ai_func.py b/scripts/parser/open_ai_func.py index 70638c36..63b06634 100644 --- a/scripts/parser/open_ai_func.py +++ b/scripts/parser/open_ai_func.py @@ -46,8 +46,8 @@ def call_openai_api(docs, folder_name): # ) # index_name = "pandas" if ( # azure - os.environ.get("AZURE_OPENAI_API_BASE") - and os.environ.get("AZURE_OPENAI_API_VERSION") + os.environ.get("OPENAI_API_BASE") + and os.environ.get("OPENAI_API_VERSION") and os.environ.get("AZURE_DEPLOYMENT_NAME") and os.environ.get("AZURE_EMBEDDINGS_DEPLOYMENT_NAME") ):