langchain
langchain copied to clipboard
How to know which tool(s) been used on `agent_chain.run`?
Hi! After I create an agent using initialize_agent , I can call the agent using agent.run.
I can see the steps on the terminal e.g.:
Thought: Do I need to use a tool? Yes
Action: Index A,
Action Input: ....
but in the end, the run function returns only a final output (string). How can I get the intermediate steps as well? Especially, whether the agent used a tool or not?
+1, I'm still trying to figure out a nice way to do this
Hi @dxv2k ! Can you check out this thread? I was able to implement the functionality using the method proposed in the thread:
Wow, really nice approach. Do you have any output that I can see? Thanks a lot.
Hi @dxv2k ! Can you check out this thread? I was able to implement the functionality using the method proposed in the thread:
@dxv2k Sorry man, I'm out of my pc now, but can send an example output later.
Thanks man, I'll try to implement it tomorrow. I have a side question, does it also store the input of each tool used?
@dxv2k you mean context from documents? I don't think so. At least, I could not find it
Context alone is not enough, I want to extract metadata and query too therefore I need to get every tool it had used with the input of each tool. It would be really helpful if we could figure out a way to do it. My current implementation is that I add another property to track it, not really nice tbh.
I was trying to have the same functionality as well. Why dont you try to get the raw response from agent (its a dict) and parse its intermediate steps to know the tool as well as tool_input.
+1
Hi, @mzhadigerov! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.
From what I understand, the issue was about determining which tool(s) were used during the agent_chain.run process in LangChain. @dxv2k proposed a method and you implemented it. There was a discussion about accessing the intermediate steps and whether the input of each tool used is stored. @KeshavSingh29 suggested getting the raw response from the agent and parsing its intermediate steps to know the tool and tool_input.
Before we close this issue, we wanted to check with you 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 and understanding. Let us know if you have any further questions or concerns!