🎨 优化模型配置 && 新增apikey功能 && 完善通用接口
This commit is contained in:
38
server/model/app/response/ai_claude.go
Normal file
38
server/model/app/response/ai_claude.go
Normal 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"`
|
||||
}
|
||||
15
server/model/app/response/ai_models.go
Normal file
15
server/model/app/response/ai_models.go
Normal 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"`
|
||||
}
|
||||
Reference in New Issue
Block a user