Find answers from the community

Updated 2 months ago

Langchain tool

Not sure why I'm asking a Langchain question here, probably LangChain community is bit too slow to respond, but it seems really urgent and no one has any answers to this.

---

In brevity, I'm seeking to cite the original source of information, which is retrieved using a Langchain agent with access to a Tool like SerpAPI. However, I can't do that using callbacks since Tools are str -> str. I can only access tool's text output. It would be great if there's a way to tap into Tool's raw output. (Btw SerpAPI is just an example, I want to do this with Drug Tools, PubMed, and Medical Literature, etc.)

Probably I'll have to write my own tool and find a way to inject in a callback each time the tool is called. Is there a set pattern on how to achieve such a goal?
L
H
9 comments
Yea I would write a custom tool that runs the function and records sources however you need.

Exposing the sources at the agent response level seems difficult πŸ‘€
I haven't yet implemented a custom tool, however, is there a way to pass in a handler to a structured tool that's subclassed or is it just str that's passed into a tool by an agent and no way to add a callback?
Any examples you've seen so far?
You'd have to instantiate the tool with the callback I think
Langchain makes it really easy to define tools, there's a few ways
I get it, I was thinking about it in different terms. Got it resolved. Now I can stream citations as they appear when using Tools. Langchain is not an out of the box solution, but really a debugging party. Lots of figuring out.
Attachment
Screenshot_2023-07-09_at_12.44.41_PM.png
Yea, these tools are still early days. But at least it's open source so you can hack if you have the knowledge.

Glad you got it working!
Langchain forum needs more Logans. You've been super helpful. Thanks a lot.
Add a reply
Sign up and join the conversation on Discord