Documentation
¶
Overview ¶
Package coreconfig holds the engine-level configuration shared by every OpenFastChat wrapper: the OpenAI-compatible provider set, the model→provider routing index, the model registry, and the flow-engine tuning constants. It carries no billing, auth, or env-secret concerns — those live in each wrapper's own config.
Index ¶
- Constants
- Variables
- func DefaultModel() string
- func ProviderFor(model string) llmclient.Client
- func ResolveModel(model string) string
- func SetActiveProviders(provs []ProviderConfig)
- func SetModels(entries []ModelEntry)
- func SetPricingOverrides(p map[string][2]float64)
- type HandlerConfig
- type ModelConfig
- type ModelEntry
- type ProviderConfig
Constants ¶
const ( // Model/token fallbacks. FallbackMaxCompletionTokens = 8192 FallbackInputPricePerK = 0.00059 FallbackOutputPricePerK = 0.00079 // Context compaction. CompactReservedTokens = 200 + 1024 CompactFallbackContext = 8192 CompactMinAvailable = 1024 CompactCharsPerToken = 4 CompactMaxOutputTokens = 1024 // Web search. WebSearchTimeoutSecs = 5 WebSearchMaxResults = 5 BraveMaxQueryChars = 380 // Brave LLM context endpoint. LLMContextMaxTokens = 8192 // 1024–32768 LLMContextMaxURLs = 5 // 1–50 LLMContextMaxSnippets = 20 // 1–100 LLMContextMaxTokensPerURL = 2048 // 512–8192 LLMContextMaxSnippetsPerURL = 10 // 1–100 // "strict", "balanced", "lenient", "disabled" LLMContextThresholdMode = "balanced" // Web-search query-reformulation prompt. WebSearchPrompt = "Convert the following " + "chat message into a concise web search " + "query. If documents are provided, use " + "them to add relevant context to the " + "query. Respond with ONLY the search " + "query, nothing else.\n\n" + "{{documents}}" + "Message: {{message}}" )
const DefaultMaxUploadSizeBytes = 10 * 1024 * 1024
DefaultMaxUploadSizeBytes caps document uploads (10 MiB).
const DefaultModelID = "openai/gpt-oss-120b"
DefaultModelID is the model used when a request names none or one no provider serves.
Variables ¶
var Models = map[string]ModelConfig{}
Models is populated at startup from every provider's API.
Functions ¶
func DefaultModel ¶
func DefaultModel() string
DefaultModel returns DefaultModelID when a provider serves it, else the lowest discovered model ID, or "" when no models are discovered.
func ProviderFor ¶
ProviderFor returns the client serving model, falling back to the first provider for ids we haven't indexed (legacy bare ids in old flow definitions).
func ResolveModel ¶
ResolveModel returns model when a provider serves it, else DefaultModel().
func SetActiveProviders ¶
func SetActiveProviders(provs []ProviderConfig)
SetActiveProviders replaces the live provider list and the default (first) client used for unknown/legacy model ids.
func SetModels ¶
func SetModels(entries []ModelEntry)
SetModels rebuilds the model catalog and the model→provider index from every provider's discovered models. On id collisions the first provider wins (provider order is the configured order, Groq first).
func SetPricingOverrides ¶
Types ¶
type HandlerConfig ¶
type HandlerConfig struct {
// BraveAPIKey enables the web-search node; empty disables search.
BraveAPIKey string
// CompactModel is the model used for context compaction and auto-titles.
CompactModel string
// TrustForwardedIP reads the client IP from X-Forwarded-For (only behind a
// trusted proxy).
TrustForwardedIP bool
// MaxUploadSizeBytes caps a single document upload.
MaxUploadSizeBytes int64
// FrontendShellPath is the built SPA index.html, used for per-flow meta-tag
// injection on /flow/{id}.
FrontendShellPath string
}
HandlerConfig is the engine-side configuration the shared HTTP handlers need. Wrappers build it from their own environment: hosted from its config.Config, self-host from env vars. Billing, auth secrets, and abuse limits are NOT here — they stay in each wrapper.
type ModelConfig ¶
type ModelEntry ¶
ModelEntry is one model discovered on a provider, tagged with the client that serves it.
type ProviderConfig ¶
ProviderConfig describes one OpenAI-compatible backend.
func ActiveProviders ¶
func ActiveProviders() []ProviderConfig
ActiveProviders returns a copy of the live provider list.
func (ProviderConfig) Client ¶
func (p ProviderConfig) Client() llmclient.Client
Client returns the llmclient for this provider.