Find answers from the community

Updated last year

Hi Guys can someone please help me with

Hi Guys, can someone please help me with this?
When running the multiDocumentAgentDemo, how can I track the sources of the response generated by the top_agent? Here the top_agent is a agent based on the index of multiple agents

tool_mapping = SimpleToolNodeMapping.from_objects(all_tools)
obj_index = ObjectIndex.from_objects(
all_tools,
tool_mapping,
VectorStoreIndex,
)

top_agent = FnRetrieverOpenAIAgent.from_retriever(
obj_index.as_retriever(similarity_top_k=3))

response = top_agent.query("question")
W
l
11 comments
Does print(response.source_nodes) not work?
it returns a empty list []
The repsonse itself looks like this
Response(response='Boston has a thriving arts and culture scene with a variety of offerings. ... The Museum of Fine Arts, Isabella Stewart Gardner Museum, and Institute of Contemporary Art are notable institutions that house a wide range of artworks, from classical to contemporary. These venues provide a rich cultural experience for both residents and visitors.', source_nodes=[], metadata=None)
I think that the top_agent synthesize the final response based on previous response generated by the sub_agents, thus the empty list makes sense because the top_agent do not access the nodes directly... but I don't know how to check the nodes accessed by the sub_agents..
Could be! Let me check the Demo once, Let me see if I can help
Thank you very much!
Can you share the link for the demo
I might be wrong, but try this maybe you'll get the response sorce nodes with scores.
Plain Text
nodes_with_score = top_agent._get_tools(user_query)

I see, that in query_engine interface, Only the response is being returned.

You can also try chat, I checked the code. Source nodes are being returned in this mode.
It will be something like
Plain Text
response = top_agent.chat(user_query)


Give both of them a try. Hoping it solves your issue.

CC: @Logan M
Thank you for the information, I will give the feedback here later
@WhiteFang_Jr Thank you again for the information, they are very helpful for my question. Here is my temp solution:

I need to combine the following two steps to track the sub_agent and sources_nodes:

Step 1.

Both <top_agent.query("Query")> and <top_agent.chat("Query")> give response, choose one to generate the response.


After having the response, <top_agent.sources> will return something include the 'tool_name' indicate which one sub_agent it used.


(not clear yet whether it will return multiple 'tool_names' depend on the query in the case requires information from multiple sub_agents )


Step 2.

This requires step 1 done to have information stored in the 'engine' object

<nodes_with_score = top_agent._get_tools("Query")> returns the list of candidate sub_agents can be used

<nodes_with_score[0].query_engine.sources> get the engine object from the tool, then access to the source_nodes


With above steps, I am able to track which sub_agent(tool_name) is used, and which source_nodes the sub_agent used.

CC: @Logan M
Add a reply
Sign up and join the conversation on Discord