llmresolver

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: Apache-2.0 Imports: 7 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

Overview

Package llmresolver selects the most appropriate backend LLM instance based on requirements.

Index

Constants

View Source
const (
	StrategyRandom      = "random"
	StrategyAuto        = "auto"
	StrategyLowLatency  = "low-latency"
	StrategyLowPriority = "low-prio"
)

Variables

View Source
var (
	ErrNoAvailableModels        = errors.New("no models found in runtime state")
	ErrNoSatisfactoryModel      = errors.New("no model matched the requirements")
	ErrUnknownModelCapabilities = errors.New("capabilities not known for this model")
)
View Source
var DefaultProviderType string = "ollama"

Functions

func Chat

func Embed

func Embed(
	ctx context.Context,
	embedReq EmbedRequest,
	getModels ProviderFromRuntimeState,
	resolver Policy,
) (libmodelprovider.LLMEmbedClient, error)

func HighestContext

func HighestContext(candidates []libmodelprovider.Provider) (libmodelprovider.Provider, string, error)

func NormalizeModelName

func NormalizeModelName(modelName string) string

NormalizeModelName standardizes model names for comparison

func PromptExecute

func PromptExecute(
	ctx context.Context,
	reqExec PromptRequest,
	getModels ProviderFromRuntimeState,
	resolver Policy,
) (libmodelprovider.LLMPromptExecClient, error)

func Randomly

func Stream

func Stream(
	ctx context.Context,
	req Request,
	getModels ProviderFromRuntimeState,
	resolver Policy,
) (libmodelprovider.LLMStreamClient, error)

Types

type EmbedRequest

type EmbedRequest struct {
	ModelName    string
	ProviderType string // Optional. Empty uses default.
	// contains filtered or unexported fields
}

type Policy

type Policy func(candidates []libmodelprovider.Provider) (libmodelprovider.Provider, string, error)

func PolicyFromString

func PolicyFromString(name string) (Policy, error)

PolicyFromString maps string names to resolver policies

type PromptRequest

type PromptRequest struct {
	ModelNames    []string
	ProviderTypes []string // Optional. Empty uses default.
	Tracker       activitytracker.ActivityTracker
	ContextLength int
}

type ProviderFromRuntimeState

type ProviderFromRuntimeState func(ctx context.Context, backendTypes ...string) ([]libmodelprovider.Provider, error)

ProviderFromRuntimeState retrieves available model providers

type Request

type Request struct {
	ProviderTypes []string // Optional: if empty, uses all default providers
	ModelNames    []string // Optional: if empty, any model is considered
	ContextLength int      // Minimum required context length
	Tracker       activitytracker.ActivityTracker
}

Request contains requirements for selecting a model provider.

Jump to

Keyboard shortcuts

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