Skip to content
Artem Gafarov edited this page Sep 18, 2024 · 4 revisions

Models

Neorun Nexus Yandex GPT uses the following structures to generate requests and responses as JSON.

Request

type Message struct {
	Role   string `json:"role"`
	Text   string `json:"text"`
}

type Request struct {
	ModelUri          string `json:"modelUri"`
	CompletionOptions struct {
		Stream      bool    `json:"stream"`
		Temperature float64 `json:"temperature"`
		MaxTokens   int64   `json:"maxTokens"`
	} `json:"completionOptions"`
	Messages []Message `json:"messages"`
}

Response

type Message struct {
	Role   string `json:"role"`
	Text   string `json:"text"`
	Tokens int64  `json:"-"`
}

type Alternative struct {
	Message Message `json:"message"`
	Status  string  `json:"status"`
}

type Response struct {
	Result struct {
		Alternatives []Alternative `json:"alternatives"`
		Usage        struct {
			InputTextTokens  int64 `json:"input_text_tokens"`
			CompletionTokens int64 `json:"completionTokens"`
			TotalTokens      int64 `json:"totalTokens"`
		} `json:"usage"`
		ModelVersion string `json:"modelVersion"`
	} `json:"result"`
}

Use the following code to retrieve the text from the response:

Response.Result.Alternatives[0].Message.Text

Yandex GPT ensures that if the execution of the SendRequest() function completes without an error, the response will contain some text. You can also use the GetLastText() function of the model instance. It will return a string of text or an error if the SendRequest() function execution failed or the function was not executed.

Clone this wiki locally