mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-01 19:12:42 +00:00
langchain[patch]: infer mistral provider in init_chat_model (#26557)
This commit is contained in:
@@ -109,6 +109,7 @@ def init_chat_model(
|
|||||||
- google_vertexai (langchain-google-vertexai)
|
- google_vertexai (langchain-google-vertexai)
|
||||||
- google_genai (langchain-google-genai)
|
- google_genai (langchain-google-genai)
|
||||||
- bedrock (langchain-aws)
|
- bedrock (langchain-aws)
|
||||||
|
- bedrock_converse (langchain-aws)
|
||||||
- cohere (langchain-cohere)
|
- cohere (langchain-cohere)
|
||||||
- fireworks (langchain-fireworks)
|
- fireworks (langchain-fireworks)
|
||||||
- together (langchain-together)
|
- together (langchain-together)
|
||||||
@@ -120,12 +121,13 @@ def init_chat_model(
|
|||||||
Will attempt to infer model_provider from model if not specified. The
|
Will attempt to infer model_provider from model if not specified. The
|
||||||
following providers will be inferred based on these model prefixes:
|
following providers will be inferred based on these model prefixes:
|
||||||
|
|
||||||
- gpt-3... or gpt-4... -> openai
|
- gpt-3..., gpt-4..., or o1... -> openai
|
||||||
- claude... -> anthropic
|
- claude... -> anthropic
|
||||||
- amazon.... -> bedrock
|
- amazon.... -> bedrock
|
||||||
- gemini... -> google_vertexai
|
- gemini... -> google_vertexai
|
||||||
- command... -> cohere
|
- command... -> cohere
|
||||||
- accounts/fireworks... -> fireworks
|
- accounts/fireworks... -> fireworks
|
||||||
|
- mistral... -> mistralai
|
||||||
configurable_fields: Which model parameters are
|
configurable_fields: Which model parameters are
|
||||||
configurable:
|
configurable:
|
||||||
|
|
||||||
@@ -276,8 +278,13 @@ def init_chat_model(
|
|||||||
|
|
||||||
.. versionchanged:: 0.2.12
|
.. versionchanged:: 0.2.12
|
||||||
|
|
||||||
Support for Ollama via langchain-ollama package added. Previously
|
Support for ChatOllama via langchain-ollama package added
|
||||||
langchain-community version of Ollama (now deprecated) was installed by default.
|
(langchain_ollama.ChatOllama). Previously,
|
||||||
|
the now-deprecated langchain-community version of Ollama was imported
|
||||||
|
(langchain_community.chat_models.ChatOllama).
|
||||||
|
|
||||||
|
Support for langchain_aws.ChatBedrockConverse added
|
||||||
|
(model_provider="bedrock_converse").
|
||||||
|
|
||||||
""" # noqa: E501
|
""" # noqa: E501
|
||||||
if not model and not configurable_fields:
|
if not model and not configurable_fields:
|
||||||
@@ -424,7 +431,7 @@ _SUPPORTED_PROVIDERS = {
|
|||||||
|
|
||||||
|
|
||||||
def _attempt_infer_model_provider(model_name: str) -> Optional[str]:
|
def _attempt_infer_model_provider(model_name: str) -> Optional[str]:
|
||||||
if model_name.startswith("gpt-3") or model_name.startswith("gpt-4"):
|
if any(model_name.startswith(pre) for pre in ("gpt-3", "gpt-4", "o1")):
|
||||||
return "openai"
|
return "openai"
|
||||||
elif model_name.startswith("claude"):
|
elif model_name.startswith("claude"):
|
||||||
return "anthropic"
|
return "anthropic"
|
||||||
@@ -436,6 +443,8 @@ def _attempt_infer_model_provider(model_name: str) -> Optional[str]:
|
|||||||
return "google_vertexai"
|
return "google_vertexai"
|
||||||
elif model_name.startswith("amazon."):
|
elif model_name.startswith("amazon."):
|
||||||
return "bedrock"
|
return "bedrock"
|
||||||
|
elif model_name.startswith("mistral"):
|
||||||
|
return "mistralai"
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user