Class GeminiAnswerRequest
- Namespace
- Uralstech.UGemini.Models.Generation.QuestionAnswering
Generates a grounded answer from the model.
public class GeminiAnswerRequest : IGeminiPostRequest, IGeminiRequest
- Inheritance
-
GeminiAnswerRequest
- Implements
- Extension Methods
Remarks
Only available in the beta API.
Constructors
GeminiAnswerRequest(GeminiModelId, bool)
Creates a new GeminiAnswerRequest.
public GeminiAnswerRequest(GeminiModelId model, bool useBetaApi = true)
Parameters
model
GeminiModelIdThe model to use.
useBetaApi
boolShould the request use the Beta API?
Remarks
Only available in the beta API.
Fields
AnswerStyle
Style in which answers should be returned.
public GeminiAnswerStyle AnswerStyle
Field Value
ApiVersion
The API version to use.
public string ApiVersion
Field Value
Contents
The content of the current conversation with the model.
public GeminiContent[] Contents
Field Value
Remarks
For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request.
generateAnswer currently only supports queries in English.
InlinePassages
Passages provided inline with the request.
public GeminiGroundingPassages InlinePassages
Field Value
Remarks
This or SemanticRetriever are must be provided at a time.
Model
The model to use.
public GeminiModelId Model
Field Value
SafetySettings
A list of unique GeminiSafetySettings instances for blocking unsafe content.
public GeminiSafetySettings[] SafetySettings
Field Value
Remarks
This will be enforced on Contents and Answer.
There should not be more than one setting for each GeminiSafetyHarmCategory 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 GeminiSafetyHarmCategory specified in the SafetySettings. If there is
no GeminiSafetySettings for a given GeminiSafetyHarmCategory provided in the list, the API will use the
default safety setting for that category. Harm categories HateSpeech,
SexuallyExplicit, DangerousContent and
Harassment are supported.
SemanticRetriever
Content retrieved from resources created via the Semantic Retriever API.
public GeminiSemanticRetrieverConfig SemanticRetriever
Field Value
Remarks
This or InlinePassages are must be provided at a time.
Temperature
Controls the randomness of the output.
public float Temperature
Field Value
Remarks
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.
Properties
AuthMethod
The preferred authentication method.
public GeminiAuthMethod AuthMethod { get; set; }
Property Value
ContentType
The MIME type of the request content.
public string ContentType { get; }
Property Value
OAuthAccessToken
The OAuth access token to authenticate the request, if using OAuthAccessToken as AuthMethod.
public string OAuthAccessToken { get; set; }
Property Value
Methods
GetEndpointUri(GeminiRequestMetadata)
Gets the URI to the API endpoint.
public string GetEndpointUri(GeminiRequestMetadata metadata)
Parameters
metadata
GeminiRequestMetadataThe metadata of the request to be carried out on the URI.
Returns
- string
The URI.
GetUtf8EncodedData()
Converts the request object to a UTF-8 encoded string.
public string GetUtf8EncodedData()
Returns
- string
The string data.