YandexGPT API, gRPC: TextGenerationService.Instruct
RPC method for instructing the model to generate text.
gRPC request
rpc Instruct (InstructRequest) returns (stream InstructResponse)
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. |
InstructResponse
{
"alternatives": [
{
"text": "string",
"score": "double",
"numTokens": "int64"
}
],
"numPromptTokens": "int64"
}
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. |