refactor(gateway): avoid extra OpenAI WS body map copy

This commit is contained in:
name 2026-05-30 16:58:58 +08:00
parent 5a3e193b53
commit 09af6ebd40

View File

@ -2793,13 +2793,8 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco
// 命中 WS 时仅走 WebSocket Mode不再自动回退 HTTP。
if wsDecision.Transport == OpenAIUpstreamTransportResponsesWebsocketV2 {
// WS 分支不会再回落 HTTP重连恢复可直接更新 reqBody避免额外保留一份完整顶层 map。
wsReqBody := reqBody
if len(reqBody) > 0 {
wsReqBody = make(map[string]any, len(reqBody))
for k, v := range reqBody {
wsReqBody[k] = v
}
}
_, hasPreviousResponseID := wsReqBody["previous_response_id"]
logOpenAIWSModeDebug(
"forward_start account_id=%d account_type=%s model=%s stream=%v has_previous_response_id=%v",