Documentation
¶
Index ¶
Constants ¶
View Source
const ( VseGptApiKeyEnv = "VSEGPT_API_KEY" // Переменная среды где лежит API ключ VseGptApiHost = "api.vsegpt.ru" // api.vsegpt.ru:6070 VseGptModelsPath = "/v1/models" VseGptChatCompletionPath = "/v1/chat/completions" VseGptEmbeddingsPath = "/v1/embeddings" VseGptEmbeddingModel = "emb-openai/text-embedding-3-small" VseGptModel = "openai/gpt-3.5-turbo" VseGptMaxTokens = 16384 MaxEmbeddingSize = 8192 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []MessageRequest `json:"messages"`
Stream bool `json:"stream"`
RepetitionPenalty float32 `json:"repetition_penalty,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
N int `json:"n,omitempty"`
TopP float32 `json:"top_p,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
UpdateInterval int `json:"update_interval,omitempty"`
}
Исходящий запрос к модели чата.
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
Choices []ChoicesResponse `json:"choices"`
Created int `json:"created"`
Model string `json:"model"`
Usage Usage `json:"usage"`
Object string `json:"object"`
}
Ответ от модели на запрос.
type ChoicesResponse ¶
type ChoicesResponse struct {
Message MessageRequest `json:"message"`
Index int `json:"index"`
FinishReason string `json:"finish_reason"`
}
Варианты.
type EmbeddingsRequest ¶
type EmbeddingsRequest struct {
Input string `json:"input"`
Model string `json:"model"`
EncodingFormat string `json:"encoding_format"` // default float
}
Запрос на векторизацию текста
type EmbeddingsResponse ¶
type EmbeddingsResponse struct {
Object string `json:"object"`
Data []struct {
Object string `json:"object"`
Index int `json:"index"`
Embedding []float64 `json:"embedding"`
} `json:"data"`
Model string `json:"model"`
Usage Usage `json:"usage"`
}
Ответ с векторизацией текста
type MessageRequest ¶
Сообщение в запросе
type MessageResponse ¶
type MessageResponse struct {
Role string `json:"role"`
Content string `json:"content"`
DataForContext []struct{} `json:"data_for_context"`
}
Сообщение в ответе.
type ModelItem ¶
type ModelItem struct {
ID string `json:"id"`
Name string `json:"name"`
ModelPricing `json:"pricing"`
ContextLength string `json:"context_length"`
}
Модель
type ModelPricing ¶
Цена за токен у модели
type ModelsResponse ¶
Формат ответа сервера со списком моделей
type Usage ¶
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
}
Статистика запроса
type VseGpt ¶
type VseGpt struct {
ApiKey string
Model string
MaxTokens int
MaxEmbeddingSize int
EmbeddingModel string
ApiHost string
Temperature float32
N int
RepetitionPenalty float32
}
Основной класс для работы с vsegpt.ru
func (*VseGpt) ChatCompletion ¶
func (v *VseGpt) ChatCompletion(messages []MessageRequest) (string, error)
ChatCompletion Отправить запрос на ответ чата в виде набора сообщений.
func (*VseGpt) Embeddings ¶
Embeddings получить вектора текста
Click to show internal directories.
Click to hide internal directories.