query

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: AGPL-3.0 Imports: 9 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 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) ApplyRecords added in v0.2.0

func (f ModelFilter) ApplyRecords(records []ModelRecord) []ModelRecord

ApplyRecords applies the model filter without discarding provider identity.

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 ModelRecord added in v0.2.0

type ModelRecord struct {
	catalogs.Model
	ProviderID catalogs.ProviderID
}

ModelRecord identifies one exact provider-scoped model record. Embedding the model preserves the existing flat JSON shape while provider_id prevents equal model IDs from becoming ambiguous in unfiltered list results.

func CatalogModels

func CatalogModels(catalog *catalogs.Catalog, provider string) ([]ModelRecord, error)

CatalogModels returns exact provider model records from the catalog's provider index. With no provider filter, equal model IDs from different providers remain distinct. CatalogModels orders them by provider ID, then model ID.

func Models

func Models(models []ModelRecord, opts ModelOptions) []ModelRecord

Models filters, sorts, and limits model results.

func (ModelRecord) MarshalJSON added in v0.2.0

func (r ModelRecord) MarshalJSON() ([]byte, error)

MarshalJSON preserves the historical flat model object while adding its provider-scoped identity. Model has a custom marshaler, so ordinary anonymous embedding would otherwise consume the outer provider_id field.

func (ModelRecord) MarshalYAML added in v0.2.0

func (r ModelRecord) MarshalYAML() (any, error)

MarshalYAML preserves the same flat provider-scoped shape as MarshalJSON.

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