feat(antigravity): comprehensive enhancements - model mapping, rate limiting, scheduling & ops
Key changes: - Upgrade model mapping: Opus 4.5 → Opus 4.6-thinking with precise matching - Unified rate limiting: scope-level → model-level with Redis snapshot sync - Load-balanced scheduling by call count with smart retry mechanism - Force cache billing support - Model identity injection in prompts with leak prevention - Thinking mode auto-handling (max_tokens/budget_tokens fix) - Frontend: whitelist mode toggle, model mapping validation, status indicators - Gemini session fallback with Redis Trie O(L) matching - Ops: enhanced concurrency monitoring, account availability, retry logic - Migration scripts: 049-051 for model mapping unification
This commit is contained in:
@@ -27,6 +27,7 @@ type OpsService struct {
|
||||
cfg *config.Config
|
||||
|
||||
accountRepo AccountRepository
|
||||
userRepo UserRepository
|
||||
|
||||
// getAccountAvailability is a unit-test hook for overriding account availability lookup.
|
||||
getAccountAvailability func(ctx context.Context, platformFilter string, groupIDFilter *int64) (*OpsAccountAvailability, error)
|
||||
@@ -43,6 +44,7 @@ func NewOpsService(
|
||||
settingRepo SettingRepository,
|
||||
cfg *config.Config,
|
||||
accountRepo AccountRepository,
|
||||
userRepo UserRepository,
|
||||
concurrencyService *ConcurrencyService,
|
||||
gatewayService *GatewayService,
|
||||
openAIGatewayService *OpenAIGatewayService,
|
||||
@@ -55,6 +57,7 @@ func NewOpsService(
|
||||
cfg: cfg,
|
||||
|
||||
accountRepo: accountRepo,
|
||||
userRepo: userRepo,
|
||||
|
||||
concurrencyService: concurrencyService,
|
||||
gatewayService: gatewayService,
|
||||
@@ -424,13 +427,23 @@ func isSensitiveKey(key string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Whitelist: known non-sensitive fields that contain sensitive substrings
|
||||
// (e.g., "max_tokens" contains "token" but is just an API parameter).
|
||||
// Token 计数 / 预算字段不是凭据,应保留用于排错。
|
||||
// 白名单保持尽量窄,避免误把真实敏感信息"反脱敏"。
|
||||
switch k {
|
||||
case "max_tokens", "max_completion_tokens", "max_output_tokens",
|
||||
"completion_tokens", "prompt_tokens", "total_tokens",
|
||||
"input_tokens", "output_tokens",
|
||||
"cache_creation_input_tokens", "cache_read_input_tokens":
|
||||
case "max_tokens",
|
||||
"max_output_tokens",
|
||||
"max_input_tokens",
|
||||
"max_completion_tokens",
|
||||
"max_tokens_to_sample",
|
||||
"budget_tokens",
|
||||
"prompt_tokens",
|
||||
"completion_tokens",
|
||||
"input_tokens",
|
||||
"output_tokens",
|
||||
"total_tokens",
|
||||
"token_count",
|
||||
"cache_creation_input_tokens",
|
||||
"cache_read_input_tokens":
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -576,7 +589,18 @@ func trimArrayField(root map[string]any, field string, maxBytes int) (map[string
|
||||
|
||||
func shrinkToEssentials(root map[string]any) map[string]any {
|
||||
out := make(map[string]any)
|
||||
for _, key := range []string{"model", "stream", "max_tokens", "temperature", "top_p", "top_k"} {
|
||||
for _, key := range []string{
|
||||
"model",
|
||||
"stream",
|
||||
"max_tokens",
|
||||
"max_output_tokens",
|
||||
"max_input_tokens",
|
||||
"max_completion_tokens",
|
||||
"thinking",
|
||||
"temperature",
|
||||
"top_p",
|
||||
"top_k",
|
||||
} {
|
||||
if v, ok := root[key]; ok {
|
||||
out[key] = v
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user