x

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package x is an experimental package that provides the customizability of the AI Gateway filter.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatchingRule = errors.New("no matching rule found")

ErrNoMatchingRule is the error the router function must return if there is no matching rule.

Functions

This section is empty.

Types

type NewCustomRouterFn

type NewCustomRouterFn func(defaultRouter Router, config *filterapi.Config) Router

NewCustomRouterFn is the function signature for NewCustomRouter.

It accepts the exptproc config passed to the AI Gateway filter and returns a Router. This is called when the new configuration is loaded.

The defaultRouter can be used to delegate the calculation to the default router implementation.

var NewCustomRouter NewCustomRouterFn

NewCustomRouter is the function to create a custom router over the default router. This is nil by default and can be set by the custom build of external processor.

type Router

type Router interface {
	// Calculate determines the backend to route to based on the request headers.
	//
	// The request headers include the populated [filterapi.Config.ModelNameHeaderKey]
	// with the parsed model name based on the [filterapi.Config] given to the NewCustomRouterFn.
	//
	// Returns the backend.
	Calculate(requestHeaders map[string]string) (backend *filterapi.Backend, err error)
}

Router is the interface for the router.

Router must be goroutine-safe as it is shared across multiple requests.

Jump to

Keyboard shortcuts

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