feat: Complete Freight Quote Agent Pipeline#1
Open
0xsaltylollipop wants to merge 10 commits intomainfrom
Open
Conversation
Design for Step 1+2 of freight agent pipeline: - GPT-powered email extraction - Schema for shipments (sea/air) - Multi-route handling - Missing field detection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- models.py: Dataclasses for Email, Shipment, ExtractionResult - extraction.py: GPT extraction with structured output - test_extraction.py: Tests against all 10 hackathon emails Key extraction rules: - Multi-route detection (email with multiple destinations) - Mode inference: sea vs air based on context - Volume without weight = sea (container inference) - Volume + weight = air (volume weight calc) - Keeps locations raw for later normalization All 10 test emails pass. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ing) Design for completing the freight quote pipeline: - Step 5: Rate lookup with auto-detect for easy/medium/hard Excel formats - Step 6: Quote calculation with discounts, margins, surcharges - Step 7: GPT-generated response formatting for natural email replies Key decisions: - Structured Quote dataclass output (not raw email string) - Support all 3 rate sheet difficulty levels - Graceful degradation for missing rates - Total 3 GPT calls (optimized from 5+) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…rmatting Implements Steps 5-7 of the freight quote agent: - Rate Lookup (Step 5): - Auto-detect Excel format (easy/medium/hard) - Parse all 3 formats into unified NormalizedRates - Fuzzy matching with built-in port aliases - Location cleaning to handle extraction artifacts - Quote Calculator (Step 6): - Deterministic pricing math - Support for discounts, margins, surcharges - Air freight chargeable weight calculation - Response Formatter (Step 7): - GPT-powered natural email generation - Professional tone matching - Pipeline Orchestrator: - Chains all 7 steps together - 3 GPT calls total (optimized from 5+) - E2E Test Suite: - Tests all 10 emails against expected solutions - 100% pass rate achieved Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ct parsing Addresses issues from code review: 1. GPT tool call safeguard (enrichment.py) - Track validated shipment indices - Force tool call if any shipments missed validation - Prevents unvalidated shipments slipping through 2. Volume discount uses total containers (quote_calculator.py) - Calculate total containers across ALL routes first - Pass total to discount calculation - Fixes AutoSpares SOP: "total containers across all routes" 3. Check subject line for mode (extraction.py) - Explicitly tell GPT to check email subject - Add examples: "Air Freight Quote" -> air mode - Improves mode inference reliability 4. New test: test_email02_hard.py - Tests TechParts air freight with hard rate sheet - Uses REAL SOP enrichment (not mock) - Validates full pipeline with customer rules Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… feature/freight-agent-v2
- Add Flask REST API (api.py) with /quote and /quote/file endpoints - Add ngrok runner for exposing local API to internet - Enhance enrichment with improved tool calling and validation - Add streaming response formatter for better UX - Expand models with confidence scoring and display flags - Improve quote calculator with volume discounts and surcharges - Update pipeline with sync and streaming modes - Update tests for hard email scenarios Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This guide provides step-by-step instructions for merging both implementations: - Explains WHY we're integrating (complementary strengths) - Creates shared models package for type safety - Uses adapter pattern for minimal code changes - Preserves all existing tests - Combines confidence scoring with HITL workflow Designed to be followed by a Codex agent or team member. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds Step 0 with clear branch strategy: 1. Create new branch from main 2. Merge feature/freight-agent-v2 into it 3. Follow integration steps 4. Open PR to main when complete This makes the workflow cleaner and safer for the Codex agent. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add local_sop.py with ground truth SOPs from SOP.md - Implement hybrid enrichment: local SOP first, Qontext for comparison - Skip Qontext for unknown customers (saves API calls) - Use local for destination surcharges (Qontext semantic matching unreliable) - Fix Australia surcharge to only apply to actual Australia destinations - Fix origin normalization (HCMC, Saigon variants) - Fix AutoSpares volume discount tiers format - Add generate_solutions.py for fast solution regeneration - Update response_formatter with validation error handling - All 10 e2e tests pass (100%) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete implementation of the Freight Rate Quotation Agent for the hackathon challenge. Processes customer emails, looks up rates from Excel sheets, applies customer SOPs, and generates professional quote responses.
Pipeline Overview (3 GPT calls total)
Key Features
Files Changed
src/extraction.py- Email parsing with subject line mode inferencesrc/enrichment.py- Qontext + GPT enrichment with validation safeguardsrc/rate_lookup/- Multi-format Excel parser with fuzzy matchingsrc/quote_calculator.py- Pricing math with SOP rulessrc/response_formatter.py- GPT-powered email generationsrc/pipeline.py- Orchestrates all stepstests/- E2E tests against expected solutionsTest plan
test_e2e_pipeline.py- 100% pass rate (10/10 emails)test_email02_hard.py- Tests hard rate sheet + real SOP enrichment🤖 Generated with Claude Code