Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertParametersToSchema(params any) (any, error)
- func ListModels(ctx context.Context) ([]string, error)
- func Pull(ctx context.Context, model string) error
- func UnloadURL(baseURL, unloadAPI string) (string, error)
- type Client
- func (c *Client) CreateBatchEmbedding(ctx context.Context, texts []string) (*base.BatchEmbeddingResult, error)
- func (c *Client) CreateChatCompletionStream(ctx context.Context, messages []chat.Message, requestTools []tools.Tool) (chat.MessageStream, error)
- func (c *Client) CreateEmbedding(ctx context.Context, text string) (*base.EmbeddingResult, error)
- func (c *Client) Rerank(ctx context.Context, query string, documents []types.Document, criteria string) ([]float64, error)
- type ModelNotAvailableError
- type PullFailedError
Constants ¶
const ProviderType = "dmr"
ProviderType is the canonical latest.ModelConfig.Provider value for Docker Model Runner. Exported so callers outside the package (e.g. the `unload` hook builtin) can dispatch on provider type without hard-coding the literal.
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 ConvertParametersToSchema ¶
ConvertParametersToSchema converts parameters to DMR Schema format
func ListModels ¶ added in v1.86.0
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 Pull ¶ added in v1.101.0
Pull pulls a Docker Model Runner model via `docker model pull`, streaming progress to the terminal. Unlike the run-path pull it never asks for confirmation, so callers that already obtained consent (e.g. the setup wizard) can invoke it directly. It skips the pull when the model is already available locally and returns a *PullFailedError on failure.
func UnloadURL ¶ added in v1.58.0
UnloadURL resolves the URL of the per-model unload endpoint for a DMR-served model, given the resolved provider base URL and the per-model `unload_api` override (both as they appear on [hooks.ModelEndpoint]).
Resolution order:
- unloadAPI is an absolute URL — used verbatim (lets users point at a different host than baseURL);
- unloadAPI is set but relative — rebased onto baseURL's scheme + host (the model's path is dropped);
- unloadAPI is unset — the default `_unload` URL is derived from baseURL by replacing its trailing `/v1` segment, mirroring the `/v1` → `/_configure` convention the configure path uses.
Returns ("", nil) when neither baseURL nor unloadAPI is set, so the caller can skip without erroring (in-process / test providers).
Types ¶
type Client ¶
Client represents an DMR client wrapper It implements the provider.Provider interface
func (*Client) CreateBatchEmbedding ¶
func (c *Client) CreateBatchEmbedding(ctx context.Context, texts []string) (*base.BatchEmbeddingResult, error)
CreateBatchEmbedding generates embedding vectors for multiple texts with usage tracking.
func (*Client) CreateChatCompletionStream ¶
func (c *Client) CreateChatCompletionStream(ctx context.Context, messages []chat.Message, requestTools []tools.Tool) (chat.MessageStream, error)
CreateChatCompletionStream creates a streaming chat completion request It returns a stream that can be iterated over to get completion chunks
func (*Client) CreateEmbedding ¶
CreateEmbedding generates an embedding vector for the given text with usage tracking.
type ModelNotAvailableError ¶ added in v1.100.0
type ModelNotAvailableError struct {
Model string
}
ModelNotAvailableError is returned at client-creation time when the requested model is not pulled in Docker Model Runner and the `docker model` CLI could not be used to offer a pull. Failing here replaces the raw HTTP 404 the chat endpoint would otherwise return at message time.
func (*ModelNotAvailableError) Error ¶ added in v1.100.0
func (e *ModelNotAvailableError) Error() string
func (*ModelNotAvailableError) ModelPullErrorSummary ¶ added in v1.100.0
func (e *ModelNotAvailableError) ModelPullErrorSummary() string
ModelPullErrorSummary is the concise one-liner used when this error is nested as the cause of another error (e.g. config.AutoModelFallbackError), so the full multi-line guidance is not duplicated.
type PullFailedError ¶ added in v1.89.0
type PullFailedError struct {
Model string
Detail string // cleaned stderr from `docker model pull`
Cause error // underlying *exec.ExitError, exposed via Unwrap
// CorruptPartial is the path to a leftover ".incomplete" blob that caused a
// 416 on resume, when one was identified. When set, the remediation names
// the exact file to remove.
CorruptPartial string
}
PullFailedError is returned when `docker model pull` fails. It carries the model name and the captured pull output so callers (and the user) get an actionable message instead of a bare "exit status 1". teamloader surfaces it unwrapped, so its Error() is what the user sees.
func (*PullFailedError) Error ¶ added in v1.89.0
func (e *PullFailedError) Error() string
func (*PullFailedError) ModelPullErrorSummary ¶ added in v1.89.0
func (e *PullFailedError) ModelPullErrorSummary() string
ModelPullErrorSummary is a concise one-liner used when this error is nested as the cause of another error (e.g. config.AutoModelFallbackError), so the full multi-line guidance is not duplicated.
func (*PullFailedError) Unwrap ¶ added in v1.89.0
func (e *PullFailedError) Unwrap() error