-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtypes.go
95 lines (78 loc) · 2.52 KB
/
types.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
package mistral
const (
ModelMistralLargeLatest = "mistral-large-latest"
ModelMistralMediumLatest = "mistral-medium-latest"
ModelMistralSmallLatest = "mistral-small-latest"
ModelCodestralLatest = "codestral-latest"
ModelOpenMixtral8x7b = "open-mixtral-8x7b"
ModelOpenMixtral8x22b = "open-mixtral-8x22b"
ModelOpenMistral7b = "open-mistral-7b"
ModelMistralLarge2402 = "mistral-large-2402"
ModelMistralMedium2312 = "mistral-medium-2312"
ModelMistralSmall2402 = "mistral-small-2402"
ModelMistralSmall2312 = "mistral-small-2312"
ModelMistralTiny = "mistral-tiny-2312"
)
const (
RoleUser = "user"
RoleAssistant = "assistant"
RoleSystem = "system"
RoleTool = "tool"
)
// FinishReason the reason that a chat message was finished
type FinishReason string
const (
FinishReasonStop FinishReason = "stop"
FinishReasonLength FinishReason = "length"
FinishReasonError FinishReason = "error"
)
// ResponseFormat the format that the response must adhere to
type ResponseFormat string
const (
ResponseFormatText ResponseFormat = "text"
ResponseFormatJsonObject ResponseFormat = "json_object"
)
// ToolType type of tool defined for the llm
type ToolType string
const (
ToolTypeFunction ToolType = "function"
)
const (
ToolChoiceAny = "any"
ToolChoiceAuto = "auto"
ToolChoiceNone = "none"
)
// Tool definition of a tool that the llm can call
type Tool struct {
Type ToolType `json:"type"`
Function Function `json:"function"`
}
// Function definition of a function that the llm can call including its parameters
type Function struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters any `json:"parameters"`
}
// FunctionCall represents a request to call an external tool by the llm
type FunctionCall struct {
Name string `json:"name"`
Arguments string `json:"arguments"`
}
// ToolCall represents the call to a tool by the llm
type ToolCall struct {
Id string `json:"id"`
Type ToolType `json:"type"`
Function FunctionCall `json:"function"`
}
// DeltaMessage represents the delta between the prior state of the message and the new state of the message when streaming responses.
type DeltaMessage struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls"`
}
// ChatMessage represents a single message in a chat.
type ChatMessage struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}