Find answers from the community

s
F
Y
a
P
Updated last month

Sources

- question , how do I extract source docs from the chat response
L
a
5 comments
Since agents use tools, we put the raw responses from tools in the response

If the tool is a query engine, this means the raw response will be a query response object

agent_response.tool_sources[0].raw_output.source_nodes

There's also a few other attributes here, like name and raw_input
thanks @Logan M is the schema defined somewhere , it gets bit hard to look at long json
and try to figure out
if there is some high level api that could give formatted sources that would be great irrespective of the source
Should probably add the get_formatted_sources function to the agent responses yea πŸ™‚

It's not too hard to parse though. The tool_sources are lists of ToolOutput objects
https://github.com/jerryjliu/llama_index/blob/3f2ad0b076f58e7ad562d3648c2178698297e545/llama_index/tools/types.py#L54

the raw_output of the tool output could be anything (it depends on the tools the agent has), but since you know your tools are query engines, then the raw_output is just a normal Response object
https://github.com/jerryjliu/llama_index/blob/3f2ad0b076f58e7ad562d3648c2178698297e545/llama_index/response/schema.py#L12
Add a reply
Sign up and join the conversation on Discord