-
Notifications
You must be signed in to change notification settings - Fork 20.1k
chore(langchain): simplify create_agent so mypy can infer typing #34309
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
base: master
Are you sure you want to change the base?
Conversation
a33913e to
1b1d5fe
Compare
I don't think this makes sense, we do use edit - I see what you mean re caller of |
d9a255b to
91ba781
Compare
91ba781 to
f8037a0
Compare
|
Should we go ahead and make the input and output types public here? |
Done. This also removed 2 ruff warnings 😃 |
| ) -> CompiledStateGraph[ | ||
| AgentState[ResponseT], ContextT, _InputAgentState, _OutputAgentState[ResponseT] | ||
| ]: | ||
| ) -> CompiledStateGraph[Any, ContextT, InputAgentState, Any]: |
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.
| ) -> CompiledStateGraph[Any, ContextT, InputAgentState, Any]: | |
| ) -> CompiledStateGraph[AgentState[ResponseT], ContextT, InputAgentState, OutputAgentState[ResponseT]] |
Does this hurt?
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.
Does this hurt?
Yes, because if we do that, mypy can't infer the type of the create_agent call and the caller has to define it explicitly. It's the goal of this PR to remove these types so that mypy can do the inference.
Those generics (StateT and OutputT) are not used anyway in CompiledStateGraph.
CompiledStateGraph'sStateTandOutputTare useless for the caller ofcreate_agent.So we can replace them by
Anyand this make mypy able to correctly infer the typing.NB: it would be nice to change the signature of
CompiledStateGraphto aGeneric[ContextT, InputT]in LangGraph since it does not useStateTandOutputT.