Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertParametersToSchema(params any) (any, 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)
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 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.