Citations in ADK #4063
Replies: 1 comment 1 reply
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR: Yes, ADK provides a native way to get citations for an agent's response, especially when using tools like Hello! Yes, it's possible to retrieve citations for an agent's response in ADK. When an agent's response is grounded in data from a tool like Vertex AI Search, the citation information is available in the You can define an def citation_retrieval_after_model_callback(
response: LlmResponse,
) -> LlmResponse:
"""Adds citations to the response if grounding metadata is present."""
if response.grounding_metadata and response.grounding_metadata.citations:
response.text += "\n\nCitations:\n"
for citation in response.grounding_metadata.citations:
response.text += f" - {citation.source_id}: {citation.text}\n"
return response
# When creating your agent, you can add this callback:
my_agent = LlmAgent(
...
after_model_callbacks=[citation_retrieval_after_model_callback],
)This approach allows you to automatically include citations, which helps in building trust and providing traceability for the information provided by the agent. You can find this example and more details in the ADK documentation. [1] [1] https://github.com/google/adk-python/blob/main/contributing/samples/adk_knowledge_agent/agent.py |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there any native way of getting citations for the Agent's response ?
Beta Was this translation helpful? Give feedback.
All reactions