lasagnastack.optimize_skill_pipeline¶
lasagnastack.optimize_skill_pipeline
¶
Three-stage pipeline that analyses human-edited CapCut drafts and produces an improved skill file.
OptimizeSkillPipeline
¶
OptimizeSkillPipeline(
optimize_client: LLMClient | None = None,
critique_client: LLMClient | None = None,
)
Bases: Pipeline
Trainset → improved skill file pipeline.
Stage 1 (IngestDraftsStage): parse every CapCut draft in the trainset folder into (CutList, ReelStyleSheet) pairs. Stage 2 (OptimizeSkillStage): call the LLM with the existing skill + examples to generate a draft improved skill file. Stage 3 (CritiqueSkillStage): iteratively critique and revise the draft skill until approved or the retry cap is reached.
Initialise the pipeline with optional per-stage LLM clients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
optimize_client
|
LLMClient | None
|
LLM client for Stage 2 (optimize). |
None
|
critique_client
|
LLMClient | None
|
LLM client for Stage 3 (critique). |
None
|
Source code in src/lasagnastack/optimize_skill_pipeline.py
run
¶
run(
state: OptimizeSkillPipelineState,
auto_confirm: bool = False,
) -> OptimizeSkillPipelineState
Run all three stages, then write the approved skill file to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
OptimizeSkillPipelineState
|
Initial pipeline state. |
required |
auto_confirm
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
OptimizeSkillPipelineState
|
Final pipeline state with |
Source code in src/lasagnastack/optimize_skill_pipeline.py
build_state
¶
build_state(
trainset_dir: Path,
output_dir: Path,
skill_path: Path | None,
critique_max_retries: int,
) -> OptimizeSkillPipelineState
Construct an OptimizeSkillPipelineState suitable for OptimizeSkillPipeline.
brief_path is set to skill_path (the skill being optimised acts as
the primary input document, which doubles as the MLflow run identifier).
When no existing skill is provided a sentinel path is used so the pipeline
can still start from scratch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trainset_dir
|
Path
|
Folder containing CapCut draft subfolders. |
required |
output_dir
|
Path
|
Where to write |
required |
skill_path
|
Path | None
|
Path to an existing skill file to improve, or |
required |
critique_max_retries
|
int
|
Maximum critique iterations. |
required |
Returns:
| Type | Description |
|---|---|
OptimizeSkillPipelineState
|
A fully initialised |