fix(gateway): 修复 Qwen3.8 推理参数并增加上游自愈
统一 Qwen3.8 固定思考、推理档位、预算互斥与温度下限规则,并覆盖 Chat Completions 和原生 Responses 请求。 新增安全参数纠正、有限重试和并发安全的进程内 LRU 学习;补充共享行为向量、httptest 回归与真实模型验收用例。 验证:go test ./... -count=1 通过,gofmt 检查通过;真实 Qwen3.8 流式、非流式及缓存重学习验收通过。
This commit is contained in:
@@ -154,6 +154,7 @@ func NewWithStores(
|
||||
}
|
||||
httpClients := newHTTPClientCache()
|
||||
scriptExecutor := &scriptengine.Executor{Logger: logger}
|
||||
openAIParameterCorrections := clients.NewParameterCorrectionCache()
|
||||
service := &Service{
|
||||
cfg: cfg,
|
||||
store: db,
|
||||
@@ -162,7 +163,7 @@ func NewWithStores(
|
||||
logger: logger,
|
||||
scriptExecutor: scriptExecutor,
|
||||
clients: map[string]clients.Client{
|
||||
"openai": clients.OpenAIClient{HTTPClient: httpClients.none},
|
||||
"openai": clients.OpenAIClient{HTTPClient: httpClients.none, Corrections: openAIParameterCorrections},
|
||||
"aliyun-bailian": clients.AliyunBailianClient{HTTPClient: httpClients.none},
|
||||
"blackforest": clients.BlackforestClient{HTTPClient: httpClients.none},
|
||||
"gemini": clients.GeminiClient{HTTPClient: httpClients.none},
|
||||
@@ -2562,6 +2563,11 @@ func validateRequest(kind string, body map[string]any) error {
|
||||
if body["input"] == nil && body["messages"] == nil {
|
||||
return errors.New("input or messages is required")
|
||||
}
|
||||
if reasoning, ok := body["reasoning"].(map[string]any); ok {
|
||||
if err := clients.ValidateOpenAIReasoningEffort(reasoning["effort"]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if value, explicit := nonNullParameter(body, "max_output_tokens"); explicit {
|
||||
if _, ok := positiveInteger(value); !ok {
|
||||
return &clients.ClientError{Code: "invalid_parameter", Message: "max_output_tokens must be a positive integer", Param: "max_output_tokens", StatusCode: 400, Retryable: false}
|
||||
|
||||
Reference in New Issue
Block a user