From 510f4e720cc95297a5adbae0e21d6dfbf81d542e Mon Sep 17 00:00:00 2001 From: Connor <36115510+ScarFX@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:53:40 -0500 Subject: [PATCH] refactor: azure openai proxy env vars --- README.md | 2 ++ config.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 37bdcdf..4cbe388 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,8 @@ The following environment variables are required to run the application: - `RAG_AZURE_OPENAI_ENDPOINT`: (Optional) The endpoint URL for Azure OpenAI service, including the resource. - Example: `https://YOUR_RESOURCE_NAME.openai.azure.com`. - Note: `AZURE_OPENAI_ENDPOINT` will work but `RAG_AZURE_OPENAI_ENDPOINT` will override it in order to not conflict with LibreChat setting. +- `RAG_AZURE_OPENAI_BASEURL`: (Optional) The base URL for your Azure OpenAI API Embeddings +- `RAG_AZURE_OPENAI_PROXY`: (Optional) Proxy for Azure OpenAI API Embeddings - `HF_TOKEN`: (Optional) if needed for `huggingface` option. - `OLLAMA_BASE_URL`: (Optional) defaults to `http://ollama:11434`. - `ATLAS_SEARCH_INDEX`: (Optional) the name of the vector search index if using Atlas MongoDB, defaults to `vector_index` diff --git a/config.py b/config.py index 7b94a97..870e8a2 100644 --- a/config.py +++ b/config.py @@ -165,6 +165,8 @@ async def dispatch(self, request, call_next): RAG_AZURE_OPENAI_ENDPOINT = get_env_variable( "RAG_AZURE_OPENAI_ENDPOINT", AZURE_OPENAI_ENDPOINT ).rstrip("/") +RAG_AZURE_OPENAI_BASEURL = get_env_variable("RAG_AZURE_OPENAI_BASEURL", None) +RAG_AZURE_OPENAI_PROXY = get_env_variable("RAG_AZURE_OPENAI_PROXY", None) HF_TOKEN = get_env_variable("HF_TOKEN", "") OLLAMA_BASE_URL = get_env_variable("OLLAMA_BASE_URL", "http://ollama:11434") AWS_ACCESS_KEY_ID = get_env_variable("AWS_ACCESS_KEY_ID", "") @@ -191,6 +193,8 @@ def init_embeddings(provider, model): api_key=RAG_AZURE_OPENAI_API_KEY, azure_endpoint=RAG_AZURE_OPENAI_ENDPOINT, api_version=RAG_AZURE_OPENAI_API_VERSION, + openai_api_base=RAG_AZURE_OPENAI_BASEURL, + openai_proxy=RAG_AZURE_OPENAI_PROXY, ) elif provider == EmbeddingsProvider.HUGGINGFACE: from langchain_huggingface import HuggingFaceEmbeddings