Merge pull request #296 from larinam/revert_breaking_renaming_azure_change

Revert "Changed environment variable names OPENAI_API_BASE and OPENAI…
This commit is contained in:
Alex 2023-08-08 18:15:45 +01:00 committed by GitHub
commit 33dce10bc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 20 deletions

View File

@ -2,7 +2,7 @@ OPENAI_API_KEY=<LLM api key (for example, open ai key)>
EMBEDDINGS_KEY=<LLM embeddings api key (for example, open ai key)>
#For Azure
AZURE_OPENAI_API_BASE=
AZURE_OPENAI_API_VERSION=
OPENAI_API_BASE=
OPENAI_API_VERSION=
AZURE_DEPLOYMENT_NAME=
AZURE_EMBEDDINGS_DEPLOYMENT_NAME=

View File

@ -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=

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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")
):