model

package
v0.93.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package model provides built-in LLM metadata and dual-model routing.

The catalog map holds known model limits (context length, max output, features). Chat agent and context management resolve token budgets from this catalog.

Index

Constants

View Source
const DefaultContextWindow = 128000

DefaultContextWindow is the fallback input token budget for unknown models.

Variables

This section is empty.

Functions

func ApplyDefaultRouter

func ApplyDefaultRouter(cfg msg.Config) msg.Config

ApplyDefaultRouter injects dual-model PrepareNextTurn when chat and tool models are set.

func ContextWindowFor

func ContextWindowFor(modelName string) int

ContextWindowFor returns the input token budget for a model name.

func HasFeature

func HasFeature(modelName string, feature Feature) bool

HasFeature reports whether a known model supports the given feature.

func MaxContextWindow

func MaxContextWindow(modelNames ...string) int

MaxContextWindow returns the largest input token budget among the given model names.

func RegisterTestMetadata

func RegisterTestMetadata(t *testing.T, meta Metadata)

RegisterTestMetadata adds or overrides a catalog entry for the duration of a test.

Types

type Feature

type Feature string

Feature names a capability or modality supported by a model.

const (
	// CapChat marks conversational chat support.
	CapChat Feature = "CapChat"
	// CapFunctionCall marks native tool / function calling support.
	CapFunctionCall Feature = "CapFunctionCall"
	// CapJsonMode marks structured JSON output mode support.
	CapJsonMode Feature = "CapJsonMode"
	// ModalityTextIn marks text input modality support.
	ModalityTextIn Feature = "ModalityTextIn"
	// ModalityTextOut marks text output modality support.
	ModalityTextOut Feature = "ModalityTextOut"
	// ModalityImageIn marks image input modality support.
	ModalityImageIn Feature = "ModalityImageIn"
	// ModalityFileIn marks file input modality support.
	ModalityFileIn Feature = "ModalityFileIn"
)

type Metadata

type Metadata struct {
	// ID is the provider-facing model identifier.
	ID string
	// Name is a human-readable display name.
	Name string
	// Description summarizes model capabilities for UI and docs.
	Description string
	// ContextLength is the maximum input token budget.
	ContextLength int
	// MaxOutput is the maximum completion token budget.
	MaxOutput int
	// Features lists supported capabilities and modalities.
	Features []Feature
}

Metadata describes a known LLM and its operational limits.

func Lookup

func Lookup(id string) (Metadata, bool)

Lookup returns catalog metadata for a model ID when known.

type Router

type Router struct {
	ChatModel string
	ToolModel string
}

Router selects between chat and tool models for dual-model strategies.

func NewRouter

func NewRouter(chatModel, toolModel string) *Router

NewRouter creates a router with explicit chat and tool model names.

func (*Router) ApplyToContext

func (r *Router) ApplyToContext(ctx *msg.Context, afterToolExecution bool)

ApplyToContext updates the agent context model field using router defaults.

func (*Router) PrepareNextTurnHook

func (r *Router) PrepareNextTurnHook() msg.PrepareNextTurnFn

PrepareNextTurnHook returns a turn-boundary hook that routes to chat or tool models.

func (*Router) Select

func (r *Router) Select(afterToolExecution bool) string

Select chooses the model for the next provider request.

Jump to

Keyboard shortcuts

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