llmprovider

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ParityPresetNone            = "none"
	ParityPresetDbrainModelfile = "dbrain-modelfile"
)

Parity preset identifiers used by model_bakeoff --parity-preset.

View Source
const (
	StrictnessNone      = "none"
	StrictnessStrict    = "strict"
	StrictnessNonStrict = "non-strict"
)

Strictness labels describe how strict a parity run is about the parameters actually sent to a provider.

View Source
const (
	ToolOllamaDirect     = "ollama-direct"
	ToolOpenRouterDirect = "openrouter-direct"
	ToolLMStudioDirect   = "lmstudio-direct"
	ToolOMLXDirect       = "omlx-direct"

	ToolVersionOllamaDirect     = "ollama-direct-v1"
	ToolVersionOpenRouterDirect = "openrouter-direct-v1"
	ToolVersionLMStudioDirect   = "lmstudio-direct-v1"
	ToolVersionOMLXDirect       = "omlx-direct-v1"
)

Variables

This section is empty.

Functions

func CloneAnyMap

func CloneAnyMap(in map[string]any) map[string]any

CloneAnyMap returns a shallow copy of the input map. Exported so other packages can clone inference parameter maps when building provider-specific request bodies.

func DbrainModelfilePreset

func DbrainModelfilePreset() map[string]any

DbrainModelfilePreset returns the sampler values defined in the repo Modelfile. These are the canonical dbrain parity values for local runs.

func ResolveBaseURL added in v0.8.0

func ResolveBaseURL(opts BaseURLResolveOptions) (string, error)

ResolveBaseURL resolves one provider endpoint without reading API keys, secret references, model strings, or task-specific headers.

Types

type BaseURLResolveOptions added in v0.8.0

type BaseURLResolveOptions struct {
	RootDir  string
	Env      map[string]string
	Provider Provider
	Override string
}

type Capabilities

type Capabilities struct {
	Text         bool
	Images       CapabilityStatus
	JSONMode     CapabilityStatus
	ToolCalling  CapabilityStatus
	ReasoningCtl CapabilityStatus
}

func TextOnlyCapabilities

func TextOnlyCapabilities() Capabilities

type CapabilityStatus

type CapabilityStatus string
const (
	CapabilitySupported                  CapabilityStatus = "supported"
	CapabilityUnsupported                CapabilityStatus = "unsupported"
	CapabilityModelDependentOrUnverified CapabilityStatus = "model_dependent_or_unverified"
)

type HeaderPolicy

type HeaderPolicy struct {
	RefererEnvKeys       []string
	TitleEnvKeys         []string
	UserAgentEnvKeys     []string
	DefaultRefererByTask map[Task]string
	DefaultTitleByTask   map[Task]string
}

type ModelRef

type ModelRef struct {
	Original          string
	Provider          Provider
	APIModel          string
	ProviderQualified bool
	Spec              *ProviderSpec
}

ModelRef is the parsed form of a provider-qualified model string.

func ParseModelRef

func ParseModelRef(model string) ModelRef

type ParamAccounting

type ParamAccounting struct {
	Requested  map[string]any
	Sent       map[string]any
	Omitted    map[string]string
	Strictness string
}

ParamAccounting records the requested, sent, and omitted inference parameters for a model call. Requested is the caller's requested shape; Sent is what goes on the wire; Omitted maps requested-but-not-sent keys to a reason.

func AccountParamsForSpec

func AccountParamsForSpec(spec ProviderSpec, requested map[string]any) ParamAccounting

func DbrainParityForSpec

func DbrainParityForSpec(spec ProviderSpec) ParamAccounting

type ParamPolicy

type ParamPolicy struct {
	LocalModelfileParity  bool
	OpenAICompatibleLocal bool
}

type ParityParams

type ParityParams = ParamAccounting

func DbrainParityForProvider

func DbrainParityForProvider(provider Provider) ParityParams

DbrainParityForProvider returns the dbrain Modelfile parity parameters adjusted for what each provider path can actually accept.

Ollama: all Modelfile sampler values are sent through the native /api/chat options object, so strict parity is achievable.

LM Studio/oMLX/configured local OpenAI-compatible backends: temperature and top_p are sent as standard chat-completions fields. top_k, repeat_penalty, and min_p are omitted until a backend path is verified to accept them. The run is therefore labelled non-strict.

Other providers (including OpenRouter) receive no local parity parameters from this preset.

func EmptyParityParams

func EmptyParityParams() ParityParams

EmptyParityParams is the zero shape used when no parity preset is active.

type PromptPolicy

type PromptPolicy struct {
	ParityStatusWithPreset string
}

type Provider

type Provider string

Provider identifies the LLM backend a model string targets.

const (
	ProviderPlain      Provider = ""
	ProviderOllama     Provider = "ollama"
	ProviderOpenRouter Provider = "openrouter"
	ProviderLMStudio   Provider = "lmstudio"
	ProviderOMLX       Provider = "omlx"
)

func EmptyProviderRef

func EmptyProviderRef(model string) (Provider, bool)

type ProviderOverrides

type ProviderOverrides struct {
	BaseURL   string
	APIKey    string
	Referer   string
	Title     string
	UserAgent string
}

type ProviderSpec

type ProviderSpec struct {
	ID              Provider
	DisplayName     string
	Transport       Transport
	Local           bool
	DefaultBaseURL  string
	DefaultAPIKey   string
	BaseURLEnvKeys  []string
	APIKeyEnvKeys   []string
	RequiresAPIKey  bool
	HeaderPolicy    HeaderPolicy
	ToolName        string
	ToolVersion     string
	ParamPolicy     ParamPolicy
	PromptPolicy    PromptPolicy
	ReasoningPolicy ReasoningPolicy
	Capabilities    Capabilities
	ConfigPath      []string
}

func BuiltInProviderSpecs

func BuiltInProviderSpecs() []ProviderSpec

type ReasoningPolicy

type ReasoningPolicy struct {
	StatusWithDirectCall string
}

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() Registry

func RegistryForRoot

func RegistryForRoot(rootDir string) (Registry, error)

func (Registry) EmptyProviderRef

func (r Registry) EmptyProviderRef(model string) (Provider, bool)

func (Registry) ParseModelRef

func (r Registry) ParseModelRef(model string) ModelRef

func (*Registry) Register

func (r *Registry) Register(spec ProviderSpec) error

func (Registry) Spec

func (r Registry) Spec(provider Provider) (ProviderSpec, bool)

type ResolveOptions

type ResolveOptions struct {
	RootDir   string
	Env       map[string]string
	Model     string
	Task      Task
	Overrides map[Provider]ProviderOverrides
}

type Target

type Target struct {
	Ref         ModelRef
	Spec        ProviderSpec
	BaseURL     string
	APIKey      string
	Headers     map[string]string
	DisplayName string
}

func ResolveTarget

func ResolveTarget(ctx context.Context, opts ResolveOptions) (Target, error)

func (Target) AuthorizationHeader

func (t Target) AuthorizationHeader() string

type Task

type Task string
const (
	TaskSummary    Task = "summary"
	TaskCategorize Task = "categorize"
	TaskOCR        Task = "ocr"
	TaskBakeoff    Task = "bakeoff"
)

type Transport

type Transport string
const (
	TransportOllamaChat        Transport = "ollama_chat"
	TransportOpenAIChat        Transport = "openai_chat_completions"
	TransportAnthropicMessages Transport = "anthropic_messages"
)

Jump to

Keyboard shortcuts

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