registry

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProviderTemplateDefinitions

func ProviderTemplateDefinitions(definitions []ProviderDefinition) []providertemplates.Definition

func Sync

func Sync(ctx context.Context, logger *slog.Logger, queries dbstore.Queries, defs []ProviderDefinition) error

Sync upserts the given provider definitions into the database. New providers are created with enable=false. Existing registry providers are matched by source file, then name, then legacy model fingerprints, so changing a YAML display name updates the existing provider instead of creating a duplicate. Existing enable state, credentials, and custom config values are preserved. Models are upserted by (provider_id, model_id), overwriting name/type/config.

Types

type ModelDefinition

type ModelDefinition struct {
	ModelID string         `yaml:"model_id"`
	Name    string         `yaml:"name"`
	Type    string         `yaml:"type"`
	Config  map[string]any `yaml:"config"`
}

ModelDefinition describes a model within a provider definition.

type ProviderDefinition

type ProviderDefinition struct {
	ID         string            `yaml:"id,omitempty"`
	Name       string            `yaml:"name"`
	ClientType string            `yaml:"client_type"`
	Icon       string            `yaml:"icon,omitempty"`
	BaseURL    string            `yaml:"base_url,omitempty"`
	Config     map[string]any    `yaml:"config,omitempty"`
	Models     []ModelDefinition `yaml:"models"`
	Source     string            `yaml:"-"`
}

ProviderDefinition describes a built-in provider loaded from a YAML file.

func Load

func Load(log *slog.Logger, dir string) ([]ProviderDefinition, error)

Load reads all .yaml / .yml files from dir and returns parsed provider definitions. It returns nil (no error) when the directory does not exist. Malformed files are skipped with a warning logged via log.

Jump to

Keyboard shortcuts

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