Overhaul extraction pipeline with new TradeItem model, conversation flow, and dedicated extraction endpoint. Add sidebar navigation with NavMenu component and landing page. Introduce few-shot prompting service and tests. Add prompt settings and email upload specs. Update OpenSpec tooling with improved export-spec and extract-feature commands. Archive completed changes and export full specs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2.6 KiB
Why
The extraction agent needs few-shot examples to reliably produce correct structured output from sales emails. Without examples, the agent relies entirely on the instruction template and tool descriptions, which cannot fully convey the implicit mapping conventions (date parsing from "OB" prefix, flattening swap legs, currency symbol mapping, breakclause defaults). A curated set of 3-5 input/output examples injected as conversation turns in the ChatHistory dramatically improves extraction accuracy. The remaining ~95 available examples serve as an evaluation set for offline quality testing.
Additionally, the extraction workflow needs a dedicated API endpoint separate from general chat, since it uses a different system prompt, different tools, and the few-shot ChatHistory prefix.
What Changes
- Create examples folder structure at
examples/extraction/few-shot/with numbered subdirectories, each containinginput.html(email) andoutput.json(expected ExtractionResult) - Create extraction instruction template — a fixed system prompt defining the extraction task, schema, and mapping rules (separate from the user-editable system prompt)
- Create a FewShotService that loads examples from disk at startup and pre-assembles a ChatHistory prefix (system message + alternating user/assistant turns)
- Add
POST /api/chat/extractendpoint that uses the few-shot ChatHistory, appends the real email, and streams the extraction response via SSE - Create
ExtractionRequestDTO for the extraction endpoint (email content + optional follow-up messages for disambiguation) - Update client
ChatApiClientwith a method for the extraction endpoint
Capabilities
New Capabilities
few-shot-prompting: Defines the example folder structure, loading mechanism, ChatHistory assembly, and instruction template for few-shot extraction promptingextraction-endpoint: Defines the dedicated extraction API endpoint, its request/response contract, and how it differs from the general chat endpoint
Modified Capabilities
chat-streaming: Add the extraction endpoint alongside the existing chat endpoint, sharing the same SSE streaming contract
Impact
- New files: examples folder, FewShotService, instruction template, ExtractionRequest DTO, extraction controller action
- Configuration: example folder path in appsettings.json
- API surface: new
POST /api/chat/extractendpoint - Client: new method on ChatApiClient (no UI changes — that's the email-upload-ux change)
- Depends on:
update-extraction-schema(needs TradeItem schema for examples and validation tools)