Appearance
Phase 3 Lab Guide: Building the Deliverables β
Curriculum Source:
docs/plan/03_phase3_modular_chaining_lcel.md
Evaluation Skill:lab-evaluator
π― Required Deliverables Specification β
When you are ready to write the code for Phase 3, you will implement the following 5 deliverables:
1. The Schema-Enforced Extractor β
- Objective: Build an LCEL chain that parses unstructured meeting or design notes into a validated
TaskPlanPydantic object. - Requirements:
- Defines
TaskPlanwith fields:title,priority(Enum),architecture_domain,steps(List ofActionableStepsub-objects), andrisk_summary. - Configures
ConfigDict(frozen=True, extra="forbid"). - Binds the schema to the model using
.with_structured_output(TaskPlan). - Verified with automated tests asserting type and field constraints.
- Defines
2. The Multi-Provider Pipeline β
- Objective: Construct a model factory and LCEL chain capable of swapping model providers (e.g. OpenAI
Anthropic Claude) without breaking downstream UI contracts. - Requirements:
- Implements a unified factory returning
BaseChatModel. - Interacts with model outputs using normalized content attributes (
.content_blocksor uniformAIMessage). - Delivers an identical Pydantic
UnifiedResponseobject regardless of the underlying cloud vendor.
- Implements a unified factory returning
3. The High-Efficiency Batch Processor β
- Objective: Demonstrate production efficiency by executing a dataset of 50+ entries through an LCEL chain using
.batch(). - Requirements:
- Prepares a dataset of at least 50 distinct architectural queries or support tickets.
- Executes the batch with configurable concurrency (
max_concurrency=10). - Measures total wall-clock duration and proves
throughput speedup compared to sequential iteration.
4. The Self-Healing Chain β
- Objective: Build a robust, fault-tolerant workflow that automatically recovers from provider outages or timeouts.
- Requirements:
- Configures
.with_retry(stop_after_attempt=2, wait_exponential_jitter=True)on the primary model for transient rate limits. - Attaches
.with_fallbacks([backup_chain])to seamlessly fail over to an alternate model provider if the primary call fails or exceeds SLA timeouts. - Verified by simulating a failure on the primary model and capturing the trace evidence in LangFuse.
- Configures
5. The Secure Schema Validator β
- Objective: Construct a production-grade extraction pipeline featuring active defense against toxic content and PII leakage.
- Requirements:
- Implements an inbound
ContentModerationMiddlewarethat intercepts and blocks toxic/harmful prompts before model execution. - Implements Pydantic field validators with regex checks that immediately raise validation errors if the output contains emails, SSNs, or raw API credential tokens.
- Verified by red-teaming tests proving that toxic prompts are blocked and data leaks are neutralized.
- Implements an inbound