-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdefinitions.go
155 lines (134 loc) · 5.38 KB
/
definitions.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
package openrouterapigo
// Request represents the main request structure.
type Request struct {
Messages []MessageRequest `json:"messages,omitempty"`
Prompt string `json:"prompt,omitempty"`
Model string `json:"model,omitempty"`
ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
Stop []string `json:"stop,omitempty"`
Stream bool `json:"stream,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice ToolChoice `json:"tool_choice,omitempty"`
Seed int `json:"seed,omitempty"`
TopP float64 `json:"top_p,omitempty"`
TopK int `json:"top_k,omitempty"`
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
PresencePenalty float64 `json:"presence_penalty,omitempty"`
RepetitionPenalty float64 `json:"repetition_penalty,omitempty"`
LogitBias map[int]float64 `json:"logit_bias,omitempty"`
TopLogprobs int `json:"top_logprobs,omitempty"`
MinP float64 `json:"min_p,omitempty"`
TopA float64 `json:"top_a,omitempty"`
Prediction *Prediction `json:"prediction,omitempty"`
Transforms []string `json:"transforms,omitempty"`
Models []string `json:"models,omitempty"`
Route string `json:"route,omitempty"`
Provider *ProviderPreferences `json:"provider,omitempty"`
IncludeReasoning bool `json:"include_reasoning,omitempty"`
}
// ResponseFormat represents the response format structure.
type ResponseFormat struct {
Type string `json:"type"`
}
// Prediction represents the prediction structure.
type Prediction struct {
Type string `json:"type"`
Content string `json:"content"`
}
// ProviderPreferences represents the provider preferences structure.
type ProviderPreferences struct {
RefererURL string `json:"referer_url,omitempty"`
SiteName string `json:"site_name,omitempty"`
}
// Message represents the message structure.
type MessageRequest struct {
Role MessageRole `json:"role"`
Content interface{} `json:"content"` // Can be string or []ContentPart
Name string `json:"name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
type MessageRole string
const (
RoleSystem MessageRole = "system"
RoleUser MessageRole = "user"
RoleAssistant MessageRole = "assistant"
)
// ContentPart represents the content part structure.
type ContentPart struct {
Type ContnetType `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *ImageURL `json:"image_url,omitempty"`
}
type ContnetType string
const (
ContentTypeText ContnetType = "text"
ContentTypeImage ContnetType = "image_url"
)
// ImageURL represents the image URL structure.
type ImageURL struct {
URL string `json:"url"`
Detail string `json:"detail,omitempty"`
}
// FunctionDescription represents the function description structure.
type FunctionDescription struct {
Description string `json:"description,omitempty"`
Name string `json:"name"`
Parameters interface{} `json:"parameters"` // JSON Schema object
}
// Tool represents the tool structure.
type Tool struct {
Type string `json:"type"`
Function FunctionDescription `json:"function"`
}
// ToolChoice represents the tool choice structure.
type ToolChoice struct {
Type string `json:"type"`
Function struct {
Name string `json:"name"`
} `json:"function"`
}
type Response struct {
ID string `json:"id"`
Choices []Choice `json:"choices"`
Created int64 `json:"created"`
Model string `json:"model"`
Object string `json:"object"`
SystemFingerprint *string `json:"system_fingerprint,omitempty"`
Usage *ResponseUsage `json:"usage,omitempty"`
}
type ResponseUsage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
}
type Choice struct {
FinishReason string `json:"finish_reason"`
Text string `json:"text,omitempty"`
Message *MessageResponse `json:"message,omitempty"`
Delta *Delta `json:"delta,omitempty"`
Error *ErrorResponse `json:"error,omitempty"`
}
type MessageResponse struct {
Content string `json:"content"`
Role string `json:"role"`
Reasoning string `json:"reasoning,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
type Delta struct {
Content string `json:"content"`
Role string `json:"role,omitempty"`
Reasoning string `json:"reasoning,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
type ErrorResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function interface{} `json:"function"`
}