Skip to content

Feature/aip 002 AI price suggestion for voyage pricing - #56

Merged
hajk1 merged 18 commits into
hajk1:masterfrom
michal-bakshi:feature/AIP-002-price-suggestion
Mar 10, 2026
Merged

Feature/aip 002 AI price suggestion for voyage pricing#56
hajk1 merged 18 commits into
hajk1:masterfrom
michal-bakshi:feature/AIP-002-price-suggestion

Conversation

@michal-bakshi

Copy link
Copy Markdown
Contributor

PR: AI Price Suggestion for Voyage Pricing

Adds a GET /voyages/{voyageId}/price-suggestion?containerSize=... endpoint that returns an AI-generated USD price range, confidence level (HIGH/MEDIUM/LOW), reasoning, and optional historical stats (avg/min/max).

Key Changes

  • AI clientscompleteWithSchema implemented in ClaudeAiClient, OpenAiClient, and NoOpAiClient for structured JSON output
  • Historical data — same-route lookup via VoyagePriceRepository; fallback to similar routes via CountryRegionMapper + PortRepository
  • Schema validation — networknt json-schema-validator validates LLM output; schema built by PriceSuggestionSchemaBuilder from price-suggestion.json
  • Fallback — returns confidence=LOW with a message on missing data or AI failure
  • New repository methodscountByVoyageIds, findHistoricalPricesSameRoute, findHistoricalPricesSimilarRoute, findByCountryIn

Tests

  • VoyagePriceSuggestionControllerTest — integration tests via MockMvc covering: suggestion with historical stats, fallback to confidence=LOW when no data, 404 for unknown voyage, and correct response for FORTY_FOOT.

  • PriceSuggestionSchemaTest validates the schema itself — covers valid payloads, missing required fields, wrong confidence type, invalid enum value, and extra properties.

Verified

mvn clean verify
mvn fmt:check

Close #48

Comment thread src/main/java/com/shipping/freightops/service/PriceSuggestionService.java Outdated
Comment thread src/main/java/com/shipping/freightops/repository/FreightOrderRepository.java Outdated
Comment thread src/main/java/com/shipping/freightops/service/PriceSuggestionService.java Outdated
Comment thread src/main/java/com/shipping/freightops/prompt/PriceSuggestionPrompts.java Outdated
@hajk1
hajk1 merged commit 7146430 into hajk1:master Mar 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AIP-002 — AI Price Suggestion from Historical Data 🟠

2 participants