feat: add options for Mistral AI (#707) #none

* add Mistral AI emb AI embedding vendor, types

* add mistral env setting to example

* add mistral LLM option

* chore: fix default embedding back to normal

* fix: comfort CI

---------

Co-authored-by: Tadashi <tadashi@cinnamon.is>
This commit is contained in:
Amin
2025-04-15 03:11:22 -05:00
committed by GitHub
parent 9b05693e4f
commit c33bedca9e
6 changed files with 62 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ from .langchain_based import (
LCCohereEmbeddings,
LCGoogleEmbeddings,
LCHuggingFaceEmbeddings,
LCMistralEmbeddings,
LCOpenAIEmbeddings,
)
from .openai import AzureOpenAIEmbeddings, OpenAIEmbeddings
@@ -20,6 +21,7 @@ __all__ = [
"LCCohereEmbeddings",
"LCHuggingFaceEmbeddings",
"LCGoogleEmbeddings",
"LCMistralEmbeddings",
"OpenAIEmbeddings",
"AzureOpenAIEmbeddings",
"FastEmbedEmbeddings",

View File

@@ -254,3 +254,40 @@ class LCGoogleEmbeddings(LCEmbeddingMixin, BaseEmbeddings):
raise ImportError("Please install langchain-google-genai")
return GoogleGenerativeAIEmbeddings
class LCMistralEmbeddings(LCEmbeddingMixin, BaseEmbeddings):
"""Wrapper around LangChain's MistralAI embedding, focusing on key parameters"""
api_key: str = Param(
help="API key (https://console.mistral.ai/api-keys)",
default=None,
required=True,
)
model: str = Param(
help="Model name to use ('mistral-embed')",
default="mistral-embed",
required=True,
)
def __init__(
self,
model: str = "mistral-embed",
api_key: Optional[str] = None,
**params,
):
super().__init__(
model=model,
api_key=api_key,
**params,
)
def _get_lc_class(self):
try:
from langchain_mistralai import MistralAIEmbeddings
except ImportError:
raise ImportError(
"Please install langchain_mistralai: "
"`pip install -U langchain_mistralai`"
)
return MistralAIEmbeddings

View File

@@ -36,6 +36,7 @@ dependencies = [
"langchain-google-genai>=1.0.3,<2.0.0",
"langchain-anthropic",
"langchain-ollama",
"langchain-mistralai",
"langchain-cohere>=0.2.4,<0.3.0",
"llama-hub>=0.0.79,<0.1.0",
"llama-index>=0.10.40,<0.11.0",

View File

@@ -59,6 +59,7 @@ class EmbeddingManager:
LCCohereEmbeddings,
LCGoogleEmbeddings,
LCHuggingFaceEmbeddings,
LCMistralEmbeddings,
OpenAIEmbeddings,
TeiEndpointEmbeddings,
)
@@ -70,6 +71,7 @@ class EmbeddingManager:
LCCohereEmbeddings,
LCHuggingFaceEmbeddings,
LCGoogleEmbeddings,
LCMistralEmbeddings,
TeiEndpointEmbeddings,
]