AzureOpenAI Embedding Model and LLM Model Initialisation from Config. (#1773)

This commit is contained in:
k10
2024-09-01 02:09:00 +05:30
committed by GitHub
parent ad233034ef
commit 077d0c47f9
10 changed files with 88 additions and 22 deletions

View File

@@ -51,6 +51,7 @@ Here's a comprehensive list of all parameters that can be used across different
| `http_client_proxies` | Allow proxy server settings |
| `ollama_base_url` | Base URL for the Ollama embedding model |
| `model_kwargs` | Key-Value arguments for the Huggingface embedding model |
| `azure_kwargs` | Key-Value arguments for the AzureOpenAI embedding model |
| `openai_base_url` | Base URL for OpenAI API | OpenAI |

View File

@@ -2,7 +2,7 @@
title: Azure OpenAI
---
To use Azure OpenAI embedding models, set the `AZURE_OPENAI_API_KEY` environment variable. You can obtain the Azure OpenAI API key from the Azure.
To use Azure OpenAI embedding models, set the `EMBEDDING_AZURE_OPENAI_API_KEY`, `EMBEDDING_AZURE_DEPLOYMENT`, `EMBEDDING_AZURE_ENDPOINT` and `EMBEDDING_AZURE_API_VERSION` environment variables. You can obtain the Azure OpenAI API key from the Azure.
### Usage
@@ -10,8 +10,10 @@ To use Azure OpenAI embedding models, set the `AZURE_OPENAI_API_KEY` environment
import os
from mem0 import Memory
os.environ["OPENAI_API_KEY"] = "your_api_key"
os.environ["AZURE_OPENAI_API_KEY"] = "your_api_key"
os.environ["EMBEDDING_AZURE_OPENAI_API_KEY"] = "your-api-key"
os.environ["EMBEDDING_AZURE_DEPLOYMENT"] = "your-deployment-name"
os.environ["EMBEDDING_AZURE_ENDPOINT"] = "your-api-base-url"
os.environ["EMBEDDING_AZURE_API_VERSION"] = "version-to-use"
config = {
@@ -19,6 +21,12 @@ config = {
"provider": "azure_openai",
"config": {
"model": "text-embedding-3-large"
"azure_kwargs" : {
"api_version" : "",
"azure_deployment" : "",
"azure_endpoint" : "",
"api_key": ""
}
}
}
}
@@ -35,4 +43,4 @@ Here are the parameters available for configuring Azure OpenAI embedder:
| --- | --- | --- |
| `model` | The name of the embedding model to use | `text-embedding-3-small` |
| `embedding_dims` | Dimensions of the embedding model | `1536` |
| `api_key` | The Azure OpenAI API key | `None` |
| `azure_kwargs` | The Azure OpenAI configs | `config_keys` |