MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / ExecuteStream

Method ExecuteStream

sdk/cliproxy/auth/conductor.go:2339–2377  ·  view source on GitHub ↗

ExecuteStream performs a 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)

Source from the content-addressed store, hash-verified

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.
2339func (m *Manager) ExecuteStream(ctx context.Context, providers []string, req cliproxyexecutor.Request, opts cliproxyexecutor.Options) (*cliproxyexecutor.StreamResult, error) {
2340 normalized := m.normalizeProviders(providers)
2341 if len(normalized) == 0 {
2342 return nil, &Error{Code: "provider_not_found", Message: "no provider supplied"}
2343 }
2344
2345 _, maxRetryCredentials, maxWait := m.retrySettings()
2346
2347 var lastErr error
2348 for attempt := 0; ; attempt++ {
2349 result, errStream := m.executeStreamMixedOnce(ctx, normalized, req, opts, maxRetryCredentials)
2350 if errStream == nil {
2351 return result, nil
2352 }
2353 lastErr = errStream
2354 wait, shouldRetry := m.shouldRetryAfterError(errStream, attempt, normalized, req.Model, maxWait)
2355 if !shouldRetry {
2356 break
2357 }
2358 if errWait := waitForCooldown(ctx, wait); errWait != nil {
2359 return nil, errWait
2360 }
2361 }
2362 if lastErr != nil {
2363 if hasAntigravityProvider(normalized) && shouldAttemptAntigravityCreditsFallback(m, lastErr, normalized) {
2364 if result, ok, errCredits := m.tryAntigravityCreditsExecuteStream(ctx, req, opts); errCredits != nil {
2365 return nil, errCredits
2366 } else if ok {
2367 return result, nil
2368 }
2369 }
2370 var bootstrapErr *streamBootstrapError
2371 if errors.As(lastErr, &bootstrapErr) && bootstrapErr != nil {
2372 return streamErrorResult(bootstrapErr.Headers(), bootstrapErr.cause), nil
2373 }
2374 return nil, lastErr
2375 }
2376 return nil, &Error{Code: "auth_not_found", Message: "no auth available"}
2377}
2378
2379type requestToFormatResolver interface {
2380 RequestToFormat(req cliproxyexecutor.Request, opts cliproxyexecutor.Options) sdktranslator.Format

Calls 10

normalizeProvidersMethod · 0.95
retrySettingsMethod · 0.95
shouldRetryAfterErrorMethod · 0.95
HeadersMethod · 0.95
waitForCooldownFunction · 0.85
hasAntigravityProviderFunction · 0.85
streamErrorResultFunction · 0.85