langchain-ai / langchain

πŸ¦œπŸ”— Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.52k stars 14.81k forks source link

BabyAGI implementation with tools with multiple inputs (requiring Structured Tool Chat Agent) #8346

Closed toadFrogski closed 10 months ago

toadFrogski commented 1 year ago

Discussed in https://github.com/langchain-ai/langchain/discussions/5410

Originally posted by **luca-git** May 29, 2023 My goal is to extend the tools used by baby AGI, more specifically to use at least the basic WriteFileTool() and ReadFileTool(). They use two inputs though, so I cannot stick with the vanilla ZeroShotAgent. So i resorted to using: AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION and replace it in the original code in the link below. Agent initialization is the only modification I've made. Can anyone kindly help me understand what I'm missing in the code in order to be able to leverage multiple input tools or provide guidance/resources? https://python.langchain.com/en/latest/use_cases/agents/baby_agi_with_agent.html?highlight=babyagi%20with%20tools ```python from langchain.agents import AgentType from langchain.agents import initialize_agent @classmethod def from_llm( cls, llm: BaseLLM, vectorstore: VectorStore, verbose: bool = False, **kwargs ) -> "BabyAGI": """Initialize the BabyAGI Controller.""" task_creation_chain = TaskCreationChain.from_llm(llm, verbose=verbose) task_prioritization_chain = TaskPrioritizationChain.from_llm( llm, verbose=verbose ) llm_chain = LLMChain(llm=llm, prompt=prompt) tool_names = [tool.name for tool in tools] agent = initialize_agent(agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,llm=llm_chain, tools=tool_names) agent_executor = AgentExecutor.from_agent_and_tools( agent=agent, tools=tools, verbose=True ) return cls( task_creation_chain=task_creation_chain, task_prioritization_chain=task_prioritization_chain, execution_chain=agent_executor, vectorstore=vectorstore, **kwargs, ) ``` I get the error ```python File ~\anaconda3\envs\aagi\lib\site-packages\langchain\agents\structured_chat\base.py:83 in create_prompt args_schema = re.sub("}", "}}}}", re.sub("{", "{{{{", str(tool.args))) AttributeError: 'str' object has no attribute 'args' ```
dosubot[bot] commented 1 year ago

Answer generated by a πŸ€–

Answer

I found related issues that might be helpful. I did my best to summarize the solutions, but I recommend looking at the related issues yourself.

Open Issues

error thrown when trying to implement BabyAGI with tools with multiple inputs (requiring Structured Tool Chat Agent)

No discussion on issue


This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

dosubot[bot] commented 11 months ago

Hi, @toadFrogski! I'm Dosu, and I'm helping the LangChain team manage our backlog. I wanted to let you know that we are marking this issue as stale.

Based on my understanding, you are trying to extend the tools used by BabyAGI to include WriteFileTool() and ReadFileTool(), which require multiple inputs. You encountered an error related to the 'args' attribute and sought guidance on modifying the code to leverage multiple input tools. There has been a response from me suggesting to look at related open issues for possible solutions.

Before we close this issue, we wanted to check if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your contribution to the LangChain repository!