🎨 优化模型配置 && 新增apikey功能 && 完善通用接口

This commit is contained in:
2026-03-03 17:13:24 +08:00
parent 2714e63d2a
commit 7dae1a6e2b
46 changed files with 3063 additions and 278 deletions

View File

@@ -0,0 +1,38 @@
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"`
}
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"`
}

View File

@@ -0,0 +1,15 @@
package response
// ModelListResponse OpenAI 兼容的模型列表响应
type ModelListResponse struct {
Object string `json:"object"` // "list"
Data []ModelInfo `json:"data"`
}
// ModelInfo 模型信息
type ModelInfo struct {
ID string `json:"id"`
Object string `json:"object"` // "model"
Created int64 `json:"created"`
OwnedBy string `json:"owned_by"`
}