mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-06-04 08:27:01 +08:00
fix(antigravity): remove credits fallback from CountTokens, fix gofmt
CountTokens upstream API does not support enabledCreditTypes, so remove the dead credits fallback path from ExecuteCount and delete the unused tryAntigravityCreditsExecuteCount method. Fix gofmt on credits test file.
This commit is contained in:
@@ -127,7 +127,6 @@ func TestAntigravityShouldRetryNoCapacity_Standard503(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestInjectEnabledCreditTypes(t *testing.T) {
|
||||
body := []byte(`{"model":"claude-sonnet-4-6","request":{}}`)
|
||||
got := injectEnabledCreditTypes(body)
|
||||
@@ -158,7 +157,6 @@ func TestParseRetryDelay_HumanReadableDuration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestAntigravityExecute_RetriesTransient429ResourceExhausted(t *testing.T) {
|
||||
resetAntigravityCreditsRetryState()
|
||||
t.Cleanup(resetAntigravityCreditsRetryState)
|
||||
|
||||
@@ -1237,11 +1237,6 @@ func (m *Manager) ExecuteCount(ctx context.Context, providers []string, req clip
|
||||
}
|
||||
}
|
||||
if lastErr != nil {
|
||||
if shouldAttemptAntigravityCreditsFallback(m, lastErr, normalized) {
|
||||
if resp, ok := m.tryAntigravityCreditsExecuteCount(ctx, req, opts); ok {
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
return cliproxyexecutor.Response{}, lastErr
|
||||
}
|
||||
return cliproxyexecutor.Response{}, &Error{Code: "auth_not_found", Message: "no auth available"}
|
||||
@@ -3026,48 +3021,6 @@ func (m *Manager) tryAntigravityCreditsExecute(ctx context.Context, req cliproxy
|
||||
return cliproxyexecutor.Response{}, false
|
||||
}
|
||||
|
||||
func (m *Manager) tryAntigravityCreditsExecuteCount(ctx context.Context, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, bool) {
|
||||
routeModel := req.Model
|
||||
candidates := m.findAllAntigravityCreditsCandidateAuths(routeModel)
|
||||
for _, c := range candidates {
|
||||
if ctx.Err() != nil {
|
||||
return cliproxyexecutor.Response{}, false
|
||||
}
|
||||
creditsCtx := WithAntigravityCredits(ctx)
|
||||
if rt := m.roundTripperFor(c.auth); rt != nil {
|
||||
creditsCtx = context.WithValue(creditsCtx, roundTripperContextKey{}, rt)
|
||||
creditsCtx = context.WithValue(creditsCtx, "cliproxy.roundtripper", rt)
|
||||
}
|
||||
creditsOpts := ensureRequestedModelMetadata(opts, routeModel)
|
||||
publishSelectedAuthMetadata(creditsOpts.Metadata, c.auth.ID)
|
||||
models := m.executionModelCandidates(c.auth, routeModel)
|
||||
if len(models) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, upstreamModel := range models {
|
||||
resultModel := m.stateModelForExecution(c.auth, routeModel, upstreamModel, len(models) > 1)
|
||||
execReq := req
|
||||
execReq.Model = upstreamModel
|
||||
resp, errExec := c.executor.CountTokens(creditsCtx, c.auth, execReq, creditsOpts)
|
||||
result := Result{AuthID: c.auth.ID, Provider: c.provider, Model: resultModel, Success: errExec == nil}
|
||||
if errExec != nil {
|
||||
result.Error = &Error{Message: errExec.Error()}
|
||||
if se, ok := errors.AsType[cliproxyexecutor.StatusError](errExec); ok && se != nil {
|
||||
result.Error.HTTPStatus = se.StatusCode()
|
||||
}
|
||||
if ra := retryAfterFromError(errExec); ra != nil {
|
||||
result.RetryAfter = ra
|
||||
}
|
||||
m.MarkResult(creditsCtx, result)
|
||||
continue
|
||||
}
|
||||
m.MarkResult(creditsCtx, result)
|
||||
return resp, true
|
||||
}
|
||||
}
|
||||
return cliproxyexecutor.Response{}, false
|
||||
}
|
||||
|
||||
func (m *Manager) tryAntigravityCreditsExecuteStream(ctx context.Context, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (*cliproxyexecutor.StreamResult, bool) {
|
||||
routeModel := req.Model
|
||||
candidates := m.findAllAntigravityCreditsCandidateAuths(routeModel)
|
||||
|
||||
Reference in New Issue
Block a user