YandexGPT API, gRPC: TextGenerationService
Written by
Updated at December 6, 2023
Service for text generation and conversation.
Call | Description |
---|---|
Instruct | RPC method for instructing the model to generate text. |
Chat | RPC method for engaging in a chat conversation with the model. |
Calls TextGenerationService
Instruct
RPC method for instructing the model to generate text.
rpc Instruct (InstructRequest) returns (stream InstructResponse)
InstructRequest
Field | Description |
---|---|
model | string The name or identifier of the model to be used for text generation. Possible value for now: general . The maximum string length in characters is 50. |
generation_options | GenerationOptions Configuration options for text generation. |
Instruction | oneof: instruction_text or instruction_uri Text precondition or context of the request. For example, if the instruction is "You are the youngest Nobel laureate", the request text might be "Tell us about your daily routine". |
instruction_text | string The text-based instruction for text generation. |
instruction_uri | string A URI containing instructions for text generation. |
Request | oneof: request_text Request for text generation. |
request_text | string The text-based request for text generation. |
GenerationOptions
Field | Description |
---|---|
partial_results | bool Enables streaming of partially generated text. |
temperature | google.protobuf.DoubleValue Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). Lower values produce more straightforward responses, while higher values lead to increased creativity and randomness. |
max_tokens | google.protobuf.Int64Value Sets the maximum limit on the total number of tokens used for both the input prompt and the generated response. Must be greater than zero and not exceed 7400 tokens. |
InstructResponse
Field | Description |
---|---|
alternatives[] | Alternative A list of alternative text responses. |
num_prompt_tokens | int64 The number of tokens used in the prompt, including both the [instruction_text] and [request_text]. |
Alternative
Field | Description |
---|---|
text | string The generated text response. |
score | double The score or confidence of the generated text. |
num_tokens | int64 The number of tokens in the generated response. |
Chat
RPC method for engaging in a chat conversation with the model.
rpc Chat (ChatRequest) returns (stream ChatResponse)
ChatRequest
Field | Description |
---|---|
model | string The name or identifier of the model to be used for the chat. Possible value for now: general . The maximum string length in characters is 50. |
generation_options | GenerationOptions Configuration options for text generation. |
Instruction | oneof: instruction_text Text precondition or context of the request. For example, the instruction may be "You are a helpful assistant". |
instruction_text | string The text-based instruction for the conversation. |
messages[] | Message A list of messages in the conversation. |
GenerationOptions
Field | Description |
---|---|
partial_results | bool Enables streaming of partially generated text. |
temperature | google.protobuf.DoubleValue Affects creativity and randomness of responses. Should be a double number between 0 (inclusive) and 1 (inclusive). Lower values produce more straightforward responses, while higher values lead to increased creativity and randomness. |
max_tokens | google.protobuf.Int64Value Sets the maximum limit on the total number of tokens used for both the input prompt and the generated response. Must be greater than zero and not exceed 7400 tokens. |
Message
Field | Description |
---|---|
role | string Identifies the sender of the message. |
text | string The text content of the message. |
ChatResponse
Field | Description |
---|---|
message | Message The assistant's message in the chat conversation. |
num_tokens | int64 Total number of tokens used in both the chat request and chat response. |