-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathchunk.go
55 lines (47 loc) · 1.89 KB
/
chunk.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
package groq
// ChoiceDeltaFunctionCall struct for details of function calls
type ChoiceDeltaFunctionCall struct {
Arguments *string `json:"arguments,omitempty"`
Name *string `json:"name,omitempty"`
}
// ChoiceDeltaToolCallFunction struct for tool call function details
type ChoiceDeltaToolCallFunction struct {
Arguments *string `json:"arguments,omitempty"`
Name *string `json:"name,omitempty"`
}
// ChoiceDeltaToolCall struct for tool call details within deltas
type ChoiceDeltaToolCall struct {
Index int `json:"index"`
ID *string `json:"id,omitempty"`
Function ChoiceDeltaToolCallFunction `json:"function,omitempty"`
Type *string `json:"type,omitempty"`
}
// ChoiceDelta struct for deltas within choices
type ChoiceDelta struct {
Content string `json:"content"`
Role string `json:"role"`
FunctionCall *ChoiceDeltaFunctionCall `json:"functionCall,omitempty"`
ToolCalls []ChoiceDeltaToolCall `json:"toolCalls,omitempty"`
}
// Choice struct for handling choices in completion chunks
type ChoiceChunk struct {
Delta ChoiceDelta `json:"delta"`
FinishReason string `json:"finishReason"`
Index int `json:"index"`
Logprobs ChoiceLogprobs `json:"logprobs"`
}
// XGroq struct for additional external data
type XGroq struct {
Usage Usage `json:"usage"`
}
// ChatCompletion struct to represent the overall completion
type ChatChunkCompletion struct {
ID *string `json:"id"`
Choices []ChoiceChunk `json:"choices"`
Created *int `json:"created"`
Model *string `json:"model"`
Object *string `json:"object"`
SystemFingerprint *string `json:"systemFingerprint"`
XGroq *XGroq `json:"xGroq,omitempty"`
stream chan *ChoiceChunk
}