mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
feat(langchain): add support for Upstage (Solar) in init_chat_model (#34220)
This commit is contained in:
@@ -102,6 +102,7 @@ def init_chat_model(
|
|||||||
- `deepseek...` -> `deepseek`
|
- `deepseek...` -> `deepseek`
|
||||||
- `grok...` -> `xai`
|
- `grok...` -> `xai`
|
||||||
- `sonar...` -> `perplexity`
|
- `sonar...` -> `perplexity`
|
||||||
|
- `solar...` -> `upstage`
|
||||||
model_provider: The model provider if not specified as part of the model arg
|
model_provider: The model provider if not specified as part of the model arg
|
||||||
(see above).
|
(see above).
|
||||||
|
|
||||||
@@ -129,6 +130,7 @@ def init_chat_model(
|
|||||||
- `nvidia` -> [`langchain-nvidia-ai-endpoints`](https://docs.langchain.com/oss/python/integrations/providers/nvidia)
|
- `nvidia` -> [`langchain-nvidia-ai-endpoints`](https://docs.langchain.com/oss/python/integrations/providers/nvidia)
|
||||||
- `xai` -> [`langchain-xai`](https://docs.langchain.com/oss/python/integrations/providers/xai)
|
- `xai` -> [`langchain-xai`](https://docs.langchain.com/oss/python/integrations/providers/xai)
|
||||||
- `perplexity` -> [`langchain-perplexity`](https://docs.langchain.com/oss/python/integrations/providers/perplexity)
|
- `perplexity` -> [`langchain-perplexity`](https://docs.langchain.com/oss/python/integrations/providers/perplexity)
|
||||||
|
- `upstage` -> [`langchain-upstage`](https://docs.langchain.com/oss/python/integrations/providers/upstage)
|
||||||
|
|
||||||
configurable_fields: Which model parameters are configurable at runtime:
|
configurable_fields: Which model parameters are configurable at runtime:
|
||||||
|
|
||||||
@@ -449,6 +451,11 @@ def _init_chat_model_helper(
|
|||||||
from langchain_perplexity import ChatPerplexity
|
from langchain_perplexity import ChatPerplexity
|
||||||
|
|
||||||
return ChatPerplexity(model=model, **kwargs)
|
return ChatPerplexity(model=model, **kwargs)
|
||||||
|
if model_provider == "upstage":
|
||||||
|
_check_pkg("langchain_upstage")
|
||||||
|
from langchain_upstage import ChatUpstage
|
||||||
|
|
||||||
|
return ChatUpstage(model=model, **kwargs)
|
||||||
supported = ", ".join(_SUPPORTED_PROVIDERS)
|
supported = ", ".join(_SUPPORTED_PROVIDERS)
|
||||||
msg = f"Unsupported {model_provider=}.\n\nSupported model providers are: {supported}"
|
msg = f"Unsupported {model_provider=}.\n\nSupported model providers are: {supported}"
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
@@ -475,6 +482,7 @@ _SUPPORTED_PROVIDERS = {
|
|||||||
"ibm",
|
"ibm",
|
||||||
"xai",
|
"xai",
|
||||||
"perplexity",
|
"perplexity",
|
||||||
|
"upstage",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -499,6 +507,8 @@ def _attempt_infer_model_provider(model_name: str) -> str | None:
|
|||||||
return "xai"
|
return "xai"
|
||||||
if model_name.startswith("sonar"):
|
if model_name.startswith("sonar"):
|
||||||
return "perplexity"
|
return "perplexity"
|
||||||
|
if model_name.startswith("solar"):
|
||||||
|
return "upstage"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user