Documentation
¶
Overview ¶
Package dmrmodels handles Docker Model Runner endpoint discovery and model listing. It is deliberately free of the OpenAI SDK (and any other model client dependency) so that pkg/runtime — which only needs DMR model discovery — does not link the full DMR provider client into embedders' binaries. The full client lives in the parent dmr package.
Index ¶
- Variables
- func DockerModelEndpointAndEngine(ctx context.Context) (endpoint, engine string, err error)
- func IsNotInstalledError(err error) bool
- func ListModels(ctx context.Context) ([]string, error)
- func ListModelsAt(ctx context.Context, httpClient *http.Client, baseURL string) ([]string, error)
- func ResolveBaseURL(ctx context.Context, cfg *latest.ModelConfig, endpoint string) (string, *http.Client)
Constants ¶
This section is empty.
Variables ¶
var ErrNotInstalled = errors.New("docker model runner is not available\nplease install it and try again (https://docs.docker.com/ai/model-runner/get-started/)")
ErrNotInstalled is returned when Docker Model Runner is not installed.
Functions ¶
func DockerModelEndpointAndEngine ¶
DockerModelEndpointAndEngine shells out to `docker model status --json` and returns the resolved endpoint URL and the active inference engine name.
func IsNotInstalledError ¶
IsNotInstalledError reports whether a `docker model` invocation failed because the Docker installation predates Model Runner (the CLI rejects the --json flag). Matching on content rather than the exact message keeps the detection stable across docker CLI usage-text changes.
func ListModels ¶
ListModels returns the IDs of the models available to Docker Model Runner (i.e. pulled locally), as reported by its OpenAI-compatible /models endpoint. IDs keep their full DMR form, e.g. "ai/qwen3:latest". The result is sorted for deterministic ordering.
It returns ErrNotInstalled when Docker Model Runner is not installed, and a wrapped error when the endpoint is unreachable or returns an unparseable body. A nil error with an empty slice means DMR is reachable but has no models pulled.
func ListModelsAt ¶
ListModelsAt fetches and parses the OpenAI-compatible /models response from the given DMR base URL. It is split out from ListModels so the HTTP handling can be unit-tested with an httptest server.
func ResolveBaseURL ¶
func ResolveBaseURL(ctx context.Context, cfg *latest.ModelConfig, endpoint string) (string, *http.Client)
ResolveBaseURL determines the correct base URL to talk to Docker Model Runner, mirroring the behavior of the `docker model` CLI as closely as possible.
High‑level rules:
- If the user explicitly configured a BaseURL or MODEL_RUNNER_HOST, use that (no fallbacks).
- For Desktop endpoints (model-runner.docker.internal) on the host, route through the Docker Engine experimental endpoints prefix over the Unix socket.
- For standalone / offload endpoints like http://172.17.0.1:12435/engines/v1/, use localhost:<port>/engines/v1/ on the host, and the gateway IP:port inside containers.
- Keep a small compatibility workaround for the legacy http://:0/engines/v1/ endpoint.
- Test connectivity and try fallback URLs if the primary endpoint is unreachable.
It also returns an *http.Client when a custom transport (e.g., Docker Unix socket) is needed.
Types ¶
This section is empty.