MCPcopy Index your code
hub / github.com/docker/docker-agent / AvailableModels

Method AvailableModels

pkg/app/app.go:1041–1071  ·  view source on GitHub ↗

AvailableModels returns the list of models available for selection. Returns nil if model switching is not supported.

(ctx context.Context)

Source from the content-addressed store, hash-verified

1039// AvailableModels returns the list of models available for selection.
1040// Returns nil if model switching is not supported.
1041func (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.
1074func (a *App) trackCustomModel(modelRef string) {

Callers

nothing calls this directly

Calls 5

DecorateModelChoicesFunction · 0.92
NowMethod · 0.80
CurrentAgentNameMethod · 0.65
AvailableModelsMethod · 0.65

Tested by

no test coverage detected