-
Notifications
You must be signed in to change notification settings - Fork 15.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core, standard tests, partner packages: add test for model params #21677
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@@ -60,6 +63,15 @@ | |||
from langchain_core.tools import BaseTool | |||
|
|||
|
|||
class LangSmithParams(TypedDict, total=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why using both total=False and Optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kind of an abuse of TypedDict because I expect fields to be missing.
here I include all parameters that we are standardizing (including those that can be None). this is mostly just to define them somewhere.
regarding total=False: the implementation of _get_ls_params on BaseChatModel is almost the same as _get_invocation_params() (it just adds ls_model_type="chat"
). so there should be minimal changes in tracing to models on which we haven't implemented _get_ls_params yet. but providers generally don't have the ls_
params yet.
**kwargs: Any, | ||
) -> LangSmithParams: | ||
"""Get standard params for tracing.""" | ||
return LangSmithParams(ls_model_type="chat") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we want this default implementation, and why does it ignore stop words?
…1677) 1. Adds `.get_ls_params` to BaseChatModel which returns ```python class LangSmithParams(TypedDict, total=False): ls_provider: str ls_model_name: str ls_model_type: Literal["chat"] ls_temperature: Optional[float] ls_max_tokens: Optional[int] ls_stop: Optional[List[str]] ``` by default it will only return ```python {ls_model_type="chat", ls_stop=stop} ``` 2. Add these params to inheritable metadata in `CallbackManager.configure` 3. Implement `.get_ls_params` and populate all params for Anthropic + all subclasses of BaseChatOpenAI Sample trace: https://smith.langchain.com/public/d2962673-4c83-47c7-b51e-61d07aaffb1b/r **OpenAI**: <img width="984" alt="Screenshot 2024-05-17 at 10 03 35 AM" src="https://github.com/langchain-ai/langchain/assets/26529506/2ef41f74-a9df-4e0e-905d-da74fa82a910"> **Anthropic**: <img width="978" alt="Screenshot 2024-05-17 at 10 06 07 AM" src="https://github.com/langchain-ai/langchain/assets/26529506/39701c9f-7da5-4f1a-ab14-84e9169d63e7"> **Mistral** (and all others for which params are not yet populated): <img width="977" alt="Screenshot 2024-05-17 at 10 08 43 AM" src="https://github.com/langchain-ai/langchain/assets/26529506/37d7d894-fec2-4300-986f-49a5f0191b03">
.get_ls_params
to BaseChatModel which returnsby default it will only return
Add these params to inheritable metadata in
CallbackManager.configure
Implement
.get_ls_params
and populate all params for Anthropic + all subclasses of BaseChatOpenAISample trace: https://smith.langchain.com/public/d2962673-4c83-47c7-b51e-61d07aaffb1b/r
OpenAI:
Anthropic:
Mistral (and all others for which params are not yet populated):