Hello,
I used to have a search functionality with LLM response where the citations were included in-line and when clicked pointed to a result from search results like so:
"example [1]"
Now, however, Google has changed it (in the search preview too) to have clickable link icons that expand and show the sources like so:
My question is, how can I achieve the same functionality? The LLM response now is a string without any source numbers, references, or anything else, just a plain response
Thank you so much for your time and any help provided
Solved! Go to Solution.
Hi @dosmac,
Welcome to Google Cloud Community!
You’d like your LLM responses to include citations for greater transparency and to easily track sources.
Here's how to achieve that using Google Search's API:
1. Request Citations in Your Search: When submitting your search request, include the following parameters in your contentSearchSpec.summarySpec:
includeCitations: true:
This tells the API to include citation numbers in the summary.summaryResultCount (optional)
: Specify how many top results you want the summary to be generated from (maximum 5).maxExtractiveAnswerCount (optional)
: Controls how many "extractive answers" (direct snippets from the source) are included per search result.2. Access the Citations in the Response: The API response will contain the following information:
startIndex and endIndex:
The start and end positions of the cited sentence in the text.sources:
A list of the source indices (referenceIndex) for each reference used in the sentence.references:
An array with metadata about each cited source, such as title, document name, and URL.Additional considerations:
I hope the above information is helpful.
Hi @dosmac,
Welcome to Google Cloud Community!
You’d like your LLM responses to include citations for greater transparency and to easily track sources.
Here's how to achieve that using Google Search's API:
1. Request Citations in Your Search: When submitting your search request, include the following parameters in your contentSearchSpec.summarySpec:
includeCitations: true:
This tells the API to include citation numbers in the summary.summaryResultCount (optional)
: Specify how many top results you want the summary to be generated from (maximum 5).maxExtractiveAnswerCount (optional)
: Controls how many "extractive answers" (direct snippets from the source) are included per search result.2. Access the Citations in the Response: The API response will contain the following information:
startIndex and endIndex:
The start and end positions of the cited sentence in the text.sources:
A list of the source indices (referenceIndex) for each reference used in the sentence.references:
An array with metadata about each cited source, such as title, document name, and URL.Additional considerations:
I hope the above information is helpful.
Thanks for your reply!
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |