chore: 更新 .gitignore 并删除旧计划文档
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
||||
|
||||
"model-gateway/model/dto"
|
||||
"model-gateway/model/entity"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// parseAnalysisResponse 解析分析模型输出的判定 JSON。
|
||||
@@ -71,8 +73,11 @@ func truncateStr(s string, max int) string {
|
||||
}
|
||||
|
||||
// buildAnalysisBody 构造分析请求体(OpenAI 兼容 messages 格式),纯函数便于单测。
|
||||
func buildAnalysisBody(modelName, code, msg, body string) map[string]any {
|
||||
func buildAnalysisBody(ctx context.Context, modelName, code, msg, body string) map[string]any {
|
||||
user := fmt.Sprintf("错误码: %s\n错误消息: %s\n错误响应体: %s", code, msg, truncateStr(body, analysisMaxBody))
|
||||
// 打印错误信息
|
||||
g.Log().Debugf(ctx, "分析请求体: %s", user)
|
||||
|
||||
return map[string]any{
|
||||
"model": modelName,
|
||||
"messages": []map[string]string{
|
||||
@@ -100,7 +105,7 @@ func resolveAnalysisModel(ctx context.Context, modelInfo *entity.ModelManage) (m
|
||||
// callAnalysisLLM 调分析模型(对话模型)判定错误是否可重试。
|
||||
// 独立短超时 http.Client;非 200 / 解析失败 / 超时 → 返回 err,调用方 fail-closed。
|
||||
func callAnalysisLLM(ctx context.Context, model *entity.ModelManage, code, msg, body string) (retryable bool, reason string, err error) {
|
||||
reqBody, err := json.Marshal(buildAnalysisBody(model.ModelName, code, msg, body))
|
||||
reqBody, err := json.Marshal(buildAnalysisBody(ctx, model.ModelName, code, msg, body))
|
||||
if err != nil {
|
||||
return false, "", fmt.Errorf("marshal分析请求失败: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user