package llm import ( "net/http" "strings" "time" "gitea.maximumdirect.net/eric/audita/internal/core/config" ) // EffectiveConfig is the runtime LLM configuration consumed by adapters and // schedulers after primary/validation inheritance is resolved. type EffectiveConfig struct { APIKey string Model string BaseURL string RequestTimeout time.Duration MaxRetries int Concurrency int } // ResolvePrimaryConfig resolves the primary LLM settings into runtime form. func ResolvePrimaryConfig(cfg config.Config) EffectiveConfig { return resolveFromLLMConfig(cfg.PrimaryLLM) } // ResolveValidationConfig resolves validation LLM settings with inheritance // from primary values when validation overrides are unset. func ResolveValidationConfig(cfg config.Config) EffectiveConfig { return resolveFromLLMConfig(cfg.EffectiveValidationLLMConfig()) } // ToInstructorClientConfig converts an effective runtime config into adapter // config while keeping instructor-go types fully internal to this package. func (c EffectiveConfig) ToInstructorClientConfig(mode Mode, httpClient *http.Client) InstructorClientConfig { return InstructorClientConfig{ BaseURL: c.BaseURL, Model: c.Model, APIKey: c.APIKey, MaxRetries: c.MaxRetries, Mode: mode, HTTPClient: httpClient, RequestTimeout: c.RequestTimeout, } } func resolveFromLLMConfig(raw config.LLMConfig) EffectiveConfig { return EffectiveConfig{ APIKey: strings.TrimSpace(raw.APIKey), Model: strings.TrimSpace(raw.Model), BaseURL: strings.TrimSpace(raw.BaseURL), RequestTimeout: time.Duration(raw.TimeoutSeconds) * time.Second, MaxRetries: raw.MaxRetries, Concurrency: raw.Concurrency, } }