How do I use LangChain Agent with tools in a Python project?
I’m trying to build a project using LangChain where an agent can decide when to call a tool (e.g., a calculator or API): from langchain.agents import initialize_agent, Tool from langchain.llms import OpenAI def my_tool(input): return "Processed: " + input tools = [ Tool(name="MyTool", func=my_tool, description="Processes input") ] llm = OpenAI() agent = initialize_agent( tools, llm, agent="zero-shot-react-description", verbose=True ) response = agent.run("Process this text") print(response) The agent runs but it doesn’t use the tool correctly. How does the agent decide to use a tool? What’s th
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.