File tree Expand file tree Collapse file tree 6 files changed +62
-0
lines changed Expand file tree Collapse file tree 6 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT=text-embedding-ada-002
1616# settings for Cohere
1717COHERE_API_KEY = <COHERE_API_KEY>
1818
19+ # settings for Mistral
20+ # MISTRAL_API_KEY=placeholder
21+
1922# settings for local models
2023LOCAL_MODEL = qwen2.5:7b
2124LOCAL_MODEL_EMBEDDINGS = nomic-embed-text
Original file line number Diff line number Diff line change 243243 },
244244 "default" : False ,
245245}
246+ KH_LLMS ["mistral" ] = {
247+ "spec" : {
248+ "__type__" : "kotaemon.llms.ChatOpenAI" ,
249+ "base_url" : "https://api.mistral.ai/v1" ,
250+ "model" : "ministral-8b-latest" ,
251+ "api_key" : config ("MISTRAL_API_KEY" , default = "your-key" ),
252+ },
253+ "default" : False ,
254+ }
246255
247256# additional embeddings configurations
248257KH_EMBEDDINGS ["cohere" ] = {
262271 },
263272 "default" : not IS_OPENAI_DEFAULT ,
264273}
274+ KH_EMBEDDINGS ["mistral" ] = {
275+ "spec" : {
276+ "__type__" : "kotaemon.embeddings.LCMistralEmbeddings" ,
277+ "model" : "mistral-embed" ,
278+ "api_key" : config ("MISTRAL_API_KEY" , default = "your-key" ),
279+ },
280+ "default" : False ,
281+ }
265282# KH_EMBEDDINGS["huggingface"] = {
266283# "spec": {
267284# "__type__": "kotaemon.embeddings.LCHuggingFaceEmbeddings",
Original file line number Diff line number Diff line change 66 LCCohereEmbeddings ,
77 LCGoogleEmbeddings ,
88 LCHuggingFaceEmbeddings ,
9+ LCMistralEmbeddings ,
910 LCOpenAIEmbeddings ,
1011)
1112from .openai import AzureOpenAIEmbeddings , OpenAIEmbeddings
2021 "LCCohereEmbeddings" ,
2122 "LCHuggingFaceEmbeddings" ,
2223 "LCGoogleEmbeddings" ,
24+ "LCMistralEmbeddings" ,
2325 "OpenAIEmbeddings" ,
2426 "AzureOpenAIEmbeddings" ,
2527 "FastEmbedEmbeddings" ,
Original file line number Diff line number Diff line change @@ -254,3 +254,40 @@ def _get_lc_class(self):
254254 raise ImportError ("Please install langchain-google-genai" )
255255
256256 return GoogleGenerativeAIEmbeddings
257+
258+
259+ class LCMistralEmbeddings (LCEmbeddingMixin , BaseEmbeddings ):
260+ """Wrapper around LangChain's MistralAI embedding, focusing on key parameters"""
261+
262+ api_key : str = Param (
263+ help = "API key (https://console.mistral.ai/api-keys)" ,
264+ default = None ,
265+ required = True ,
266+ )
267+ model : str = Param (
268+ help = "Model name to use ('mistral-embed')" ,
269+ default = "mistral-embed" ,
270+ required = True ,
271+ )
272+
273+ def __init__ (
274+ self ,
275+ model : str = "mistral-embed" ,
276+ api_key : Optional [str ] = None ,
277+ ** params ,
278+ ):
279+ super ().__init__ (
280+ model = model ,
281+ api_key = api_key ,
282+ ** params ,
283+ )
284+
285+ def _get_lc_class (self ):
286+ try :
287+ from langchain_mistralai import MistralAIEmbeddings
288+ except ImportError :
289+ raise ImportError (
290+ "Please install langchain_mistralai: "
291+ "`pip install -U langchain_mistralai`"
292+ )
293+ return MistralAIEmbeddings
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ dependencies = [
3636 " langchain-google-genai>=1.0.3,<2.0.0" ,
3737 " langchain-anthropic" ,
3838 " langchain-ollama" ,
39+ " langchain-mistralai" ,
3940 " langchain-cohere>=0.2.4,<0.3.0" ,
4041 " llama-hub>=0.0.79,<0.1.0" ,
4142 " llama-index>=0.10.40,<0.11.0" ,
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ def load_vendors(self):
5959 LCCohereEmbeddings ,
6060 LCGoogleEmbeddings ,
6161 LCHuggingFaceEmbeddings ,
62+ LCMistralEmbeddings ,
6263 OpenAIEmbeddings ,
6364 TeiEndpointEmbeddings ,
6465 )
@@ -70,6 +71,7 @@ def load_vendors(self):
7071 LCCohereEmbeddings ,
7172 LCHuggingFaceEmbeddings ,
7273 LCGoogleEmbeddings ,
74+ LCMistralEmbeddings ,
7375 TeiEndpointEmbeddings ,
7476 ]
7577
You can’t perform that action at this time.
0 commit comments