|
|
@@ -20,7 +20,7 @@ func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, re
|
|
|
// 读取响应体
|
|
|
responseBody, err := io.ReadAll(resp.Body)
|
|
|
if err != nil {
|
|
|
- return nil, types.NewError(err, types.ErrorCodeBadResponseBody)
|
|
|
+ return nil, types.NewOpenAIError(err, types.ErrorCodeBadResponseBody, http.StatusInternalServerError)
|
|
|
}
|
|
|
|
|
|
if common.DebugEnabled {
|
|
|
@@ -31,7 +31,7 @@ func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, re
|
|
|
var geminiResponse GeminiChatResponse
|
|
|
err = common.Unmarshal(responseBody, &geminiResponse)
|
|
|
if err != nil {
|
|
|
- return nil, types.NewError(err, types.ErrorCodeBadResponseBody)
|
|
|
+ return nil, types.NewOpenAIError(err, types.ErrorCodeBadResponseBody, http.StatusInternalServerError)
|
|
|
}
|
|
|
|
|
|
// 计算使用量(基于 UsageMetadata)
|
|
|
@@ -54,7 +54,7 @@ func GeminiTextGenerationHandler(c *gin.Context, info *relaycommon.RelayInfo, re
|
|
|
// 直接返回 Gemini 原生格式的 JSON 响应
|
|
|
jsonResponse, err := common.Marshal(geminiResponse)
|
|
|
if err != nil {
|
|
|
- return nil, types.NewError(err, types.ErrorCodeBadResponseBody)
|
|
|
+ return nil, types.NewOpenAIError(err, types.ErrorCodeBadResponseBody, http.StatusInternalServerError)
|
|
|
}
|
|
|
|
|
|
common.IOCopyBytesGracefully(c, resp, jsonResponse)
|