-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatModel.go
183 lines (158 loc) · 5.59 KB
/
chatModel.go
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package goopenaiclient
import "time"
// ChatRequest ChatRequest
type ChatRequest struct {
Model string `json:"model"`
Messages []ChatMessage `json:"messages"` //system, user, assistant, tool or function message
FrequencyPenalty any `json:"frequency_penalty"` //num or null
LogitBias any `json:"logit_bias"` //map or null
Logprobs any `json:"logprobs"` //boolean or null
TopLogprobs any `json:"top_logprobs"` //integer or null
MaxTokens any `json:"max_tokens"` //integer or null
NumberGenTokens any `json:"n"` //integer or null
PresencePenalty any `json:"presence_penalty"` //number or null
ResponseFormat ChatRespFormat `json:"response_format"`
Seed any `json:"seed"` //integer or null
Stop any `json:"stop"` //string / array / null
Stream any `json:"stream"` //boolean or null
Temperature any `json:"temperature"` //number or null
TopProbability any `json:"top_p"` //number or null
Tools []ChatTool `json:"tools"`
ToolChoice any `json:"tool_choice"` //string or chatTool
User string `json:"user"`
}
// ChatResponse ChatResponse
type ChatResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created time.Time `json:"created"`
Model string `json:"model"`
Choices []ChatChoice `json:"choices"`
Usage ChatUsage `json:"usage"`
SystemFingerprint string `json:"system_fingerprint"`
}
// ChatTool ChatTool
type ChatTool struct {
Type string `json:"type"`
Function ChatFunction `json:"function"`
}
// ChatFunction ChatFunction
type ChatFunction struct {
Name string `json:"name"`
Description any `json:"description"` //string or null
Parameters any `json:"parameters"` //ChatParameters or null
}
// ChatParameters ChatParameters
type ChatParameters struct {
Type string `json:"type"`
Properties ChatProperties `json:"properties"`
Required []string `json:"required"`
}
// ChatProperties ChatProperties
type ChatProperties struct {
Location ChatLocation `json:"location"`
Unit ChatUnit `json:"unit"`
}
// ChatUnit ChatUnit
type ChatUnit struct {
Type string `json:"type"`
Enum []string `json:"enum"`
}
// ChatLocation Location
type ChatLocation struct {
Type string `json:"type"`
Description string `json:"description"`
}
// ChatRespFormat ChatRespFormat
type ChatRespFormat struct {
Type any `json:"type"`
}
// ChatImageURL ChatImageURL
type ChatImageURL struct {
URL string `json:"url"`
Detail string `json:"detail"`
}
// ChatTextContentParts ChatContent
type ChatTextContentParts struct {
Type string `json:"type"`
Text string `json:"text"`
}
// ChatImageContentParts ChatImageContent
type ChatImageContentParts struct {
Type string `json:"type"`
ImageURL ChatImageURL `json:"image_url"`
}
// ChatSystemMessage ChatSystemMessage
// type ChatSystemMessage struct {
// Role string `json:"role"`
// Content string `json:"content"`
// Name string `json:"name"`
// }
// ChatUserMessage ChatUserMessage
// type ChatUserMessage struct {
// Role string `json:"role"`
// Content any `json:"content"` //string or array of parts
// Name string `json:"name"`
// }
// ChatAssistantMessage ChatAssistantMessage
// type ChatAssistantMessage struct {
// Role string `json:"role"`
// Content any `json:"content"` //string or null
// Name string `json:"name"`
// ToolCalls ChatToolCall `json:"tool_calls"`
// }
// ChatFunctionMessage ChatFunctionMessage
// type ChatFunctionMessage struct {
// Role string `json:"role"`
// Content any `json:"content"` //string or null
// Name string `json:"name"`
// }
// ChatToolMessage ChatToolMessage
// type ChatToolMessage struct {
// Role string `json:"role"`
// Content string `json:"content"`
// ToolCallID string `json:"tool_call_id"`
// }
// ChatToolCall ChatToolCall
type ChatToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function ChatToolFunction `json:"function"`
}
// ChatToolFunction ChatToolFunction
type ChatToolFunction struct {
Name string `json:"name"`
Arguments string `json:"arguments"`
}
// ChatMessage Message
type ChatMessage struct {
Role string `json:"role"`
Content any `json:"content"` //string, null or array of ChatTextContentParts, ChatImageContentParts
Name string `json:"name"`
ToolCalls []ChatToolCall `json:"tool_calls"`
ToolCallID string `json:"tool_call_id"`
}
// ChatLogprobContent LogprobContent
type ChatLogprobContent struct {
Token string `json:"token"`
Logprob float64 `json:"logprob"`
Bytes []byte `json:"bytes"`
TopLogprobs []ChatLogprobContent `json:"top_logprobs"`
}
// ChatLogprob Logprob
type ChatLogprob struct {
Content []ChatLogprobContent `json:"content"`
}
// ChatChoice Choice
type ChatChoice struct {
Index int64 `json:"index"`
Message ChatMessage `json:"message"`
Logprobs ChatLogprob `json:"logprobs"`
FinishReason string `json:"finish_reason"`
}
// ChatUsage ChatUsage
type ChatUsage struct {
CompletionTokens int64 `json:"completion_tokens"`
PromptTokens int64 `json:"prompt_tokens"`
TotalTokens int64 `json:"total_tokens"`
}