Documentation
¶
Index ¶
- Constants
- Variables
- func IsLoopbackHost(host string) bool
- type AuthConfig
- type BackendConfig
- type BackendModels
- type Config
- func (c *Config) Address() string
- func (c *Config) AllModels() []Model
- func (c *Config) BackendForModel(id string) *BackendConfig
- func (c *Config) HasModelCosts() bool
- func (c *Config) LocalModelID(upstreamID string) string
- func (c *Config) ModelCost(id string) ModelCost
- func (c *Config) Validate() error
- type Flags
- type Model
- type ModelCost
- type ServerConfig
- type TestConfig
- type UIConfig
Constants ¶
const ( DefaultHost = "127.0.0.1" DefaultPort = 8080 DefaultLocation = "global" DefaultUIRecentRequests = 10 MaxUIRecentRequests = 100 )
const ( DefaultTestSystemMessage = "You are a helpful assistant." DefaultTestUserMessage = "Reply with a short test message to confirm this connection is working." )
Variables ¶
var ErrUsage = errors.New("usage error")
Functions ¶
func IsLoopbackHost ¶
Types ¶
type AuthConfig ¶ added in v0.2.0
type AuthConfig struct {
Type string `yaml:"type"` // none, bearer, google_adc, oauth_client_credentials
Token string `yaml:"token"`
TokenURL string `yaml:"token_url"`
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
Scopes []string `yaml:"scopes"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}
AuthConfig describes how to authenticate against a backend.
type BackendConfig ¶ added in v0.2.0
type BackendConfig struct {
Name string `yaml:"name"`
Type string `yaml:"type"` // gcp_openai or openai_compatible
BaseURL string `yaml:"base_url"`
Project string `yaml:"project"`
Location string `yaml:"location"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
Auth AuthConfig `yaml:"auth"`
Models BackendModels `yaml:"models"`
}
BackendConfig describes one upstream backend.
func (*BackendConfig) UpstreamModelID ¶ added in v0.2.0
func (bc *BackendConfig) UpstreamModelID(id string) string
UpstreamModelID returns the upstream model ID that should be sent to the backend for the given local model ID.
func (*BackendConfig) VertexBaseURL ¶ added in v0.2.0
func (bc *BackendConfig) VertexBaseURL() string
VertexBaseURL computes the Vertex AI OpenAI-compatible base URL for a gcp_openai backend.
type BackendModels ¶ added in v0.2.0
BackendModels holds either "all" (pass-through) or an explicit list of models.
func (*BackendModels) UnmarshalYAML ¶ added in v0.2.0
func (bm *BackendModels) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML supports both `models: all` and `models: [{id: ...}]`.
type Config ¶
type Config struct {
Server ServerConfig `yaml:"server"`
Backends []BackendConfig `yaml:"backends"`
UI UIConfig `yaml:"ui"`
SourcePath string `yaml:"-"`
}
func (*Config) AllModels ¶ added in v0.2.0
AllModels returns all explicitly-listed models across all backends (excludes "models: all" backends).
func (*Config) BackendForModel ¶ added in v0.2.0
func (c *Config) BackendForModel(id string) *BackendConfig
BackendForModel returns the first backend that serves the given model ID. Exact-listed models take priority over "models: all" pass-through backends.
func (*Config) HasModelCosts ¶ added in v0.4.0
func (*Config) LocalModelID ¶
LocalModelID translates an upstream model ID back to the local model ID.
type ModelCost ¶ added in v0.4.0
type ModelCost struct {
InputPerMillion float64 `yaml:"input_per_million"`
OutputPerMillion float64 `yaml:"output_per_million"`
CachePerMillion float64 `yaml:"cache_per_million"`
}
func (ModelCost) RequestCost ¶ added in v0.4.0
type ServerConfig ¶
type TestConfig ¶ added in v0.6.0
type TestConfig struct {
Enabled *bool `yaml:"enabled"`
SystemMessage string `yaml:"system_message"`
UserMessage string `yaml:"user_message"`
}
TestConfig controls the in-TUI model test feature.
type UIConfig ¶
type UIConfig struct {
RecentRequests int `yaml:"recent_requests"`
Test TestConfig `yaml:"test"`
}
func (*UIConfig) TestEnabled ¶ added in v0.6.0
TestEnabled returns whether the TUI test tab is enabled (default true).
func (*UIConfig) TestSystemMsg ¶ added in v0.6.0
TestSystemMsg returns the system message for testing, using the default if not configured.
func (*UIConfig) TestUserMsg ¶ added in v0.6.0
TestUserMsg returns the user message for testing, using the default if not configured.