modelmatch

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package modelmatch is the single implementation of the LLM "allowed models" matching rule. The proxy (request time), the LLM service (save time) and the failover validator all delegate here so a model that passes in one place passes everywhere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allowed

func Allowed(patterns []string, modelName string) bool

Allowed reports whether modelName is permitted by the configured patterns.

Two behaviours worth stating plainly, because both surprise people:

  1. An empty pattern list allows EVERY model. An empty Allowed Models field is not a deny-all.
  2. Patterns are matched UNANCHORED, i.e. anywhere within the model name. So "gpt-4.*" -- the example the UI itself suggests -- also matches "legacy-gpt-4o" and "not-really-gpt-4". Anchor explicitly with ^ and $ if you mean the whole name.

The unanchored behaviour is kept deliberately: existing configurations rely on substring matching, and silently anchoring them would start rejecting models that are allowed today.

A pattern that fails to compile never matches; it does not turn into a wildcard. Use AllowedStrict when the caller wants to hear about it.

func AllowedStrict

func AllowedStrict(patterns []string, modelName string) (bool, error)

AllowedStrict is Allowed but surfaces an invalid pattern as an error instead of treating it as a non-match. Save-time validation uses this so an admin learns about a broken pattern rather than silently locking a model out.

Types

This section is empty.

Jump to

Keyboard shortcuts

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