(ctx context.Context, cfg *latest.Config, name string, selectors map[string]bool, modelsGateway string, env environment.Provider)
| 48 | } |
| 49 | |
| 50 | func resolveFirstAvailableModel(ctx context.Context, cfg *latest.Config, name string, selectors map[string]bool, modelsGateway string, env environment.Provider) error { |
| 51 | m := cfg.Models[name] |
| 52 | chosen, ref, err := selectFirstAvailable(ctx, cfg, m.FirstAvailable, selectors, modelsGateway, env) |
| 53 | if err != nil { |
| 54 | var missingErr *firstAvailableMissingEnvError |
| 55 | if errors.As(err, &missingErr) { |
| 56 | return missingErr |
| 57 | } |
| 58 | return fmt.Errorf("model '%s': %w", name, err) |
| 59 | } |
| 60 | |
| 61 | slog.DebugContext(ctx, "Resolved first_available model", |
| 62 | "model_name", name, "selected", ref, "provider", chosen.Provider, "model", chosen.Model) |
| 63 | cfg.Models[name] = chosen |
| 64 | return nil |
| 65 | } |
| 66 | |
| 67 | func reachableFirstAvailableModels(cfg *latest.Config, selectors map[string]bool) map[string]bool { |
| 68 | reachable := map[string]bool{} |
no test coverage detected