buildModelChain returns the ordered list of models to try: primary first, then fallbacks.
(primary provider.Provider, fallbacks []provider.Provider)
| 72 | |
| 73 | // buildModelChain returns the ordered list of models to try: primary first, then fallbacks. |
| 74 | func buildModelChain(primary provider.Provider, fallbacks []provider.Provider) []modelWithFallback { |
| 75 | chain := make([]modelWithFallback, 0, 1+len(fallbacks)) |
| 76 | chain = append(chain, modelWithFallback{ |
| 77 | provider: primary, |
| 78 | isFallback: false, |
| 79 | index: -1, |
| 80 | }) |
| 81 | for i, fb := range fallbacks { |
| 82 | chain = append(chain, modelWithFallback{ |
| 83 | provider: fb, |
| 84 | isFallback: true, |
| 85 | index: i, |
| 86 | }) |
| 87 | } |
| 88 | return chain |
| 89 | } |
| 90 | |
| 91 | // logFallbackAttempt logs information about a fallback attempt |
| 92 | func logFallbackAttempt(agentName string, model modelWithFallback, attempt, maxRetries int, err error) { |
no outgoing calls