modelselectors

package
v0.1.56 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package modelselectors normalizes provider/model selector strings shared by model-level admin features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExactMatchKey

func ExactMatchKey(providerName, model string) string

ExactMatchKey returns the lookup key used to index exact provider+model overrides. Returns "" when either side is missing — exact matching only applies to fully-qualified pairs.

func IsGlobal

func IsGlobal(raw string) bool

IsGlobal reports whether raw selects every provider and model.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError reports whether err is a validation error.

func NewValidationError

func NewValidationError(message string, err error) error

NewValidationError creates a selector validation error.

func ParseStoredParts

func ParseStoredParts(selector string) (providerName, model string)

ParseStoredParts splits a stored selector without a configured-provider catalog. This is a best-effort fallback for old rows. Stores should persist provider_name and model columns because slash-shaped model IDs cannot be distinguished from provider/model selectors without a provider catalog.

func ProviderNames

func ProviderNames(catalog Catalog) []string

ProviderNames returns a copy of configured provider names from catalog.

func String

func String(providerName, model string) string

String returns the canonical selector string for normalized parts.

Types

type Catalog

type Catalog interface {
	ProviderNames() []string
}

Catalog is the minimal configured-provider surface needed for selector validation.

type ScopeKind

type ScopeKind string

ScopeKind identifies how broadly a selector applies.

const (
	ScopeGlobal        ScopeKind = "global"
	ScopeModel         ScopeKind = "model"
	ScopeProvider      ScopeKind = "provider"
	ScopeProviderModel ScopeKind = "provider_model"
)

func ScopeKindFor

func ScopeKindFor(selector, providerName, model string) ScopeKind

ScopeKindFor reports the normalized selector scope.

type Selector

type Selector struct {
	Selector     string
	ProviderName string
	Model        string
}

Selector is the normalized form of a model selector.

func NormalizeInput

func NormalizeInput(catalog Catalog, raw string) (Selector, error)

NormalizeInput validates and normalizes one user-supplied selector.

func NormalizeInputWithProviderNames

func NormalizeInputWithProviderNames(providerNames []string, raw string) (Selector, error)

NormalizeInputWithProviderNames validates and normalizes one user-supplied selector.

func NormalizeStored

func NormalizeStored(selector, providerName, model string) (Selector, error)

NormalizeStored normalizes selector columns loaded from storage.

type ValidationError

type ValidationError = validation.Error

ValidationError indicates invalid selector input or invalid selector state.

Jump to

Keyboard shortcuts

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