Resolve producer modes turn allowances cache controls and shared workers
This commit is contained in:
@@ -112,36 +112,14 @@ func newLoadedConfig(result *configkit.Result[Document]) (*LoadedConfig, error)
|
||||
func documentToConfig(document Document) (Config, error) {
|
||||
config := Default()
|
||||
config.Pipelines = documentPipelinesToRuntime(document.Pipelines)
|
||||
if document.Concurrency != nil {
|
||||
config.Concurrency.StageWorkers = documentIntMap(document.Concurrency.StageWorkers)
|
||||
if document.Concurrency.TotalLLM != nil {
|
||||
config.Concurrency.TotalLLM = *document.Concurrency.TotalLLM
|
||||
}
|
||||
if document.Concurrency != nil && document.Concurrency.Workers != nil {
|
||||
config.Concurrency.Workers = *document.Concurrency.Workers
|
||||
}
|
||||
if document.Output != nil && document.Output.Directory != nil {
|
||||
config.Output.Directory = *document.Output.Directory
|
||||
}
|
||||
if document.Cache != nil {
|
||||
if document.Cache.ChunkPlans != nil {
|
||||
if document.Cache.ChunkPlans.Directory != nil {
|
||||
config.Cache.ChunkPlans.Directory = *document.Cache.ChunkPlans.Directory
|
||||
}
|
||||
if document.Cache.ChunkPlans.Mode != nil {
|
||||
mode, err := pipeline.ParseChunkCacheMode(*document.Cache.ChunkPlans.Mode)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("convert chunk-plan cache mode: %w", err)
|
||||
}
|
||||
config.Cache.ChunkPlans.Mode = mode
|
||||
}
|
||||
}
|
||||
if document.Cache.Checkpoints != nil {
|
||||
if document.Cache.Checkpoints.Enabled != nil {
|
||||
config.Cache.Checkpoints.Enabled = *document.Cache.Checkpoints.Enabled
|
||||
}
|
||||
if document.Cache.Checkpoints.Directory != nil {
|
||||
config.Cache.Checkpoints.Directory = *document.Cache.Checkpoints.Directory
|
||||
}
|
||||
}
|
||||
if document.CacheDirectory != nil {
|
||||
config.CacheDirectory = *document.CacheDirectory
|
||||
}
|
||||
if document.Debug != nil && document.Debug.Directory != nil {
|
||||
config.Debug.Directory = *document.Debug.Directory
|
||||
@@ -162,12 +140,13 @@ func documentPipelinesToRuntime(documents map[string]PipelineDocument) map[strin
|
||||
|
||||
func documentPipelineToRuntime(id string, document PipelineDocument) pipeline.PipelineProfile {
|
||||
profile := pipeline.PipelineProfile{
|
||||
ID: id,
|
||||
StructuredOutputRepairAttempts: cloneDocumentInt(document.StructuredOutputRepairAttempts),
|
||||
ValidationPolicy: documentPolicyToRuntime(document.ValidationPolicy),
|
||||
Input: documentBindingToRuntime(document.Input),
|
||||
Artifacts: documentLanesToRuntime(document.Artifacts),
|
||||
References: documentReferencesToRuntime(document.References),
|
||||
Mode: cloneValue(document.Mode),
|
||||
MaxAdditionalTurns: cloneValue(document.MaxAdditionalTurns),
|
||||
Cache: cloneValue(document.Cache),
|
||||
ID: id,
|
||||
Input: documentBindingToRuntime(document.Input),
|
||||
Artifacts: documentLanesToRuntime(document.Artifacts),
|
||||
References: documentReferencesToRuntime(document.References),
|
||||
}
|
||||
if document.LLMProfile != nil {
|
||||
profile.LLMProfile = *document.LLMProfile
|
||||
@@ -220,12 +199,12 @@ func documentLanesToRuntime(documents map[string]ArtifactLaneDocument) map[strin
|
||||
|
||||
func documentBindingToRuntime(document BindingDocument) pipeline.ModuleBinding {
|
||||
binding := pipeline.ModuleBinding{
|
||||
Module: document.Module,
|
||||
StructuredOutputRepairAttempts: cloneDocumentInt(document.StructuredOutputRepairAttempts),
|
||||
ValidationPolicy: documentPolicyToRuntime(document.ValidationPolicy),
|
||||
Retries: document.Retries,
|
||||
Options: documentOptions(document.Options),
|
||||
References: documentReferencesToRuntime(document.References),
|
||||
Mode: cloneValue(document.Mode),
|
||||
MaxAdditionalTurns: cloneValue(document.MaxAdditionalTurns),
|
||||
Cache: cloneValue(document.Cache),
|
||||
Module: document.Module,
|
||||
Options: documentOptions(document.Options),
|
||||
References: documentReferencesToRuntime(document.References),
|
||||
}
|
||||
if document.LLMProfile != nil {
|
||||
binding.LLMProfile = *document.LLMProfile
|
||||
@@ -242,10 +221,8 @@ func documentBindingToRuntime(document BindingDocument) pipeline.ModuleBinding {
|
||||
|
||||
func documentValidatorToRuntime(document ValidatorDocument) pipeline.ModuleBinding {
|
||||
binding := pipeline.ModuleBinding{
|
||||
Module: document.Module,
|
||||
StructuredOutputRepairAttempts: cloneDocumentInt(document.StructuredOutputRepairAttempts),
|
||||
Retries: document.Retries,
|
||||
Options: documentOptions(document.Options),
|
||||
Module: document.Module,
|
||||
Options: documentOptions(document.Options),
|
||||
}
|
||||
if document.LLMProfile != nil {
|
||||
binding.LLMProfile = *document.LLMProfile
|
||||
@@ -270,45 +247,6 @@ func documentReferencesToRuntime(documents map[string]ReferenceDocument) map[str
|
||||
return references
|
||||
}
|
||||
|
||||
func documentPolicyToRuntime(document *ValidationPolicyDocument) *pipeline.ValidationPolicyOverride {
|
||||
if document == nil {
|
||||
return nil
|
||||
}
|
||||
policy := pipeline.ValidationPolicyOverride{}
|
||||
if document.ProducerStructuralFailure != nil {
|
||||
value := *document.ProducerStructuralFailure
|
||||
policy.ProducerStructuralFailure = &value
|
||||
}
|
||||
if document.SemanticRejection != nil {
|
||||
value := *document.SemanticRejection
|
||||
policy.SemanticRejection = &value
|
||||
}
|
||||
if document.ValidatorFailure != nil {
|
||||
value := *document.ValidatorFailure
|
||||
policy.ValidatorFailure = &value
|
||||
}
|
||||
return &policy
|
||||
}
|
||||
|
||||
func documentIntMap(values map[string]int) map[string]int {
|
||||
if values == nil {
|
||||
return nil
|
||||
}
|
||||
result := make(map[string]int, len(values))
|
||||
for key, value := range values {
|
||||
result[key] = value
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func cloneDocumentInt(value *int) *int {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
result := *value
|
||||
return &result
|
||||
}
|
||||
|
||||
func documentOptions(values map[string]any) map[string]any {
|
||||
if values == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user