query

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package query provides shared catalog list/detail query behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authors

func Authors(authors []catalogs.Author, opts AuthorOptions) []catalogs.Author

Authors filters, sorts, and limits author results.

func CatalogModels

func CatalogModels(catalog catalogs.Reader, provider string) ([]catalogs.Model, error)

CatalogModels returns either all legacy flattened models or the exact provider-specific offerings from the catalog's provider index.

func Models

func Models(models []catalogs.Model, opts ModelOptions) []catalogs.Model

Models filters, sorts, and limits model results.

func Providers

func Providers(providers []catalogs.Provider, opts ProviderOptions) []catalogs.Provider

Providers filters, sorts, and limits provider results.

Types

type AuthorOptions

type AuthorOptions struct {
	Search string
	Limit  int
}

AuthorOptions controls author list filtering.

type ModelFilter

type ModelFilter struct {
	// Basic filters
	ID           string
	Name         string
	NameContains string
	Provider     string
	Status       string

	// Modality filters
	ModalityInput  []string
	ModalityOutput []string

	// Feature filters
	Features map[string]bool

	// Metadata filters
	Tags        []string
	OpenWeights *bool

	// Numeric range filters
	MinContext int64
	MaxContext int64
	MinInput   int64
	MaxInput   int64
	MinOutput  int64
	MaxOutput  int64

	// Date filters
	ReleasedAfter  *time.Time
	ReleasedBefore *time.Time

	// Pagination
	Sort       string
	Order      string
	Limit      int
	Offset     int
	MaxResults int
}

ModelFilter contains all possible filter criteria for models.

func (ModelFilter) Apply

func (f ModelFilter) Apply(models []catalogs.Model) []catalogs.Model

Apply applies the filter to a list of models and returns filtered results.

func (ModelFilter) Validate

func (f ModelFilter) Validate() error

Validate rejects unsupported or ambiguous filter, sort, range, and page values before query execution.

type ModelOptions

type ModelOptions struct {
	Author     string
	Capability string
	MinContext int64
	MaxPrice   float64
	Search     string
	Limit      int
}

ModelOptions controls model list filtering.

type PageResult

type PageResult[T any] struct {
	Items  []T
	Total  int
	Limit  int
	Offset int
	Count  int
}

PageResult contains paginated query results and metadata.

func Paginate

func Paginate[T any](items []T, limit int, offset int) PageResult[T]

Paginate returns a stable page from a result set.

type ProviderOptions

type ProviderOptions struct {
	Search string
	Limit  int
}

ProviderOptions controls provider list filtering.

Jump to

Keyboard shortcuts

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