AvailableModels returns the list of models available for selection. Returns nil if model switching is not supported.
(ctx context.Context)
| 1039 | // AvailableModels returns the list of models available for selection. |
| 1040 | // Returns nil if model switching is not supported. |
| 1041 | func (a *App) AvailableModels(ctx context.Context) []runtime.ModelChoice { |
| 1042 | start := time.Now() |
| 1043 | if !a.runtime.SupportsModelSwitching() { |
| 1044 | slog.DebugContext(ctx, "App available models skipped; model switching unsupported", "duration", time.Since(start)) |
| 1045 | return nil |
| 1046 | } |
| 1047 | |
| 1048 | agentName := a.runtime.CurrentAgentName(ctx) |
| 1049 | currentRef := "" |
| 1050 | var customRefs []string |
| 1051 | if a.session != nil { |
| 1052 | currentRef = a.session.AgentModelOverrides[agentName] |
| 1053 | customRefs = a.session.CustomModelsUsed |
| 1054 | } |
| 1055 | |
| 1056 | runtimeStart := time.Now() |
| 1057 | baseModels := a.runtime.AvailableModels(ctx) |
| 1058 | runtimeDuration := time.Since(runtimeStart) |
| 1059 | decorateStart := time.Now() |
| 1060 | models := runtime.DecorateModelChoices(baseModels, currentRef, customRefs) |
| 1061 | slog.DebugContext(ctx, "App available models completed", |
| 1062 | "duration", time.Since(start), |
| 1063 | "runtime_duration", runtimeDuration, |
| 1064 | "decorate_duration", time.Since(decorateStart), |
| 1065 | "base_models", len(baseModels), |
| 1066 | "models", len(models), |
| 1067 | "custom_refs", len(customRefs), |
| 1068 | "agent", agentName, |
| 1069 | ) |
| 1070 | return models |
| 1071 | } |
| 1072 | |
| 1073 | // trackCustomModel adds a custom model to the session's history if not already present. |
| 1074 | func (a *App) trackCustomModel(modelRef string) { |
nothing calls this directly
no test coverage detected