Find answers from the community

Updated 5 months ago

Hi @WhiteFang_Jr , @Logan M , @kapa.ai#

Hi @WhiteFang_Jr , @Logan M , @kapa.ai

I'm having trouble retrieving source_nodes from my agent (Function Calling Agent Worker and Agent Runner). The code below was working previously, but now it fails to return the relevant nodes. I am not understanding the reason for it .

Code :-
def get_text_nodes(
nodes: List[NodeWithScore],
) -> List[NodeWithScore]:
text_nodes = []
for res_node in nodes:
text_nodes.append(res_node)
return text_nodes

def relevant_nodes(response: AGENT_CHAT_RESPONSE_TYPE):
text_nodes = get_text_nodes(response.source_nodes)
# Extract the nodes from here,

response = agent.chat(query)
relevant_docs = relevant_nodes(response=response)

The issue seems to be with extracting source_nodes correctly. Any suggestions or fixes would be greatly appreciated.
L
p
8 comments
I dont know what the issue is here? What do you mean it fails?
Previously, I was able to successfully retrieve these source_nodes, but now I am getting an empty list.

It's because of using prompt template or else where is the issue I am not understanding , If possible you share some resources on getting source nodes when I am using (Function Calling Agent Worker and Agent Runner).
It would really help me .
If its empty, I think that means that the agent didn't actually call a query engine tool and responded directly
Thanks @Logan M for your prompt response.

query engine tool is nothing but the function output and llm response is the agent response Right ?

If it's right then , I am getting function output and LLM response but not the source_nodes.
Do you this is the right way to get source nodes [response.source_nodes] ?
text_nodes = get_text_nodes(response.source_nodes)

Is there any alternative way to get the source nodes ?
Right, but what I'm saying is that the LLM isn't actually calling a tool that returns source nodes

You can see all tool calls under response.sources -- I have a feeling its probably empty
Ok , I will re-check everything .

If possible can I send you my code personally?
Add a reply
Sign up and join the conversation on Discord