discover

package
v0.13.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverModels

func DiscoverModels(ctx context.Context, cfg Config, resolver Resolver) ([]catwalk.Model, error)

DiscoverModels fetches available models from the provider's /models endpoint. It uses the provided context for cancellation and timeout; callers should set a deadline (e.g. context.WithTimeout) to avoid blocking indefinitely. Models whose IDs already appear in cfg.ExistingModels are skipped — user-specified models take precedence.

func IsKnownCustomProvider

func IsKnownCustomProvider(providerType string) bool

IsKnownCustomProvider reports whether the given provider type has a registered enricher. This signals that the provider type is recognized and speaks OpenAI-compat protocol, without exposing the enricher itself to callers that only need the compatibility check.

func RegisterEnricher

func RegisterEnricher(providerType string, e Enricher)

RegisterEnricher registers an Enricher for the given provider type. Called from init() in each enricher implementation file.

func RegisteredProviderTypes

func RegisteredProviderTypes() []string

RegisteredProviderTypes returns the provider type strings that have a registered enricher, sorted for stable output. These are the custom, locally-discovered providers (e.g. ollama, omlx) that Atlas-Agent accepts as a `type` value even though they are not catwalk provider types. The schema generator uses this so the published enum stays in sync with the registry instead of drifting from a hand-maintained list.

Types

type Config

type Config struct {
	ID           string
	BaseURL      string
	APIKey       string
	ExtraHeaders map[string]string
	// Existing models from config — IDs present in this list are skipped
	// during discovery (user-specified models win).
	ExistingModels []catwalk.Model
}

Config holds the provider configuration needed for model discovery.

type Enricher

type Enricher interface {
	// EnrichModels takes a slice of bare discovered models and returns
	// them with metadata populated. Implementations should preserve
	// existing non-zero fields (user overrides take precedence).
	EnrichModels(ctx context.Context, cfg Config, resolver Resolver, models []catwalk.Model) ([]catwalk.Model, error)
}

Enricher fills in model metadata (context window, max tokens, pricing, etc.) for discovered models. Providers that expose richer endpoints beyond /v1/models can register an Enricher to populate fields that the standard listing endpoint omits.

func GetEnricher

func GetEnricher(providerType string) Enricher

GetEnricher returns the Enricher for the given provider type, or nil if no enricher is registered.

type Resolver

type Resolver interface {
	ResolveValue(val string) (string, error)
}

Resolver resolves variable references (e.g. $ENV_VAR) in config values.

Jump to

Keyboard shortcuts

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