Documentation
¶
Index ¶
- func FileIdFromMessageContent(content string) (string, error)
- func FilesFileId(ctx context.Context, accessToken string, fileId string) ([]byte, error)
- func TokensCount(ctx context.Context, accessToken string, tokensCountIn *TokensCountIn) (*[]TokensCountOut, error)
- type ChatCompletionsIn
- type ChatCompletionsOut
- type Choice
- type Embedding
- type EmbeddingsIn
- type EmbeddingsOut
- type FewShotExample
- type Function
- type Message
- type Model
- type ModelsOut
- type TokensCountIn
- type TokensCountOut
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileIdFromMessageContent ¶ added in v0.5.0
FileIdFromMessageContent выделяет FileId из строки Message.Content.
func FilesFileId ¶ added in v0.5.0
FilesFileId возвращает файл изображения в бинарном представлении в формате JPG.
func TokensCount ¶
func TokensCount(ctx context.Context, accessToken string, tokensCountIn *TokensCountIn) (*[]TokensCountOut, error)
TokensCount возвращает объект с информацией о количестве токенов, посчитанных заданной моделью в строках, переданных в массиве input.
Types ¶
type ChatCompletionsIn ¶
type ChatCompletionsIn struct {
// https://developers.sber.ru/docs/ru/gigachat/api/selecting-a-model
Model string `json:"model"`
// https://developers.sber.ru/docs/ru/gigachat/api/keeping-context
// https://developers.sber.ru/docs/ru/gigachat/api/images-generation
Messages []Message `json:"messages"`
// https://developers.sber.ru/docs/ru/gigachat/api/function-calling
FunctionCall any `json:"function_call"`
Functions []Function `json:"functions"`
Temperature float64 `json:"temperature,omitempty"`
TopP float64 `json:"top_p,omitempty"`
N int64 `json:"n,omitempty"`
// https://developers.sber.ru/docs/ru/gigachat/api/response-token-streaming
Stream bool `json:"stream,omitempty"`
MaxTokens int64 `json:"max_tokens,omitempty"`
RepetitionPenalty float64 `json:"repetition_penalty,omitempty"`
UpdateInterval float64 `json:"update_interval,omitempty"`
}
Input chat/completions object.
type ChatCompletionsOut ¶
type ChatCompletionsOut struct {
// https://developers.sber.ru/docs/ru/gigachat/api/reference/rest/post-chat#responses
Choices []Choice `json:"choices"`
Created timehelper.UnixSec `json:"created"`
Model string `json:"model"`
Usage Usage `json:"usage"`
Object string `json:"object"`
}
Output chat/completions object.
func ChatCompletions ¶
func ChatCompletions(ctx context.Context, accessToken string, chatCompletionsIn *ChatCompletionsIn) (*ChatCompletionsOut, error)
ChatCompletions возвращает ответ модели с учётом переданных сообщений.
type Choice ¶
type Choice struct {
Message Message `json:"message"`
Index int32 `json:"index"`
FinishReason string `json:"finish_reason"`
}
Choice.
type Embedding ¶ added in v0.5.0
type Embedding struct {
Object string `json:"object"`
Embedding []float64 `json:"embedding"`
Index int64 `json:"index"`
}
Embedding
type EmbeddingsIn ¶ added in v0.5.0
type EmbeddingsIn struct {
// https://developers.sber.ru/docs/ru/gigachat/api/reference/rest/post-embeddings#zapros
Model string `json:"model"`
Input []string `json:"input"`
}
Input embeddings object.
type EmbeddingsOut ¶ added in v0.5.0
type EmbeddingsOut struct {
// https://developers.sber.ru/docs/ru/gigachat/api/reference/rest/post-embeddings#responses
Object string `json:"object"`
Data []Embedding `json:"data"`
Model string `json:"model"`
}
Output embeddings object.
func Embeddings ¶ added in v0.5.0
func Embeddings(ctx context.Context, accessToken string, embeddingsIn *EmbeddingsIn) (*EmbeddingsOut, error)
Embeddings возвращает векторные представления соответствующих текстовых запросов.
type FewShotExample ¶ added in v0.6.0
FewShotExample.
type Function ¶ added in v0.6.0
type Function struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters any `json:"parameters"`
FewShotExamples []FewShotExample `json:"few_shot_examples,omitempty"`
ReturnParameters any `json:"return_parameters,omitempty"`
}
Function.
type Model ¶
type Model struct {
// https://developers.sber.ru/docs/ru/gigachat/api/reference/rest/get-models#responses
Id string `json:"id"`
Object string `json:"object"`
OwnedBy string `json:"owned_by"`
}
Output model object.
type ModelsOut ¶
type ModelsOut struct {
// https://developers.sber.ru/docs/ru/gigachat/api/reference/rest/get-models#responses
Object string `json:"object"`
Data []Model `json:"data"`
}
Output models object.
type TokensCountIn ¶
type TokensCountIn struct {
// https://developers.sber.ru/docs/ru/gigachat/api/reference/rest/post-tokens-count#zapros
Model string `json:"model"`
Input []string `json:"input"`
}
Input tokens/count object.
type TokensCountOut ¶
type TokensCountOut struct {
// https://developers.sber.ru/docs/ru/gigachat/api/reference/rest/post-tokens-count#responses
Object string `json:"object"`
Tokens int `json:"tokens"`
Characters int `json:"characters"`
}
Output tokens/count object.