Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The following environment variables are required to run the application:
- `PDF_EXTRACT_IMAGES`: (Optional) A boolean value indicating whether to extract images from PDF files. Default value is "False".
- `DEBUG_RAG_API`: (Optional) Set to "True" to show more verbose logging output in the server console, and to enable postgresql database routes
- `CONSOLE_JSON`: (Optional) Set to "True" to log as json for Cloud Logging aggregations
- `EMBEDDINGS_PROVIDER`: (Optional) either "openai", "bedrock", "azure", "huggingface", "huggingfacetei" or "ollama", where "huggingface" uses sentence_transformers; defaults to "openai"
- `EMBEDDINGS_PROVIDER`: (Optional) either "openai", "bedrock", "azure", "huggingface", "huggingfacetei", "ollama" or "mistral", where "huggingface" uses sentence_transformers; defaults to "openai"
- `EMBEDDINGS_MODEL`: (Optional) Set a valid embeddings model to use from the configured provider.
- **Defaults**
- openai: "text-embedding-3-small"
Expand All @@ -70,6 +70,7 @@ The following environment variables are required to run the application:
- huggingfacetei: "http://huggingfacetei:3000". Hugging Face TEI uses model defined on TEI service launch.
- ollama: "nomic-embed-text"
- bedrock: "amazon.titan-embed-text-v1"
- mistral: "mistral-embed"
- `RAG_AZURE_OPENAI_API_VERSION`: (Optional) Default is `2023-05-15`. The version of the Azure OpenAI API.
- `RAG_AZURE_OPENAI_API_KEY`: (Optional) The API key for Azure OpenAI service.
- Note: `AZURE_OPENAI_API_KEY` will work but `RAG_AZURE_OPENAI_API_KEY` will override it in order to not conflict with LibreChat setting.
Expand All @@ -83,6 +84,7 @@ The following environment variables are required to run the application:
- `AWS_DEFAULT_REGION`: (Optional) defaults to `us-east-1`
- `AWS_ACCESS_KEY_ID`: (Optional) needed for bedrock embeddings
- `AWS_SECRET_ACCESS_KEY`: (Optional) needed for bedrock embeddings
- `MISTRAL_API_KEY`: (Optional) needed for mistral embeddings

Make sure to set these environment variables before running the application. You can set them in a `.env` file or as system environment variables.

Expand Down
14 changes: 13 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EmbeddingsProvider(Enum):
HUGGINGFACETEI = "huggingfacetei"
OLLAMA = "ollama"
BEDROCK = "bedrock"

MISTRAL = "mistral"

def get_env_variable(
var_name: str, default_value: str = None, required: bool = False
Expand Down Expand Up @@ -176,6 +176,7 @@ async def dispatch(self, request, call_next):
OLLAMA_BASE_URL = get_env_variable("OLLAMA_BASE_URL", "http://ollama:11434")
AWS_ACCESS_KEY_ID = get_env_variable("AWS_ACCESS_KEY_ID", "")
AWS_SECRET_ACCESS_KEY = get_env_variable("AWS_SECRET_ACCESS_KEY", "")
MISTRAL_API_KEY = get_env_variable("MISTRAL_API_KEY", "")

## Embeddings

Expand Down Expand Up @@ -226,6 +227,13 @@ def init_embeddings(provider, model):
model_id=model,
region_name=AWS_DEFAULT_REGION,
)
elif provider == EmbeddingsProvider.MISTRAL:
from langchain_mistralai import MistralAIEmbeddings

return MistralAIEmbeddings(
model=model,
api_key=MISTRAL_API_KEY,
)
else:
raise ValueError(f"Unsupported embeddings provider: {provider}")

Expand Down Expand Up @@ -253,6 +261,10 @@ def init_embeddings(provider, model):
"EMBEDDINGS_MODEL", "amazon.titan-embed-text-v1"
)
AWS_DEFAULT_REGION = get_env_variable("AWS_DEFAULT_REGION", "us-east-1")
elif EMBEDDINGS_PROVIDER == EmbeddingsProvider.MISTRAL:
EMBEDDINGS_MODEL = get_env_variable(
"EMBEDDINGS_MODEL", "mistral-embed"
)
else:
raise ValueError(f"Unsupported embeddings provider: {EMBEDDINGS_PROVIDER}")

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pymongo==4.6.3
langchain-mongodb==0.2.0
langchain-ollama==0.2.0
langchain-huggingface==0.1.0
langchain-mistralai==0.2.1
cryptography==44.0.1
python-magic==0.4.27
python-pptx==0.6.23
Expand Down