@@ -53,6 +53,7 @@ type ChatCompletionMessage struct {
53
53
Role string `json:"role"`
54
54
Content json.RawMessage `json:"content"`
55
55
Name string `json:"name,omitempty"`
56
+ // MultiContent []VisionContent
56
57
}
57
58
58
59
type FunctionDefinition struct {
@@ -115,17 +116,27 @@ type ChatCompletionResponse struct {
115
116
Message struct {
116
117
Role string `json:"role"`
117
118
Content string `json:"content"`
118
- ToolCalls []ToolCall `json:"tool_calls"`
119
+ ToolCalls []ToolCall `json:"tool_calls,omitempty "`
119
120
} `json:"message"`
120
121
Logprobs string `json:"logprobs"`
121
122
FinishReason string `json:"finish_reason"`
122
123
} `json:"choices"`
123
124
Usage struct {
124
- PromptTokens int `json:"prompt_tokens"`
125
- CompletionTokens int `json:"completion_tokens"`
126
- TotalTokens int `json:"total_tokens"`
127
- } `json:"usage"`
128
- SystemFingerprint string `json:"system_fingerprint"`
125
+ PromptTokens int `json:"prompt_tokens,omitempty"`
126
+ CompletionTokens int `json:"completion_tokens,omitempty"`
127
+ TotalTokens int `json:"total_tokens,omitempty"`
128
+ PromptTokensDetails struct {
129
+ CachedTokens int `json:"cached_tokens,omitempty"`
130
+ AudioTokens int `json:"audio_tokens,omitempty"`
131
+ } `json:"prompt_tokens_details,omitempty"`
132
+ CompletionTokensDetails struct {
133
+ ReasoningTokens int `json:"reasoning_tokens,omitempty"`
134
+ AudioTokens int `json:"audio_tokens,omitempty"`
135
+ AcceptedPredictionTokens int `json:"accepted_prediction_tokens,omitempty"`
136
+ RejectedPredictionTokens int `json:"rejected_prediction_tokens,omitempty"`
137
+ } `json:"completion_tokens_details,omitempty"`
138
+ } `json:"usage,omitempty"`
139
+ SystemFingerprint string `json:"system_fingerprint,omitempty"`
129
140
}
130
141
131
142
type Choice struct {
@@ -304,13 +315,12 @@ func ChatProxy(c *gin.Context, chatReq *ChatCompletionRequest) {
304
315
// 处理非流式响应
305
316
body , err := io .ReadAll (teeReader )
306
317
if err != nil {
307
- c . JSON ( http . StatusInternalServerError , gin. H { "error" : err . Error ()} )
318
+ fmt . Println ( "Error reading response body:" , err )
308
319
return
309
320
}
310
321
var opiResp ChatCompletionResponse
311
322
if err := json .Unmarshal (body , & opiResp ); err != nil {
312
323
log .Println ("Error parsing JSON:" , err )
313
- c .JSON (http .StatusInternalServerError , gin.H {"error" : "Error parsing JSON," + err .Error ()})
314
324
return
315
325
}
316
326
if opiResp .Choices != nil && len (opiResp .Choices ) > 0 {
0 commit comments