fix(langchain): infer provider from mixed-case prefixes (#34672)

Fix provider inference for mixed-case model prefixes and add matching
unit coverage.
This commit is contained in:
Guofang.Tang
2026-01-10 00:07:14 +08:00
committed by GitHub
parent c080296bed
commit 384158daec
2 changed files with 5 additions and 2 deletions

View File

@@ -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 models

View File

@@ -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"),