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.5 KiB
Purpose
Define the extraction-specific API endpoint — request/response contract, few-shot ChatHistory integration, and tool isolation from the general chat endpoint.
Requirements
Requirement: Extraction API endpoint
The API SHALL expose POST /api/chat/extract that accepts an ExtractionRequest containing the email HTML content and optional follow-up conversation messages. The endpoint SHALL use the few-shot ChatHistory prefix (not the user-editable system prompt) and load extraction-specific SK plugins.
Scenario: Initial extraction request
- WHEN the client sends a POST to
/api/chat/extractwith email HTML and no follow-up messages - THEN the API assembles the few-shot ChatHistory, appends the email as the final user message, and streams the extraction response via SSE
Scenario: Follow-up disambiguation request
- WHEN the client sends a POST to
/api/chat/extractwith email HTML and follow-up messages (e.g., user selecting a counterparty) - THEN the API assembles the few-shot ChatHistory, appends the email, appends all follow-up messages, and streams the continuation response via SSE
Scenario: SSE streaming contract
- WHEN the extraction endpoint streams a response
- THEN it uses the same SSE format as
/api/chat:data: {"text":"..."}\n\nfor deltas anddata: [DONE]\n\nfor completion
Requirement: ExtractionRequest DTO
The system SHALL define an ExtractionRequest class with EmailHtml (string, required) and Messages (List, optional) for follow-up conversation context.
Scenario: First request has email only
- WHEN the user uploads an email for the first time
- THEN the ExtractionRequest contains
EmailHtmlwith the email content and an emptyMessageslist
Scenario: Follow-up request includes conversation
- WHEN the user replies to a disambiguation question
- THEN the ExtractionRequest contains the original
EmailHtmlplusMessageswith the full assistant/user exchange since the extraction started
Requirement: Extraction endpoint uses extraction tools only
The extraction endpoint SHALL import only the extraction-specific SK plugins (counterparty lookup, trade validation, currency validation, schema validation). General chat tools (if any) SHALL NOT be loaded for extraction requests.
Scenario: Tool isolation
- WHEN the extraction endpoint processes a request
- THEN only extraction-related KernelFunctions are available to the LLM