mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 16:07:33 +00:00
perf(openai): use the validated parse path for chat completions too
Same shape as the responses handler: the body is validated at the top of ChatCompletions, the only later rewrite is applyOpenAIReasoningEffortPolicyForRequest (sjson), and the parse error was already being ignored. Nothing between the two points mutates the bytes: parseOpenAICompatibleStream, checkSecurityAudit and tokenInflightEstimate only read them.
This commit is contained in:
1 parent
844459e785
commit
8d962ba494
1 file changed
+3
-1
@@ -174,8 +174,10 @@ func (h *GatewayHandler) ChatCompletions(c *gin.Context) {
|
||||
defer inflightRelease()
|
||||
|
||||
// Parse request for session hash
|
||||
// body 已在本函数开头用 gjson.ValidBytes 校验过,之后只经过 sjson 改写
|
||||
// (applyOpenAIReasoningEffortPolicyForRequest),合法性保持,因此跳过重复校验。
|
||||
bodyRef := service.NewRequestBodyRef(body)
|
||||
parsedReq, _ := service.ParseGatewayRequest(bodyRef, "chat_completions")
|
||||
parsedReq, _ := service.ParseGatewayRequestValidated(bodyRef, "chat_completions")
|
||||
if parsedReq == nil {
|
||||
parsedReq = &service.ParsedRequest{Model: reqModel, Stream: reqStream, Body: bodyRef}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user