models

package
v0.0.185 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package models lists available Grok CLI models from on-disk files only (~/.grok/config.toml and models_cache.json). It does not spawn `grok models`.

Index

Constants

View Source
const (
	// DefaultConfigFile is the Grok home config name.
	DefaultConfigFile = "config.toml"
	// ModelsCacheFile is the Grok home models cache name.
	ModelsCacheFile = "models_cache.json"
)

Variables

This section is empty.

Functions

func DefaultHome

func DefaultHome() string

DefaultHome returns $GROK_HOME when set, otherwise $HOME/.grok. Empty HOME falls back to a temp-dir based path (same idea as agenttty.GrokHome).

func FormatJSON added in v0.0.184

func FormatJSON(cat Catalog) ([]byte, error)

FormatJSON returns indented Catalog JSON for CLI --json output.

func FormatText added in v0.0.184

func FormatText(cat Catalog) string

FormatText returns a human-readable catalog listing. The configured default model is marked with a leading "* ".

func ListIDs

func ListIDs(home string) ([]string, error)

ListIDs returns List(home) model ids in catalog order.

Types

type Catalog

type Catalog struct {
	// Home is the resolved Grok data directory used for the listing.
	Home string `json:"home"`
	// Default is [models].default from config.toml (empty when unset/missing).
	Default string `json:"default,omitempty"`
	// Models is the sorted unique union of config.toml [model."…"] keys and
	// models_cache.json model ids. Empty when neither source yields ids.
	Models []Model `json:"models"`
	// FromConfig is true when config.toml was read successfully.
	FromConfig bool `json:"from_config"`
	// FromCache is true when models_cache.json was read successfully.
	FromCache bool `json:"from_cache"`
}

Catalog is the merged file-backed model list for a Grok home.

func List

func List(home string) (Catalog, error)

List returns the file-backed catalog for home. Empty home uses DefaultHome(). Missing files are soft: empty Models, no error unless a present file is unreadable/invalid.

type Model added in v0.0.185

type Model struct {
	// ID is the model id passed to grok.
	ID string `json:"id"`
	// Source is the basename of the file that primarily contributed this id
	// (config.toml preferred over models_cache.json when both list it).
	Source string `json:"source"`
	// DisplayName is config `name` when set, else cache info.name.
	DisplayName string `json:"display_name,omitempty"`
}

Model is one selectable Grok model in the unified CLI JSON shape.

Jump to

Keyboard shortcuts

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