mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-22 14:49:29 +00:00
langchain: infer Perplexity provider for sonar model prefix (#30861)
**Description:** This PR adds provider inference logic to `init_chat_model` for Perplexity models that use the "sonar..." prefix (`sonar`, `sonar-pro`, `sonar-reasoning`, `sonar-reasoning-pro` or `sonar-deep-research`). This allows users to initialize these models by simply passing the model name, without needing to explicitly set `model_provider="perplexity"`. The docstring for `init_chat_model` has also been updated to reflect this new inference rule.
This commit is contained in:
parent
085baef926
commit
4ff576e37d
@ -133,6 +133,7 @@ def init_chat_model(
|
|||||||
- 'mistral...' -> 'mistralai'
|
- 'mistral...' -> 'mistralai'
|
||||||
- 'deepseek...' -> 'deepseek'
|
- 'deepseek...' -> 'deepseek'
|
||||||
- 'grok...' -> 'xai'
|
- 'grok...' -> 'xai'
|
||||||
|
- 'sonar...' -> 'perplexity'
|
||||||
configurable_fields: Which model parameters are
|
configurable_fields: Which model parameters are
|
||||||
configurable:
|
configurable:
|
||||||
|
|
||||||
@ -504,6 +505,8 @@ def _attempt_infer_model_provider(model_name: str) -> Optional[str]:
|
|||||||
return "deepseek"
|
return "deepseek"
|
||||||
elif model_name.startswith("grok"):
|
elif model_name.startswith("grok"):
|
||||||
return "xai"
|
return "xai"
|
||||||
|
elif model_name.startswith("sonar"):
|
||||||
|
return "perplexity"
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user