Return sources from custom retriever with langchain knowledge base

I am using LangchainKnowledgeBase for agent. I created a custom retriever for this knowledge base which implements the langchain “_get_relevant_documents” method.
How can I get the sources returned to final agent answer (without relying on llm). I am basically looking to return top 3/5 sources matched in vector search.
Does phidata agent support anything ready to use for this?

1 Like

Got it in


run: RunResponse = myagent.run(query)
message_reference = run.extra_data.references[0]
sources = message_reference.references
1 Like

Hi @sujata

I’m so glad to see you found the solution! :blush: Please don’t hesitate to reach out if you have any more questions or need further assistance—we’re always happy to help.