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)
| 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) { |
| 2309 | normalized := m.normalizeProviders(providers) |
| 2310 | if len(normalized) == 0 { |
| 2311 | return cliproxyexecutor.Response{}, &Error{Code: "provider_not_found", Message: "no provider supplied"} |
| 2312 | } |
| 2313 | |
| 2314 | _, maxRetryCredentials, maxWait := m.retrySettings() |
| 2315 | |
| 2316 | var lastErr error |
| 2317 | for attempt := 0; ; attempt++ { |
| 2318 | resp, errExec := m.executeCountMixedOnce(ctx, normalized, req, opts, maxRetryCredentials) |
| 2319 | if errExec == nil { |
| 2320 | return resp, nil |
| 2321 | } |
| 2322 | lastErr = errExec |
| 2323 | wait, shouldRetry := m.shouldRetryAfterError(errExec, attempt, normalized, req.Model, maxWait) |
| 2324 | if !shouldRetry { |
| 2325 | break |
| 2326 | } |
| 2327 | if errWait := waitForCooldown(ctx, wait); errWait != nil { |
| 2328 | return cliproxyexecutor.Response{}, errWait |
| 2329 | } |
| 2330 | } |
| 2331 | if lastErr != nil { |
| 2332 | return cliproxyexecutor.Response{}, lastErr |
| 2333 | } |
| 2334 | return cliproxyexecutor.Response{}, &Error{Code: "auth_not_found", Message: "no auth available"} |
| 2335 | } |
| 2336 | |
| 2337 | // ExecuteStream performs a streaming execution using the configured selector and executor. |
| 2338 | // It supports multiple providers for the same model and round-robins the starting provider per model. |