107 lines
3.5 KiB
Go
107 lines
3.5 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
type CLIOverrides struct {
|
|
ModulesCSV *string
|
|
OutputSchema *string
|
|
PrimaryLLMAPIKey *string
|
|
ValidationLLMAPIKey *string
|
|
PrimaryModel *string
|
|
ValidationModel *string
|
|
PrimaryBaseURL *string
|
|
ValidationBaseURL *string
|
|
PrimaryLLMTimeoutSeconds *int
|
|
TotalLLMConcurrency *int
|
|
ProposalLLMConcurrency *int
|
|
PrimaryLLMConcurrency *int
|
|
ValidationLLMTimeoutSeconds *int
|
|
MaxRetries *int
|
|
ValidationMaxRetries *int
|
|
ValidationLLMConcurrency *int
|
|
ValidationMaxPromptTokens *int
|
|
MaxSectionTokens *int
|
|
MinSectionTokens *int
|
|
TargetSections *int
|
|
GlossaryConfidenceThreshold *float64
|
|
GrammarConfidenceThreshold *float64
|
|
HomophonesConfidenceThreshold *float64
|
|
SpokenWordConfidenceThreshold *float64
|
|
NormalizeMaxSegmentGap *float64
|
|
NormalizeEllipsisGap *float64
|
|
NormalizeMaxSegmentDuration *float64
|
|
NormalizeMaxSegmentTokens *int
|
|
TranscriptDescription *string
|
|
WorkDir *string
|
|
WorkDirRetention *string
|
|
}
|
|
|
|
func (c *Config) ApplyCLIOverrides(overrides CLIOverrides) error {
|
|
if overrides.ModulesCSV != nil {
|
|
modules, err := ParseModulesCSV(*overrides.ModulesCSV)
|
|
if err != nil {
|
|
return fmt.Errorf("--modules: %w", err)
|
|
}
|
|
c.Modules = modules
|
|
}
|
|
if overrides.OutputSchema != nil {
|
|
c.OutputSchema = strings.TrimSpace(*overrides.OutputSchema)
|
|
}
|
|
|
|
c.applyPrimaryLLMTargetPatch(llmTargetPatch{
|
|
apiKey: overrides.PrimaryLLMAPIKey,
|
|
model: overrides.PrimaryModel,
|
|
baseURL: overrides.PrimaryBaseURL,
|
|
timeoutSeconds: overrides.PrimaryLLMTimeoutSeconds,
|
|
maxRetries: overrides.MaxRetries,
|
|
})
|
|
c.applyValidationLLMTargetPatch(llmTargetPatch{
|
|
apiKey: overrides.ValidationLLMAPIKey,
|
|
model: overrides.ValidationModel,
|
|
baseURL: overrides.ValidationBaseURL,
|
|
timeoutSeconds: overrides.ValidationLLMTimeoutSeconds,
|
|
maxRetries: overrides.ValidationMaxRetries,
|
|
})
|
|
c.applyConcurrencyPatch(concurrencyPatch{
|
|
totalLLM: overrides.TotalLLMConcurrency,
|
|
legacyTotalLLM: overrides.PrimaryLLMConcurrency,
|
|
proposalLLM: overrides.ProposalLLMConcurrency,
|
|
validationLLM: overrides.ValidationLLMConcurrency,
|
|
inheritProposal: true,
|
|
allowLegacyAlias: true,
|
|
})
|
|
|
|
if overrides.ValidationMaxPromptTokens != nil {
|
|
c.ValidationMaxPromptTokens = *overrides.ValidationMaxPromptTokens
|
|
}
|
|
c.applyChunkingPatch(chunkingPatch{
|
|
targetSections: overrides.TargetSections,
|
|
maxSectionTokens: overrides.MaxSectionTokens,
|
|
minSectionTokens: overrides.MinSectionTokens,
|
|
})
|
|
c.applyThresholdsPatch(thresholdsPatch{
|
|
glossary: overrides.GlossaryConfidenceThreshold,
|
|
grammar: overrides.GrammarConfidenceThreshold,
|
|
homophones: overrides.HomophonesConfidenceThreshold,
|
|
spokenWord: overrides.SpokenWordConfidenceThreshold,
|
|
})
|
|
c.applyNormalizationPatch(normalizationPatch{
|
|
maxSegmentGap: overrides.NormalizeMaxSegmentGap,
|
|
ellipsisGap: overrides.NormalizeEllipsisGap,
|
|
maxSegmentDuration: overrides.NormalizeMaxSegmentDuration,
|
|
maxSegmentTokens: overrides.NormalizeMaxSegmentTokens,
|
|
})
|
|
c.applyContextPatch(contextPatch{transcriptDescription: overrides.TranscriptDescription})
|
|
c.applyDiagnosticsPatch(diagnosticsPatch{
|
|
workDir: overrides.WorkDir,
|
|
workDirRetention: overrides.WorkDirRetention,
|
|
})
|
|
|
|
c.syncLegacyConcurrencyAliases()
|
|
|
|
return c.Validate()
|
|
}
|