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>
3.0 KiB
3.0 KiB
1. Replace Shared Models
- 1.1 Create
TradeItem.csin Shared/Models with fields:Valuedate(string),Counterparty(string),LegalEntity(string?),TradeId(long),DisplayCcy(string),Pv(double),Breakclause(string). Add[JsonPropertyName]attributes for snake_case serialization. - 1.2 Create
ExtractionResult.csin Shared/Models withList<TradeItem> Itemsproperty - 1.3 Delete the old
ExtractedFields.cs - 1.4 Update
ValidationResult.csto support candidate lists — addList<CandidateMatch>? Candidatesproperty for disambiguation results (each withNameandLegalEntityfields)
2. Configure External API HttpClients
- 2.1 Add
ExternalApissection toappsettings.jsonwith base URLs for counterparty, trade, and currency APIs - 2.2 Create typed HttpClient service
CounterpartyApiClientwithLookupAsync(string name)method returning candidate tuples - 2.3 Create typed HttpClient service
TradeApiClientwithValidateAsync(long tradeId)method - 2.4 Create typed HttpClient service
CurrencyApiClientwithValidateAsync(string currencyCode)method - 2.5 Register all typed HttpClients in
Program.csviaAddHttpClient<T>()with base URLs from configuration
3. Rewrite ExtractionPlugin
- 3.1 Replace
ExtractionPlugin.ValidateExtractedFields()withLookupCounterparty(string name)— callsCounterpartyApiClient, returns candidate list as JSON. Include[KernelFunction]and[Description]attributes explaining the tool returns candidates for disambiguation. - 3.2 Add
ValidateTrade(long tradeId)method — callsTradeApiClient, returns valid/invalid result as JSON - 3.3 Add
ValidateCurrency(string currencyCode)method — callsCurrencyApiClient, returns valid/invalid result as JSON - 3.4 Add
ValidateSchema(string extractionResultJson)method — validates the full ExtractionResult JSON against TradeItem schema locally (required fields present, correct types, breakclause is Y or N) - 3.5 Inject typed HttpClients into ExtractionPlugin via constructor. Register ExtractionPlugin in DI with its dependencies.
- 3.6 Add error handling in each tool method — catch
HttpRequestException, return structured error JSON instead of throwing
4. Update Controller
- 4.1 Update
ChatController.Post()— no changes needed, DI resolution via GetRequiredService works with scoped registration to use the newExtractionPluginconstructor (pass DI-resolved instance with HttpClients)
5. Update Tests
- 5.1 Remove or rewrite tests referencing old
ExtractedFieldsschema - 5.2 Add unit tests for
ValidateSchemamethod against TradeItem (valid, missing fields, wrong types) - 5.3 Add unit tests for ExtractionPlugin tool methods with mocked HttpClients (success, error, multi-candidate responses)
6. Build and Verify
- 6.1 Build the solution (
dotnet build) and confirm no compilation errors - 6.2 Run all tests (
dotnet test) and confirm they pass