mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 12:02:27 +08:00
fix: complete upstream request id handling
This commit is contained in:
@@ -474,6 +474,9 @@ func (s *adminServiceImpl) CreateAccount(ctx context.Context, input *CreateAccou
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := ValidateUpstreamRequestIDHeaderExtra(accountExtra); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 绑定分组
|
||||
groupIDs := input.GroupIDs
|
||||
@@ -571,6 +574,9 @@ func (s *adminServiceImpl) UpdateAccount(ctx context.Context, id int64, input *U
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := ValidateUpstreamRequestIDHeaderExtra(normalizedExtra); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
previousProbeIdentity := upstreamBillingProbeIdentity(account)
|
||||
previousOllamaUsageIdentity := ollamaCloudUsageIdentity(account)
|
||||
|
||||
@@ -150,6 +150,7 @@ func (s *AntigravityGatewayService) ForwardUpstream(ctx context.Context, c *gin.
|
||||
Duration: duration,
|
||||
FirstTokenMs: firstTokenMs,
|
||||
ClientDisconnect: clientDisconnect,
|
||||
UpstreamHeaders: resp.Header,
|
||||
Usage: ClaudeUsage{
|
||||
InputTokens: usage.InputTokens,
|
||||
OutputTokens: usage.OutputTokens,
|
||||
|
||||
@@ -3,6 +3,7 @@ package service
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
infraerrors "github.com/Wei-Shaw/sub2api/internal/pkg/errors"
|
||||
"golang.org/x/net/http/httpguts"
|
||||
@@ -51,6 +52,12 @@ func usageUpstreamRequestIDPtr(account *Account, h http.Header, wsMode bool) *st
|
||||
}
|
||||
if len(id) > maxUsageUpstreamRequestIDLen {
|
||||
id = id[:maxUsageUpstreamRequestIDLen]
|
||||
for len(id) > 0 && !utf8.ValidString(id) {
|
||||
id = id[:len(id)-1]
|
||||
}
|
||||
}
|
||||
if id == "" {
|
||||
return nil
|
||||
}
|
||||
return &id
|
||||
}
|
||||
|
||||
@@ -5120,6 +5120,7 @@ const resetForm = () => {
|
||||
adaptiveBaseUrls.value = { chat_completions: '', anthropic: '', responses: '' }
|
||||
apiKeyBaseUrl.value = 'https://api.anthropic.com'
|
||||
apiKeyValue.value = ''
|
||||
upstreamRequestIdHeader.value = ''
|
||||
upstreamBillingAutoProbeEnabled.value = true
|
||||
editQuotaLimit.value = null
|
||||
editQuotaDailyLimit.value = null
|
||||
|
||||
Reference in New Issue
Block a user