Changed environment variable names OPENAI_API_BASE and OPENAI_API_VERSION to AZURE_OPENAI_API_BASE and AZURE_OPENAI_API_VERSION

This commit is contained in:
Rik Schoonbeek 2023-07-12 17:37:56 +02:00
parent 6ab15f8eb1
commit ce8b29e9d0
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
OPENAI_API_BASE=
OPENAI_API_VERSION=
AZURE_OPENAI_API_BASE=
AZURE_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
OPENAI_API_BASE=
OPENAI_API_VERSION=
AZURE_OPENAI_API_BASE=
AZURE_OPENAI_API_VERSION=
AZURE_DEPLOYMENT_NAME=
AZURE_EMBEDDINGS_DEPLOYMENT_NAME=

View File

@ -164,12 +164,12 @@ def complete_stream(question, docsearch, chat_history, api_key):
if is_azure_configured():
logger.debug("in Azure")
openai.api_type = "azure"
openai.api_version = settings.OPENAI_API_VERSION
openai.api_base = settings.OPENAI_API_BASE
openai.api_version = settings.AZURE_OPENAI_API_VERSION
openai.api_base = settings.AZURE_OPENAI_API_BASE
llm = AzureChatOpenAI(
openai_api_key=api_key,
openai_api_base=settings.OPENAI_API_BASE,
openai_api_version=settings.OPENAI_API_VERSION,
openai_api_base=settings.AZURE_OPENAI_API_BASE,
openai_api_version=settings.AZURE_OPENAI_API_VERSION,
deployment_name=settings.AZURE_DEPLOYMENT_NAME,
)
else:
@ -244,7 +244,7 @@ def stream():
def is_azure_configured():
return settings.OPENAI_API_BASE and settings.OPENAI_API_VERSION and settings.AZURE_DEPLOYMENT_NAME
return settings.AZURE_OPENAI_API_BASE and settings.AZURE_OPENAI_API_VERSION and settings.AZURE_DEPLOYMENT_NAME
@app.route("/api/answer", methods=["POST"])
@ -278,8 +278,8 @@ def api_answer():
logger.debug("in Azure")
llm = AzureChatOpenAI(
openai_api_key=api_key,
openai_api_base=settings.OPENAI_API_BASE,
openai_api_version=settings.OPENAI_API_VERSION,
openai_api_base=settings.AZURE_OPENAI_API_BASE,
openai_api_version=settings.AZURE_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
OPENAI_API_BASE: str = None # azure openai api base url
OPENAI_API_VERSION: str = None # azure openai api version
AZURE_OPENAI_API_BASE: str = None # azure openai api base url
AZURE_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
- OPENAI_API_BASE=$OPENAI_API_BASE
- OPENAI_API_VERSION=$OPENAI_API_VERSION
- AZURE_OPENAI_API_BASE=$AZURE_OPENAI_API_BASE
- AZURE_OPENAI_API_VERSION=$AZURE_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
- OPENAI_API_BASE=$OPENAI_API_BASE
- OPENAI_API_VERSION=$OPENAI_API_VERSION
- AZURE_OPENAI_API_BASE=$AZURE_OPENAI_API_BASE
- AZURE_OPENAI_API_VERSION=$AZURE_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 "$OPENAI_API_BASE" ]] && [[ -n "$OPENAI_API_VERSION" ]] && [[ -n "$AZURE_DEPLOYMENT_NAME" ]] && [[ -n "$AZURE_EMBEDDINGS_DEPLOYMENT_NAME" ]]; then
if [[ -n "$AZURE_OPENAI_API_BASE" ]] && [[ -n "$AZURE_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("OPENAI_API_BASE")
and os.environ.get("OPENAI_API_VERSION")
os.environ.get("AZURE_OPENAI_API_BASE")
and os.environ.get("AZURE_OPENAI_API_VERSION")
and os.environ.get("AZURE_DEPLOYMENT_NAME")
and os.environ.get("AZURE_EMBEDDINGS_DEPLOYMENT_NAME")
):