-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructures.go
More file actions
89 lines (78 loc) · 2.76 KB
/
structures.go
File metadata and controls
89 lines (78 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package vsegpt
// Цена за токен у модели
type ModelPricing struct {
Prompt string `json:"prompt"`
Completion string `json:"completion"`
}
// Модель
type ModelItem struct {
ID string `json:"id"`
Name string `json:"name"`
ModelPricing `json:"pricing"`
ContextLength string `json:"context_length"`
}
// Формат ответа сервера со списком моделей
type ModelsResponse struct {
Object string `json:"object"`
Data []ModelItem `json:"data"`
}
// Сообщение в запросе
type MessageRequest struct {
Role string `json:"role"`
Content string `json:"content"`
}
// Статистика запроса
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
}
// Сообщение в ответе.
type MessageResponse struct {
Role string `json:"role"`
Content string `json:"content"`
DataForContext []struct{} `json:"data_for_context"`
}
// Варианты.
type ChoicesResponse struct {
Message MessageRequest `json:"message"`
Index int `json:"index"`
FinishReason string `json:"finish_reason"`
}
// Исходящий запрос к модели чата.
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 struct {
Choices []ChoicesResponse `json:"choices"`
Created int `json:"created"`
Model string `json:"model"`
Usage Usage `json:"usage"`
Object string `json:"object"`
}
// Запрос на векторизацию текста
type EmbeddingsRequest struct {
Input string `json:"input"`
Model string `json:"model"`
EncodingFormat string `json:"encoding_format"` // default float
}
// Ответ с векторизацией текста
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"`
}