Skip to content

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 TaskPlan Pydantic object.
  • Requirements:
    • Defines TaskPlan with fields: title, priority (Enum), architecture_domain, steps (List of ActionableStep sub-objects), and risk_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.

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_blocks or uniform AIMessage).
    • Delivers an identical Pydantic UnifiedResponse object regardless of the underlying cloud vendor.

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 β‰₯4Γ— 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.

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 ContentModerationMiddleware that 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.

Master AI Architecture Training Program