dmr

package
v1.58.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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

func ConvertParametersToSchema(params any) (any, error)

ConvertParametersToSchema converts parameters to DMR Schema format

func UnloadURL added in v1.58.0

func UnloadURL(baseURL, unloadAPI string) (string, error)

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:

  1. unloadAPI is an absolute URL — used verbatim (lets users point at a different host than baseURL);
  2. unloadAPI is set but relative — rebased onto baseURL's scheme + host (the model's path is dropped);
  3. 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

type Client struct {
	base.Config
	// contains filtered or unexported fields
}

Client represents an DMR client wrapper It implements the provider.Provider interface

func NewClient

func NewClient(ctx context.Context, cfg *latest.ModelConfig, opts ...options.Opt) (*Client, error)

NewClient creates a new DMR client from the provided configuration

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

func (c *Client) CreateEmbedding(ctx context.Context, text string) (*base.EmbeddingResult, error)

CreateEmbedding generates an embedding vector for the given text with usage tracking.

func (*Client) Rerank

func (c *Client) Rerank(ctx context.Context, query string, documents []types.Document, criteria string) ([]float64, error)

Rerank scores documents by relevance to the query using a reranking model. Returns relevance scores in the same order as input documents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL