wzxwhxcz commited on
Commit
9dd7f51
·
verified ·
1 Parent(s): 3516e13

Create model/openai.go

Browse files
Files changed (1) hide show
  1. internal/model/openai.go +53 -0
internal/model/openai.go ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package model
2
+
3
+ // OpenAI compatible request/response structures
4
+
5
+ type ChatCompletionRequest struct {
6
+ Model string `json:"model"`
7
+ Messages []ChatMessage `json:"messages"`
8
+ MaxTokens int `json:"max_tokens,omitempty"`
9
+ Temperature float64 `json:"temperature,omitempty"`
10
+ TopP float64 `json:"top_p,omitempty"`
11
+ Stream bool `json:"stream,omitempty"`
12
+ Stop []string `json:"stop,omitempty"`
13
+ }
14
+
15
+ type ChatMessage struct {
16
+ Role string `json:"role"`
17
+ Content string `json:"content"`
18
+ }
19
+
20
+ type ChatCompletionResponse struct {
21
+ ID string `json:"id"`
22
+ Object string `json:"object"`
23
+ Created int64 `json:"created"`
24
+ Model string `json:"model"`
25
+ Choices []Choice `json:"choices"`
26
+ Usage Usage `json:"usage"`
27
+ }
28
+
29
+ type Choice struct {
30
+ Index int `json:"index"`
31
+ Message ChatMessage `json:"message"`
32
+ FinishReason string `json:"finish_reason"`
33
+ }
34
+
35
+ type Usage struct {
36
+ PromptTokens int `json:"prompt_tokens"`
37
+ CompletionTokens int `json:"completion_tokens"`
38
+ TotalTokens int `json:"total_tokens"`
39
+ }
40
+
41
+ type StreamChoice struct {
42
+ Index int `json:"index"`
43
+ Delta ChatMessage `json:"delta"`
44
+ FinishReason *string `json:"finish_reason"`
45
+ }
46
+
47
+ type ChatCompletionChunk struct {
48
+ ID string `json:"id"`
49
+ Object string `json:"object"`
50
+ Created int64 `json:"created"`
51
+ Model string `json:"model"`
52
+ Choices []StreamChoice `json:"choices"`
53
+ }