providercatalogue

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: BSD-2-Clause Imports: 5 Imported by: 1 module, 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 providercatalogue renders the pi CLI's provider catalogue.

pi 0.87.1 has no environment variable for a provider base URL; the only route to a non-built-in endpoint is <agent-dir>/models.json. This package exists so the two entry points (main.go and cmd/run-task/main.go) share one renderer instead of each carrying a copy that can drift, and so the file the CLI parses is covered by tests that assert its shape rather than its substrings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Models

func Models(ctx context.Context, settings Settings) ([]byte, error)

Models renders the catalogue bytes for the configured provider.

It returns nil when no base URL is configured, which is the signal that the pi CLI's own default provider configuration applies and no catalogue should be written. contextWindow is declared explicitly because pi silently falls back to 128000 when it is omitted, so a larger-window model would compact early with no error.

func Write

func Write(ctx context.Context, settings Settings, agentDir string) error

Write renders the catalogue into <agentDir>/models.json.

It writes nothing when no base URL is configured, and in particular leaves an existing models.json untouched: an unconfigured agent must keep behaving exactly as it did before this package existed. The directory is created on demand because the pi agent directory may not exist yet on a fresh volume.

Types

type Settings

type Settings struct {
	ProviderBaseURL string
	ProviderKeyEnv  string
	Model           string
	ContextWindow   int
	MaxTokens       int
}

Settings is the provider configuration rendered into the catalogue.

ProviderKeyEnv carries the *name* of the environment variable pi interpolates, never the credential itself: pi resolves "$NAME" from its own environment at request time, so writing the value into the file would put the secret on disk for no gain.

Jump to

Keyboard shortcuts

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