## 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/extract` with 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/extract` with 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\n` for deltas and `data: [DONE]\n\n` for 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 `EmailHtml` with the email content and an empty `Messages` list #### Scenario: Follow-up request includes conversation - **WHEN** the user replies to a disambiguation question - **THEN** the ExtractionRequest contains the original `EmailHtml` plus `Messages` with 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