Share configuration settings across the public boundary

This commit is contained in:
2026-11-21 14:15:14 +00:00
parent 38a2dcca52
commit 76c8789e65
7 changed files with 310 additions and 131 deletions

View File

@@ -13,103 +13,22 @@ import (
"go.maximumdirect.net/promptkit/internal/domain"
"go.maximumdirect.net/promptkit/internal/jsonvalue"
"go.maximumdirect.net/promptkit/internal/llm"
"go.maximumdirect.net/promptkit/internal/settings"
)
type document struct {
Version *string `yaml:"version"`
SchemaRoot *string `yaml:"schema_root"`
Backends []backendConfig `yaml:"backends"`
Profiles []profileConfig `yaml:"profiles"`
Prompts []promptConfig `yaml:"prompts"`
Collections map[string]collectionConfig `yaml:"collections"`
Version *string `yaml:"version"`
settings.Settings `yaml:",inline"`
}
type collectionConfig struct {
ReleaseVersion *string `yaml:"release_version"`
SchemaRoot *string `yaml:"schema_root"`
Backends []backendConfig `yaml:"backends"`
Profiles []profileConfig `yaml:"profiles"`
Prompts []promptConfig `yaml:"prompts"`
}
type backendConfig struct {
ID string `yaml:"id"`
Endpoint *string `yaml:"endpoint"`
APIKeyEnv *string `yaml:"api_key_env"`
ConcurrencyLimit *int `yaml:"concurrency_limit"`
QueueCapacity *int `yaml:"queue_capacity"`
ExtraParams map[string]any `yaml:"extra_params"`
SmokeTests *backendSmokeTestConfig `yaml:"smoke_tests"`
}
type backendSmokeTestConfig struct {
DefaultProfile *string `yaml:"default_profile"`
Reachability *reachabilityProbeConfig `yaml:"reachability"`
Authentication *authenticationProbeConfig `yaml:"authentication"`
}
type reachabilityProbeConfig struct {
Endpoint *string `yaml:"endpoint"`
}
type authenticationProbeConfig struct {
Kind *string `yaml:"kind"`
Endpoint *string `yaml:"endpoint"`
}
type profileConfig struct {
ID string `yaml:"id"`
Backend *string `yaml:"backend"`
Endpoint *string `yaml:"endpoint"`
Model *string `yaml:"model"`
Temperature *float64 `yaml:"temperature"`
TopP *float64 `yaml:"top_p"`
MaxTokens *int `yaml:"max_tokens"`
TimeoutSeconds *int `yaml:"timeout_seconds"`
ServiceTier *string `yaml:"service_tier"`
ReasoningEffort *string `yaml:"reasoning_effort"`
APIKeyEnv *string `yaml:"api_key_env"`
APIKeyRequired *bool `yaml:"api_key_required"`
ExtraParams map[string]any `yaml:"extra_params"`
}
type promptConfig struct {
ID string `yaml:"id"`
DefaultProfile *string `yaml:"default_profile"`
Description *string `yaml:"description"`
SessionID *string `yaml:"session_id"`
Inputs []promptInputConfig `yaml:"inputs"`
Messages []promptMessageConfig `yaml:"messages"`
Output *promptOutputConfig `yaml:"output"`
}
type promptInputConfig struct {
Name string `yaml:"name"`
Required bool `yaml:"required"`
ContentType *string `yaml:"content_type"`
Description *string `yaml:"description"`
}
type promptMessageConfig struct {
Role *string `yaml:"role"`
Content *string `yaml:"content"`
ContentFile *string `yaml:"content_file"`
CacheControl *cacheControlConfig `yaml:"cache_control"`
}
type cacheControlConfig struct {
Type *string `yaml:"type"`
TTL *string `yaml:"ttl"`
}
type promptOutputConfig struct {
Format *string `yaml:"format"`
ValidationMode *string `yaml:"validation_mode"`
Schema any `yaml:"schema"`
SchemaFile *string `yaml:"schema_file"`
SchemaPath *string `yaml:"schema_path"`
RepairAttempts *int `yaml:"repair_attempts"`
}
type collectionConfig = settings.CollectionSettings
type backendConfig = settings.BackendSettings
type profileConfig = settings.ProfileSettings
type promptConfig = settings.PromptSettings
type promptInputConfig = settings.PromptInputSettings
type promptMessageConfig = settings.PromptMessageSettings
type cacheControlConfig = settings.PromptCacheControlSettings
type promptOutputConfig = settings.PromptOutputSettings
// fieldState distinguishes omission, an explicit value, and an explicit null.
// Inherited values are explicit because ConfigKit has already expanded them.