Find answers from the community

Updated 3 months ago

why does the CitatioNQueryEngine does not print the citations of the response?

why does the CitatioNQueryEngine does not print the citations of the response?
k
L
6 comments
Please stand by @Leonardo Oliva as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
The CitationQueryEngine does not automatically print the citations of the response. However, you can manually print the cited passages that were used to construct the response. Here's how you can do it:

Plain Text
# Show cited passages that were used to construct the response.
for cited_text in [node.text for node in response.source_nodes]:
    print(f"Cited text: {cited_text}")


This code will iterate over the source_nodes of the response, which contain the citations, and print each one.

You can find this information in the following knowledge source: source ()
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
How I can print the citations over the response?
@kapa.ai How I can print the citations over the response?
Let me check the knowledge base for you. One moment! :books:
----------------------
To print the citations over the response, you can use the source_nodes attribute of the response object. Each source_node represents a citation that was used to construct the response. Here's an example of how you can do it:

Plain Text
# Show cited passages that were used to construct the response.
for cited_text in [node.text for node in response.source_nodes]:
    print(f"Cited text: {cited_text}")


This code will iterate over the source_nodes of the response, which contain the citations, and print each one.

You can find this information in the following knowledge source: source ()
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Add a reply
Sign up and join the conversation on Discord