Skip to main content

answers

Creates, updates, deletes, gets or lists an answers resource.

Overview

Nameanswers
TypeResource
Idgemini.models.answers

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
answerobjectA response candidate generated from the model.
answerableProbabilitynumber (float)Output only. The model's estimate of the probability that its answer is correct and grounded in the input passages. A low `answerable_probability` indicates that the answer might not be grounded in the sources. When `answerable_probability` is low, you may want to: * Display a message to the effect of "We couldn’t answer that question" to the user. * Fall back to a general-purpose LLM that answers the question from world knowledge. The threshold and nature of such fallbacks will depend on individual use cases. `0.5` is a good starting threshold.
inputFeedbackobjectOutput only. Feedback related to the input data used to answer the question, as opposed to the model-generated response to the question. The input data can be one or more of the following: - Question specified by the last entry in `GenerateAnswerRequest.content` - Conversation history specified by the other entries in `GenerateAnswerRequest.content` - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or `GenerateAnswerRequest.inline_passages`)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
generate_answerselectmodelsIdcontents, safetySettings, semanticRetriever, answerStyle, temperature, inlinePassagesGenerates a grounded answer from the model given an input GenerateAnswerRequest.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
modelsIdstring
answerStylestringRequired. Style in which answers should be returned.
contentsarrayRequired. 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 Content in the list containing the question. Note: GenerateAnswer only supports queries in English.
inlinePassagesobjectA repeated list of passages.
safetySettingsarrayOptional. A list of unique SafetySetting instances for blocking unsafe content. This will be enforced on the GenerateAnswerRequest.contents and GenerateAnswerResponse.candidate. There should not be more than one setting for each SafetyCategory type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each SafetyCategory specified in the safety_settings. If there is no SafetySetting for a given SafetyCategory provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported. Refer to the guide for detailed information on available safety settings. Also refer to the Safety guidance to learn how to incorporate safety considerations in your AI applications.
semanticRetrieverobjectConfiguration for retrieving grounding content from a Corpus or Document created using the Semantic Retriever API.
temperaturenumberOptional. 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.

SELECT examples

Generates a grounded answer from the model given an input GenerateAnswerRequest.

SELECT
answer,
answerableProbability,
inputFeedback
FROM gemini.models.answers
WHERE modelsId = '{{ modelsId }}' -- required
AND contents = '{{ contents }}'
AND safetySettings = '{{ safetySettings }}'
AND semanticRetriever = '{{ semanticRetriever }}'
AND answerStyle = '{{ answerStyle }}'
AND temperature = '{{ temperature }}'
AND inlinePassages = '{{ inlinePassages }}'
;