Implemented the config source setter cleanup identified during the code audit
This commit is contained in:
@@ -205,118 +205,98 @@ func (c *Config) applyFileConfigWithLookup(fileCfg FileConfig, lookup func(strin
|
||||
|
||||
if fileCfg.LLM != nil {
|
||||
if fileCfg.LLM.Proposal != nil {
|
||||
if fileCfg.LLM.Proposal.BaseURL != nil {
|
||||
c.PrimaryLLM.BaseURL = *fileCfg.LLM.Proposal.BaseURL
|
||||
}
|
||||
if fileCfg.LLM.Proposal.Model != nil {
|
||||
c.PrimaryLLM.Model = *fileCfg.LLM.Proposal.Model
|
||||
patch := llmTargetPatch{
|
||||
model: fileCfg.LLM.Proposal.Model,
|
||||
baseURL: fileCfg.LLM.Proposal.BaseURL,
|
||||
maxRetries: fileCfg.LLM.Proposal.MaxRetries,
|
||||
}
|
||||
if fileCfg.LLM.Proposal.Timeout != nil {
|
||||
c.PrimaryLLM.TimeoutSeconds = fileCfg.LLM.Proposal.Timeout.Seconds()
|
||||
}
|
||||
if fileCfg.LLM.Proposal.MaxRetries != nil {
|
||||
c.PrimaryLLM.MaxRetries = *fileCfg.LLM.Proposal.MaxRetries
|
||||
timeoutSeconds := fileCfg.LLM.Proposal.Timeout.Seconds()
|
||||
patch.timeoutSeconds = &timeoutSeconds
|
||||
}
|
||||
if fileCfg.LLM.Proposal.APIKeyEnv != nil {
|
||||
apiKey, err := resolveAPIKeyEnv(*fileCfg.LLM.Proposal.APIKeyEnv, lookup)
|
||||
if err != nil {
|
||||
return fmt.Errorf("llm.proposal.api_key_env: %w", err)
|
||||
}
|
||||
c.PrimaryLLM.APIKey = apiKey
|
||||
patch.apiKey = &apiKey
|
||||
}
|
||||
c.applyPrimaryLLMTargetPatch(patch)
|
||||
}
|
||||
if fileCfg.LLM.Validation != nil {
|
||||
if fileCfg.LLM.Validation.BaseURL != nil {
|
||||
c.ValidationLLM.BaseURL = *fileCfg.LLM.Validation.BaseURL
|
||||
}
|
||||
if fileCfg.LLM.Validation.Model != nil {
|
||||
c.ValidationLLM.Model = *fileCfg.LLM.Validation.Model
|
||||
patch := llmTargetPatch{
|
||||
model: fileCfg.LLM.Validation.Model,
|
||||
baseURL: fileCfg.LLM.Validation.BaseURL,
|
||||
maxRetries: fileCfg.LLM.Validation.MaxRetries,
|
||||
}
|
||||
if fileCfg.LLM.Validation.Timeout != nil {
|
||||
v := fileCfg.LLM.Validation.Timeout.Seconds()
|
||||
c.ValidationLLM.TimeoutSeconds = &v
|
||||
}
|
||||
if fileCfg.LLM.Validation.MaxRetries != nil {
|
||||
v := *fileCfg.LLM.Validation.MaxRetries
|
||||
c.ValidationLLM.MaxRetries = &v
|
||||
timeoutSeconds := fileCfg.LLM.Validation.Timeout.Seconds()
|
||||
patch.timeoutSeconds = &timeoutSeconds
|
||||
}
|
||||
if fileCfg.LLM.Validation.APIKeyEnv != nil {
|
||||
apiKey, err := resolveAPIKeyEnv(*fileCfg.LLM.Validation.APIKeyEnv, lookup)
|
||||
if err != nil {
|
||||
return fmt.Errorf("llm.validation.api_key_env: %w", err)
|
||||
}
|
||||
c.ValidationLLM.APIKey = apiKey
|
||||
patch.apiKey = &apiKey
|
||||
}
|
||||
c.applyValidationLLMTargetPatch(patch)
|
||||
}
|
||||
}
|
||||
|
||||
if fileCfg.Concurrency != nil {
|
||||
if fileCfg.Concurrency.TotalLLM != nil {
|
||||
c.TotalLLMConcurrency = *fileCfg.Concurrency.TotalLLM
|
||||
}
|
||||
if fileCfg.Concurrency.ProposalLLM != nil {
|
||||
c.ProposalLLMConcurrency = *fileCfg.Concurrency.ProposalLLM
|
||||
}
|
||||
if fileCfg.Concurrency.ValidationLLM != nil {
|
||||
v := *fileCfg.Concurrency.ValidationLLM
|
||||
c.ValidationLLMConcurrency = &v
|
||||
}
|
||||
c.applyConcurrencyPatch(concurrencyPatch{
|
||||
totalLLM: fileCfg.Concurrency.TotalLLM,
|
||||
proposalLLM: fileCfg.Concurrency.ProposalLLM,
|
||||
validationLLM: fileCfg.Concurrency.ValidationLLM,
|
||||
})
|
||||
}
|
||||
|
||||
if fileCfg.Chunking != nil {
|
||||
if fileCfg.Chunking.TargetSections != nil {
|
||||
v := *fileCfg.Chunking.TargetSections
|
||||
c.TargetSections = &v
|
||||
}
|
||||
if fileCfg.Chunking.MaxSectionTokens != nil {
|
||||
c.MaxSectionTokens = *fileCfg.Chunking.MaxSectionTokens
|
||||
}
|
||||
if fileCfg.Chunking.MinSectionTokens != nil {
|
||||
c.MinSectionTokens = *fileCfg.Chunking.MinSectionTokens
|
||||
}
|
||||
c.applyChunkingPatch(chunkingPatch{
|
||||
targetSections: fileCfg.Chunking.TargetSections,
|
||||
maxSectionTokens: fileCfg.Chunking.MaxSectionTokens,
|
||||
minSectionTokens: fileCfg.Chunking.MinSectionTokens,
|
||||
})
|
||||
}
|
||||
|
||||
if fileCfg.Normalization != nil {
|
||||
patch := normalizationPatch{
|
||||
maxSegmentTokens: fileCfg.Normalization.MaxSegmentTokens,
|
||||
}
|
||||
if fileCfg.Normalization.MaxSegmentGap != nil {
|
||||
c.Normalization.MaxSegmentGap = fileCfg.Normalization.MaxSegmentGap.Seconds()
|
||||
maxSegmentGap := fileCfg.Normalization.MaxSegmentGap.Seconds()
|
||||
patch.maxSegmentGap = &maxSegmentGap
|
||||
}
|
||||
if fileCfg.Normalization.EllipsisGap != nil {
|
||||
c.Normalization.EllipsisGap = fileCfg.Normalization.EllipsisGap.Seconds()
|
||||
ellipsisGap := fileCfg.Normalization.EllipsisGap.Seconds()
|
||||
patch.ellipsisGap = &ellipsisGap
|
||||
}
|
||||
if fileCfg.Normalization.MaxSegmentDuration != nil {
|
||||
c.Normalization.MaxSegmentDuration = fileCfg.Normalization.MaxSegmentDuration.Seconds()
|
||||
}
|
||||
if fileCfg.Normalization.MaxSegmentTokens != nil {
|
||||
c.Normalization.MaxSegmentTokens = *fileCfg.Normalization.MaxSegmentTokens
|
||||
maxSegmentDuration := fileCfg.Normalization.MaxSegmentDuration.Seconds()
|
||||
patch.maxSegmentDuration = &maxSegmentDuration
|
||||
}
|
||||
c.applyNormalizationPatch(patch)
|
||||
}
|
||||
|
||||
if fileCfg.Thresholds != nil {
|
||||
if fileCfg.Thresholds.Glossary != nil {
|
||||
c.Thresholds.Glossary = *fileCfg.Thresholds.Glossary
|
||||
}
|
||||
if fileCfg.Thresholds.Homophones != nil {
|
||||
c.Thresholds.Homophones = *fileCfg.Thresholds.Homophones
|
||||
}
|
||||
if fileCfg.Thresholds.SpokenWord != nil {
|
||||
c.Thresholds.SpokenWord = *fileCfg.Thresholds.SpokenWord
|
||||
}
|
||||
if fileCfg.Thresholds.Grammar != nil {
|
||||
c.Thresholds.Grammar = *fileCfg.Thresholds.Grammar
|
||||
}
|
||||
c.applyThresholdsPatch(thresholdsPatch{
|
||||
glossary: fileCfg.Thresholds.Glossary,
|
||||
grammar: fileCfg.Thresholds.Grammar,
|
||||
homophones: fileCfg.Thresholds.Homophones,
|
||||
spokenWord: fileCfg.Thresholds.SpokenWord,
|
||||
})
|
||||
}
|
||||
|
||||
if fileCfg.Context != nil && fileCfg.Context.Description != nil {
|
||||
c.TranscriptDescription = strings.TrimSpace(*fileCfg.Context.Description)
|
||||
c.applyContextPatch(contextPatch{transcriptDescription: fileCfg.Context.Description})
|
||||
}
|
||||
|
||||
if fileCfg.Diagnostics != nil {
|
||||
if fileCfg.Diagnostics.WorkDir != nil {
|
||||
c.WorkDir = *fileCfg.Diagnostics.WorkDir
|
||||
}
|
||||
if fileCfg.Diagnostics.Retention != nil {
|
||||
c.WorkDirRetention = WorkDirRetention(*fileCfg.Diagnostics.Retention)
|
||||
}
|
||||
c.applyDiagnosticsPatch(diagnosticsPatch{
|
||||
workDir: fileCfg.Diagnostics.WorkDir,
|
||||
workDirRetention: fileCfg.Diagnostics.Retention,
|
||||
})
|
||||
}
|
||||
|
||||
c.syncLegacyConcurrencyAliases()
|
||||
|
||||
Reference in New Issue
Block a user