- HTTP request
- Path parameters
- Request body
- Response body
- Authorization scopes
- GroundingPassages
- GroundingPassage
- SemanticRetrieverConfig
- AnswerStyle
- InputFeedback
- BlockReason
Generates a grounded answer from the model given an input GenerateAnswerRequest
.
HTTP request
POST https://generativelanguage.googleapis.com/v1beta/{model=models/*}:generateAnswer
Path parameters
Parameters | |
---|---|
model |
Required. The name of the Format: |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "contents": [ { object ( |
Fields | |
---|---|
contents[] |
Required. The content of the current conversation with the model. For single-turn queries, this is a single question to answer. For multi-turn queries, this is a repeated field that contains conversation history and the last Note: models.generateAnswer currently only supports queries in English. |
answerStyle |
Required. Style in which answers should be returned. |
safetySettings[] |
Optional. A list of unique This will be enforced on the |
Union field grounding_source . The sources in which to ground the answer. grounding_source can be only one of the following: |
|
inlinePassages |
Passages provided inline with the request. |
semanticRetriever |
Content retrieved from resources created via the Semantic Retriever API. |
temperature |
Optional. Controls the randomness of the output. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases. |
Response body
Response from the model for a grounded answer.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "answer": { object ( |
Fields | |
---|---|
answer |
Candidate answer from the model. Note: The model always attempts to provide a grounded answer, even when the answer is unlikely to be answerable from the given passages. In that case, a low-quality or ungrounded answer may be provided, along with a low |
answerableProbability |
Output only. The model's estimate of the probability that its answer is correct and grounded in the input passages. A low answerableProbability indicates that the answer might not be grounded in the sources. When
|
inputFeedback |
Output only. Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. "Input data" can be one or more of the following:
|
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/generative-language
https://www.googleapis.com/auth/generative-language.retriever
https://www.googleapis.com/auth/generative-language.retriever.readonly
https://www.googleapis.com/auth/generative-language.tuning
https://www.googleapis.com/auth/generative-language.tuning.readonly
For more information, see the Authentication Overview.
GroundingPassages
A repeated list of passages.
JSON representation |
---|
{
"passages": [
{
object ( |
Fields | |
---|---|
passages[] |
List of passages. |
GroundingPassage
Passage included inline with a grounding configuration.
JSON representation |
---|
{
"id": string,
"content": {
object ( |
Fields | |
---|---|
id |
Identifier for the passage for attributing this passage in grounded answers. |
content |
Content of the passage. |
SemanticRetrieverConfig
Configuration for retrieving grounding content from a Corpus
or Document
created using the Semantic Retriever API.
JSON representation |
---|
{ "source": string, "query": { object ( |
Fields | |
---|---|
source |
Required. Name of the resource for retrieval, e.g. corpora/123 or corpora/123/documents/abc. |
query |
Required. Query to use for similarity matching |
metadataFilters[] |
Optional. Filters for selecting |
maxChunksCount |
Optional. Maximum number of relevant |
minimumRelevanceScore |
Optional. Minimum relevance score for retrieved relevant |
AnswerStyle
Style for grounded answers.
Enums | |
---|---|
ANSWER_STYLE_UNSPECIFIED |
Unspecified answer style. |
ABSTRACTIVE |
Succint but abstract style. |
EXTRACTIVE |
Very brief and extractive style. |
VERBOSE |
Verbose style including extra details. The response may be formatted as a sentence, paragraph, multiple paragraphs, or bullet points, etc. |
InputFeedback
Feedback related to the input data used to answer the question, as opposed to model-generated response to the question.
JSON representation |
---|
{ "safetyRatings": [ { object ( |
Fields | |
---|---|
safetyRatings[] |
Ratings for safety of the input. There is at most one rating per category. |
blockReason |
Optional. If set, the input was blocked and no candidates are returned. Rephrase your input. |
BlockReason
Specifies what was the reason why input was blocked.
Enums | |
---|---|
BLOCK_REASON_UNSPECIFIED |
Default value. This value is unused. |
SAFETY |
Input was blocked due to safety reasons. You can inspect safetyRatings to understand which safety category blocked it. |
OTHER |
Input was blocked due to other reasons. |