YandexGPT API, gRPC: TextGenerationAsyncService.Instruct
RPC method for instructing the model to generate text.
gRPC request
rpc Instruct (InstructRequest) returns (operation.Operation)
InstructRequest
{
"model": "string",
"generationOptions": {
"partialResults": "bool",
"temperature": "google.protobuf.DoubleValue",
"maxTokens": "google.protobuf.Int64Value"
},
// Includes only one of the fields `instructionText`, `instructionUri`
"instructionText": "string",
"instructionUri": "string",
// end of the list of possible fields
// Includes only one of the fields `requestText`
"requestText": "string"
// end of the list of possible fields
}
Request for instructing the model to generate text.
Field |
Description |
model |
string The name or identifier of the model to be used for text generation. |
generationOptions |
Configuration options for text generation. |
instructionText |
string The text-based instruction for text generation. Includes only one of the fields Text precondition or context of the request. |
instructionUri |
string A URI containing instructions for text generation. Includes only one of the fields Text precondition or context of the request. |
requestText |
string The text-based request for text generation. Includes only one of the fields Request for text generation. |
GenerationOptions
Defines the options for text generation.
Field |
Description |
partialResults |
bool Enables streaming of partially generated text. |
temperature |
Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). |
maxTokens |
Sets the maximum limit on the total number of tokens used for both the input prompt and the generated response. |
operation.Operation
{
"id": "string",
"description": "string",
"createdAt": "google.protobuf.Timestamp",
"createdBy": "string",
"modifiedAt": "google.protobuf.Timestamp",
"done": "bool",
"metadata": "google.protobuf.Any",
// Includes only one of the fields `error`, `response`
"error": "google.rpc.Status",
"response": {
"alternatives": [
{
"text": "string",
"score": "double",
"numTokens": "int64"
}
],
"numPromptTokens": "int64"
}
// end of the list of possible fields
}
An Operation resource. For more information, see Operation.
Field |
Description |
id |
string ID of the operation. |
description |
string Description of the operation. 0-256 characters long. |
createdAt |
Creation timestamp. |
createdBy |
string ID of the user or service account who initiated the operation. |
modifiedAt |
The time when the Operation resource was last modified. |
done |
bool If the value is |
metadata |
Service-specific metadata associated with the operation. |
error |
The error result of the operation in case of failure or cancellation. Includes only one of the fields The operation result. |
response |
The normal response of the operation in case of success. Includes only one of the fields The operation result. |
InstructResponse
Response containing generated text alternatives and token count.
Field |
Description |
alternatives[] |
A list of alternative text responses. |
numPromptTokens |
int64 The number of tokens used in the prompt, including both the instructionText and requestText. |
Alternative
Represents an alternative generated response, including its score and token count.
Field |
Description |
text |
string The generated text response. |
score |
double The score or confidence of the generated text. |
numTokens |
int64 The number of tokens in the generated response. |