mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-11-22 15:14:35 +00:00
fix(openai): normalize Responses Lite tool declarations
This commit is contained in:
1 parent
3f605c3543
commit
bc6d9c47d2
7 files changed
+539
-4
No files matched your search
@@ -44,6 +44,19 @@ func (s *OpenAIGatewayService) Forward(ctx context.Context, c *gin.Context, acco
|
||||
if normalized {
|
||||
body = normalizedBody
|
||||
}
|
||||
if account.IsOpenAIOAuth() && isOpenAIResponsesLiteHeader(c.GetHeader(responsesLiteHeader)) {
|
||||
liteBody, changed, liteErr := normalizeOpenAIResponsesLiteToolsPayload(body)
|
||||
if liteErr != nil {
|
||||
setOpsUpstreamError(c, http.StatusBadRequest, liteErr.Error(), "")
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": gin.H{
|
||||
"type": "invalid_request_error", "message": liteErr.Error(), "param": "tools",
|
||||
}})
|
||||
return nil, liteErr
|
||||
}
|
||||
if changed {
|
||||
body = liteBody
|
||||
}
|
||||
}
|
||||
wsDecision := s.getOpenAIWSProtocolResolver().Resolve(account)
|
||||
// 仅允许 WS 入站请求走 WS 上游,避免出现 HTTP -> WS 协议混用。
|
||||
wsDecision = resolveOpenAIWSDecisionByClientTransport(wsDecision, GetOpenAIClientTransport(c))
|
||||
|
||||
Reference in new issue
Block a user