router

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatModelString

func FormatModelString(provider, model string) string

FormatModelString formats provider and model into a comma-separated string

func ParseModelString

func ParseModelString(modelStr string) (provider, model string)

ParseModelString parses a model string which can be either "model" or "provider,model"

func RouterMiddleware

func RouterMiddleware(cfg *config.Config) gin.HandlerFunc

RouterMiddleware creates a middleware that performs intelligent model routing

Types

type Request

type Request struct {
	Model    string `json:"model"`
	Thinking bool   `json:"thinking,omitempty"`
}

Request represents the incoming request with model and parameters

type RouteDecision

type RouteDecision struct {
	Provider   string
	Model      string
	Reason     string
	Parameters map[string]interface{}
}

RouteDecision represents the result of routing logic

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router handles intelligent model routing based on various criteria

func New

func New(cfg *config.Config) *Router

New creates a new Router instance

func (*Router) GetProviderForModel

func (r *Router) GetProviderForModel(model string) (string, error)

GetProviderForModel returns the provider for a given model based on configuration

func (*Router) Route

func (r *Router) Route(req Request, tokenCount int) RouteDecision

Route determines which model to use based on request parameters and token count

Jump to

Keyboard shortcuts

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