Documentation
¶
Overview ¶
Package model defines model metadata and collections.
Index ¶
- type ContextLength
- type DisplayOptions
- type Model
- type Models
- func (ms Models) ByContextLength() Models
- func (ms Models) ByName() Models
- func (ms Models) BySize() Models
- func (ms Models) Display(w io.Writer, sortBy SortBy) error
- func (ms Models) Exclude(patterns ...string) Models
- func (ms Models) Exists(name string) bool
- func (ms Models) Get(name string) Model
- func (ms Models) HasTools() Models
- func (ms Models) Include(patterns ...string) Models
- func (ms Models) IsEmbedding() Models
- func (ms Models) IsGeneral() Models
- func (ms Models) LongestName() int
- func (ms Models) Names() []string
- func (ms Models) Sort(by SortBy) Models
- func (ms Models) WithCapability(cap capabilities.Capability) Models
- type ParameterCount
- type SortBy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextLength ¶
type ContextLength int
ContextLength represents a context window size.
func (ContextLength) PercentUsed ¶
func (c ContextLength) PercentUsed(inputTokens int) float64
PercentUsed returns the percentage of context used by the given input token count.
func (ContextLength) String ¶
func (c ContextLength) String() string
String returns a human-readable SI format (e.g., "8k", "128k").
type DisplayOptions ¶
type DisplayOptions struct {
Bullet string
ModelName func(a ...any) string
ParamsLabel string
ParamsValue func(a ...any) string
ContextLabel string
ContextValue func(a ...any) string
SizeLabel string
SizeValue func(a ...any) string
ThinkingIcon func(a ...any) string
VisionIcon func(a ...any) string
NameWidth int
MaxParamsLen int
MaxCtxLen int
}
type Model ¶
type Model struct {
// Name is the model identifier.
Name string
// ParameterCount is the model's parameter count (e.g., 8B = 8_000_000_000).
ParameterCount ParameterCount `json:"parameter_count,omitempty"`
// ContextLength is the maximum context window size.
ContextLength ContextLength `json:"context_length"`
// Capabilities lists the model's supported features.
Capabilities capabilities.Capabilities `json:",omitempty"`
// Family is the model family name (e.g., "gpt", "llama").
Family string `json:",omitempty"`
// Size is the model size in bytes.
Size uint64 `json:",omitempty"`
}
Model represents an LLM model with metadata.
func (Model) Context ¶
func (m Model) Context(opts DisplayOptions) string
func (*Model) Deref ¶
Deref safely dereferences a *Model pointer. Returns the Model value if non-nil, or a zero-value Model if nil. Safe to call on nil receivers.
func (Model) Display ¶
func (m Model) Display(opts DisplayOptions) string
Display returns a formatted, colorized string for a single model.
func (Model) Params ¶
func (m Model) Params(opts DisplayOptions) string
type Models ¶
type Models []Model
Models is a collection of model metadata.
func (Models) ByContextLength ¶
ByContextLength returns models sorted by context length (descending), with name as fallback.
func (Models) BySize ¶
BySize returns models sorted by size (descending), with context length as fallback.
func (Models) Display ¶
Display prints the models in a formatted, colorized output grouped by capability.
func (Models) Exclude ¶
Exclude returns models that do not match any of the given wildcard patterns.
func (Models) IsEmbedding ¶
IsEmbedding returns embedding models.
func (Models) IsGeneral ¶
IsGeneral returns general-purpose models (neither embedding nor tool-specific).
func (Models) LongestName ¶
LongestName returns the display width of the longest model name.
func (Models) WithCapability ¶
func (ms Models) WithCapability(cap capabilities.Capability) Models
WithCapability returns models that have the given capability.
type ParameterCount ¶
type ParameterCount int64
ParameterCount represents a model's parameter count in absolute units. For example, an 8B model is stored as 8_000_000_000.
func ParseParameterName ¶
func ParseParameterName(name string) ParameterCount
ParseParameterName extracts a parameter count from a model name string. Falls back to 0 if no pattern is found.
func ParseParameterSize ¶
func ParseParameterSize(s string) ParameterCount
ParseParameterSize parses an explicit parameter size string (e.g., "8B", "70.6B", "567M"). This is the format returned by the Ollama API's Details.ParameterSize field. Returns 0 if the string doesn't match.
func (ParameterCount) Billions ¶
func (p ParameterCount) Billions() float64
Billions returns the parameter count in billions as a float.
func (ParameterCount) String ¶
func (p ParameterCount) String() string
String returns a human-readable parameter count (e.g., "8B", "70B", "1.5B", "567M"). Zero value returns an empty string.