Spaces:
Paused
Paused
fix: 修复模型不存在时的返回值,添加错误处理逻辑
Browse files
main.go
CHANGED
@@ -348,7 +348,7 @@ func getEndpointID(openaiModel string) string {
|
|
348 |
if endpoint, exists := modelMap[model]; exists {
|
349 |
return endpoint
|
350 |
}
|
351 |
-
return
|
352 |
}
|
353 |
|
354 |
// 创建会话
|
@@ -456,6 +456,17 @@ func chatCompletions(c *gin.Context) {
|
|
456 |
}
|
457 |
|
458 |
endpointID := getEndpointID(req.Model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
|
460 |
// 添加模型和端点的日志记录
|
461 |
log.Printf("【模型请求】模型: %s, 端点: %s, 流式: %t", req.Model, endpointID, req.Stream)
|
|
|
348 |
if endpoint, exists := modelMap[model]; exists {
|
349 |
return endpoint
|
350 |
}
|
351 |
+
return ""
|
352 |
}
|
353 |
|
354 |
// 创建会话
|
|
|
456 |
}
|
457 |
|
458 |
endpointID := getEndpointID(req.Model)
|
459 |
+
if endpointID == "" {
|
460 |
+
c.JSON(http.StatusBadRequest, gin.H{
|
461 |
+
"error": map[string]interface{}{
|
462 |
+
"message": fmt.Sprintf("The model '%s' does not exist", req.Model),
|
463 |
+
"type": "invalid_request_error",
|
464 |
+
"param": "model",
|
465 |
+
"code": "model_not_found",
|
466 |
+
},
|
467 |
+
})
|
468 |
+
return
|
469 |
+
}
|
470 |
|
471 |
// 添加模型和端点的日志记录
|
472 |
log.Printf("【模型请求】模型: %s, 端点: %s, 流式: %t", req.Model, endpointID, req.Stream)
|