37 lines
1.5 KiB
Go
37 lines
1.5 KiB
Go
package request
|
|
|
|
// ClaudeMessageRequest Claude API 兼容的消息请求
|
|
type ClaudeMessageRequest struct {
|
|
Model string `json:"model"`
|
|
Messages []ClaudeMessage `json:"messages"`
|
|
MaxTokens int `json:"max_tokens"`
|
|
Temperature *float64 `json:"temperature,omitempty"`
|
|
TopP *float64 `json:"top_p,omitempty"`
|
|
TopK *int `json:"top_k,omitempty"`
|
|
Stream bool `json:"stream,omitempty"`
|
|
StopSequences []string `json:"stop_sequences,omitempty"`
|
|
System string `json:"system,omitempty"`
|
|
|
|
// 扩展字段 - 用于指定预设和提供商
|
|
PresetName string `json:"preset_name,omitempty"` // 预设名称
|
|
ProviderName string `json:"provider_name,omitempty"` // 提供商名称
|
|
BindingName string `json:"binding_name,omitempty"` // 绑定名称(优先级最高)
|
|
}
|
|
|
|
type ClaudeMessage struct {
|
|
Role string `json:"role"` // user, assistant
|
|
Content interface{} `json:"content"` // string 或 []ClaudeContentBlock
|
|
}
|
|
|
|
type ClaudeContentBlock struct {
|
|
Type string `json:"type"` // text, image
|
|
Text string `json:"text,omitempty"`
|
|
Source *ClaudeImageSource `json:"source,omitempty"`
|
|
}
|
|
|
|
type ClaudeImageSource struct {
|
|
Type string `json:"type"` // base64
|
|
MediaType string `json:"media_type"` // image/jpeg, image/png, image/gif, image/webp
|
|
Data string `json:"data"` // base64 编码的图片数据
|
|
}
|