fix(openai): strip unsupported passthrough fields
This commit is contained in:
@@ -5454,7 +5454,8 @@ func extractOpenAIRequestMetaFromBody(body []byte) (model string, stream bool, p
|
||||
}
|
||||
|
||||
// normalizeOpenAIPassthroughOAuthBody 将透传 OAuth 请求体收敛为旧链路关键行为:
|
||||
// 1) store=false 2) 非 compact 保持 stream=true;compact 强制 stream=false
|
||||
// 1) 删除 ChatGPT internal API 不支持的顶层 Responses 参数
|
||||
// 2) store=false 3) 非 compact 保持 stream=true;compact 强制 stream=false
|
||||
func normalizeOpenAIPassthroughOAuthBody(body []byte, compact bool) ([]byte, bool, error) {
|
||||
if len(body) == 0 {
|
||||
return body, false, nil
|
||||
@@ -5463,6 +5464,18 @@ func normalizeOpenAIPassthroughOAuthBody(body []byte, compact bool) ([]byte, boo
|
||||
normalized := body
|
||||
changed := false
|
||||
|
||||
for _, field := range openAIChatGPTInternalUnsupportedFields {
|
||||
if value := gjson.GetBytes(normalized, field); !value.Exists() {
|
||||
continue
|
||||
}
|
||||
next, err := sjson.DeleteBytes(normalized, field)
|
||||
if err != nil {
|
||||
return body, false, fmt.Errorf("normalize passthrough body delete %s: %w", field, err)
|
||||
}
|
||||
normalized = next
|
||||
changed = true
|
||||
}
|
||||
|
||||
if compact {
|
||||
if store := gjson.GetBytes(normalized, "store"); store.Exists() {
|
||||
next, err := sjson.DeleteBytes(normalized, "store")
|
||||
|
||||
Reference in New Issue
Block a user