langchain
langchain copied to clipboard
[structure][agent class] Move Overlapping Methods to a Shared Base Class
BaseSingleActionAgentandBaseMultiActionAgentare pretty much the same. In the original PR where MultiActionAgent was introduced, @hwchase17 shared the worry that MultiActionAgent is so under-explored that it would potentially be really different from the SingleActionAgent. It could still be true when the autonomous agent grows.- Given the above, this PR still keeps the strict distinguishing between these two classes and at the same time reduce the duplicate logics as much as possible. Itβs still very convenient to change any of the methods and make them as different as we want.
Test:
- as the logic is so deep and core, all existing integration test should be able to cover it.
- Iβll add additional integration tests in following PRs when we start ramping up on concrete business inheritance. :)
- Tested additionally by calling an agent directly with 2 provided tools and then confirm all functionality the same
def test_agent_chain_chat_bot():
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI
from langchain.utilities.duckduckgo_search import DuckDuckGoSearchAPIWrapper
chat = ChatOpenAI(temperature=0)
llm = OpenAI(temperature=0)
tools = load_tools(["ddg-search", "llm-math"], llm=llm)
agent = initialize_agent(tools, chat, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
agent.run("Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?")
test_agent_chain_chat_bot()
@vowelparrot , please take a look when you have time. Thank you so much. :)
Will sync with @hwchase17 on this one and review tomorrow
Will sync with @hwchase17 on this one and review tomorrow
Thank you so much. Really appreciate it. :) (let me quickly rebase now to make it easier for you.)
@vowelparrot please lmk what is your discussion result with Harrison. Thank you so much!
some feedback we've gotten from users is theres a lot of inheritance already and it can make it tricky to understand whats going on. although this may save code, i think this contributes to that problem. therefor, i dont think we want to do this at the moment