Execute performs a non-streaming execution using the configured selector and executor. It supports multiple providers for the same model and round-robins the starting provider per model.
(ctx context.Context, providers []string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options)
| 2269 | // Execute performs a non-streaming execution using the configured selector and executor. |
| 2270 | // It supports multiple providers for the same model and round-robins the starting provider per model. |
| 2271 | func (m *Manager) Execute(ctx context.Context, providers []string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) { |
| 2272 | normalized := m.normalizeProviders(providers) |
| 2273 | if len(normalized) == 0 { |
| 2274 | return cliproxyexecutor.Response{}, &Error{Code: "provider_not_found", Message: "no provider supplied"} |
| 2275 | } |
| 2276 | |
| 2277 | _, maxRetryCredentials, maxWait := m.retrySettings() |
| 2278 | |
| 2279 | var lastErr error |
| 2280 | for attempt := 0; ; attempt++ { |
| 2281 | resp, errExec := m.executeMixedOnce(ctx, normalized, req, opts, maxRetryCredentials) |
| 2282 | if errExec == nil { |
| 2283 | return resp, nil |
| 2284 | } |
| 2285 | lastErr = errExec |
| 2286 | wait, shouldRetry := m.shouldRetryAfterError(errExec, attempt, normalized, req.Model, maxWait) |
| 2287 | if !shouldRetry { |
| 2288 | break |
| 2289 | } |
| 2290 | if errWait := waitForCooldown(ctx, wait); errWait != nil { |
| 2291 | return cliproxyexecutor.Response{}, errWait |
| 2292 | } |
| 2293 | } |
| 2294 | if lastErr != nil { |
| 2295 | if hasAntigravityProvider(normalized) && shouldAttemptAntigravityCreditsFallback(m, lastErr, normalized) { |
| 2296 | if resp, ok, errCredits := m.tryAntigravityCreditsExecute(ctx, req, opts); errCredits != nil { |
| 2297 | return cliproxyexecutor.Response{}, errCredits |
| 2298 | } else if ok { |
| 2299 | return resp, nil |
| 2300 | } |
| 2301 | } |
| 2302 | return cliproxyexecutor.Response{}, lastErr |
| 2303 | } |
| 2304 | return cliproxyexecutor.Response{}, &Error{Code: "auth_not_found", Message: "no auth available"} |
| 2305 | } |
| 2306 | |
| 2307 | // It supports multiple providers for the same model and round-robins the starting provider per model. |
| 2308 | func (m *Manager) ExecuteCount(ctx context.Context, providers []string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (cliproxyexecutor.Response, error) { |