Files
ai_proxy/server/model/app/response/ai_claude.go

41 lines
1.6 KiB
Go

package response
// ClaudeMessageResponse Claude API 兼容的消息响应
type ClaudeMessageResponse struct {
ID string `json:"id"`
Type string `json:"type"` // message
Role string `json:"role"` // assistant
Content []ClaudeContentBlock `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason,omitempty"` // end_turn, max_tokens, stop_sequence
StopSequence string `json:"stop_sequence,omitempty"`
Usage ClaudeUsage `json:"usage"`
// 统一格式的用量统计(与 OpenAI chat.completions 对齐)
StandardUsage *ChatCompletionUsage `json:"standard_usage,omitempty"`
}
type ClaudeContentBlock struct {
Type string `json:"type"` // text
Text string `json:"text"`
}
type ClaudeUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
// ClaudeStreamResponse Claude 流式响应
type ClaudeStreamResponse struct {
Type string `json:"type"` // message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop
Message *ClaudeMessageResponse `json:"message,omitempty"`
Index int `json:"index,omitempty"`
ContentBlock *ClaudeContentBlock `json:"content_block,omitempty"`
Delta *ClaudeContentBlockDelta `json:"delta,omitempty"`
Usage *ClaudeUsage `json:"usage,omitempty"`
}
type ClaudeContentBlockDelta struct {
Type string `json:"type"` // text_delta
Text string `json:"text"`
}