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?
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?
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.