The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix(langchain): infer provider from mixed-case prefixes (#34672)
Guofang.Tang384158daec7c
diff --git a/libs/langchain_v1/langchain/chat_models/base.py b/libs/langchain_v1/langchain/chat_models/base.pyindex 7f47772321..89a8b00e53 100644--- a/libs/langchain_v1/langchain/chat_models/base.py+++ b/libs/langchain_v1/langchain/chat_models/base.py@@ -501,7 +501,7 @@ def _attempt_infer_model_provider(model_name: str) -> str | None:return "cohere"# Fireworks models- if model_name.startswith("accounts/fireworks"):+ if model_lower.startswith("accounts/fireworks"):return "fireworks"# Google models@@ -509,7 +509,7 @@ def _attempt_infer_model_provider(model_name: str) -> str | None:return "google_vertexai"# AWS Bedrock models- if model_name.startswith("amazon.") or model_lower.startswith(("anthropic.", "meta.")):+ if model_lower.startswith(("amazon.", "anthropic.", "meta.")):return "bedrock"# Mistral modelsdiff --git a/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py b/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.pyindex bdbb39d400..9f9f341fd6 100644--- a/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py+++ b/libs/langchain_v1/tests/unit_tests/chat_models/test_chat_models.py@@ -78,11 +78,14 @@ def test_supported_providers_is_sorted() -> None:("claude-3-haiku-20240307", "anthropic"),("command-r-plus", "cohere"),("accounts/fireworks/models/mixtral-8x7b-instruct", "fireworks"),+ ("Accounts/Fireworks/models/mixtral-8x7b-instruct", "fireworks"),("gemini-1.5-pro", "google_vertexai"),("gemini-2.5-pro", "google_vertexai"),("gemini-3-pro-preview", "google_vertexai"),("amazon.titan-text-express-v1", "bedrock"),+ ("Amazon.Titan-Text-Express-v1", "bedrock"),("anthropic.claude-v2", "bedrock"),+ ("Anthropic.Claude-V2", "bedrock"),("mistral-small", "mistralai"),("mixtral-8x7b", "mistralai"),("deepseek-v3", "deepseek"),