-
Notifications
You must be signed in to change notification settings - Fork 15.7k
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
Pass kwargs from initialize_agent into agent classmethod #799
Conversation
This reverts commit 6506bb0.
langchain/agents/initialize.py
Outdated
@@ -51,7 +51,7 @@ def initialize_agent( | |||
) | |||
agent_cls = AGENT_TO_CLASS[agent] | |||
agent_obj = agent_cls.from_llm_and_tools( | |||
llm, tools, callback_manager=callback_manager | |||
llm, tools, callback_manager=callback_manager, **kwargs |
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.
these are the same kwargs also passed to the AgentExecutor though right? thats kind of an issue...
could we add another parameter that is agent_kwargs = Optional[dict] = None
that we pass through here
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.
done
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.
awesome addition - thanks!
Problem
I noticed that in order to change the prefix of the prompt in the
zero-shot-react-description
agentwe had to dig around to subset strings deep into the agent's attributes. It requires the user to inspect a long chain of attributes and classes.
initialize_agent -> AgentExecutor -> Agent -> LLMChain -> Prompt from Agent.create_prompt
Implemented Solution
initialize_agent
accepts**kwargs
but passes it toAgentExecutor
but notZeroShotAgent
, by simply giving the kwargs to the agent class methods we can support changing the prefix and suffix for one agent while allowing future agents to take advantage ofinitialize_agent
.To be fair, this was before finding docs around custom agents here: https://langchain.readthedocs.io/en/latest/modules/agents/examples/custom_agent.html?highlight=custom%20#custom-llmchain but i find that my use case just needed to change the prefix a little.
Changes