Added langchain4j support and API example#70
Conversation
…ration for LangChain4j integration
There was a problem hiding this comment.
Pull request overview
This PR integrates LangChain4j support into the platform, enabling AI-powered customer eligibility analysis for financial products. The implementation includes shared AI configuration infrastructure and a working example in the customer-service that uses AI agents to determine if a customer can purchase a specific financial product based on their MiFID risk profile.
Key changes:
- Added LangChain4j dependencies and Ollama chat model configuration to platform-core
- Implemented an AI agent (
CustomerInsightAgent) that analyzes customer eligibility for financial products using tool-augmented LLM calls - Created a REST endpoint (
/ai/analyze/{customerId}) demonstrating the AI agent in action
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pom.xml | Added langchain4j BOM (v0.35.0) and JUnit BOM (v6.0.1) to dependency management |
| core/platform-core/pom.xml | Added langchain4j dependencies including core, spring-boot-starter, and ollama integration |
| core/platform-core/src/main/resources/platform-shared-properties.yaml | Added Ollama configuration properties (base URL and model name) |
| core/platform-core/src/main/java/raff/stein/platformcore/ai/tool/WealthTool.java | Created custom annotation for marking AI tool methods as financially audited |
| core/platform-core/src/main/java/raff/stein/platformcore/ai/AiAgentEnabler.java | Created SPI interface for microservices to expose LangChain4j tools |
| core/platform-core/src/main/java/raff/stein/platformcore/ai/config/OllamaChatModelProperties.java | Created configuration properties record for Ollama chat model settings |
| core/platform-core/src/main/java/raff/stein/platformcore/ai/config/OllamaChatModelConfiguration.java | Created Spring configuration that builds and configures OllamaChatModel bean |
| business-modules/customer-service/customer-core/src/main/java/raff/stein/customer/model/entity/mifid/mapper/MifidFillingEntityToMifidFillingMapper.java | Added mapping for customerRiskProfile.profile field to support AI tools |
| business-modules/customer-service/customer-core/src/main/java/raff/stein/customer/ai/CustomerInsightAgent.java | Created AI agent interface with system/user prompts for customer eligibility analysis |
| business-modules/customer-service/customer-core/src/main/java/raff/stein/customer/ai/tool/CustomerComplianceTools.java | Implemented LangChain4j tools to retrieve MiFID profiles and product details |
| business-modules/customer-service/customer-core/src/main/java/raff/stein/customer/ai/tool/projection/ProductProjectionStore.java | Created in-memory product projection store with sample data for development |
| business-modules/customer-service/customer-core/src/main/java/raff/stein/customer/ai/config/CustomerAiConfiguration.java | Created Spring configuration to wire up the CustomerInsightAgent with tools |
| business-modules/customer-service/customer-core/src/main/java/raff/stein/customer/controller/AiCustomerAnalysisController.java | Created REST controller exposing the AI eligibility analysis endpoint |
| @GetMapping("/analyze/{customerId}") | ||
| public ResponseEntity<CustomerEligibilityAnalysisResponse> analyze( | ||
| @PathVariable UUID customerId, | ||
| @RequestParam String isin) { | ||
| CustomerInsightAgent.EligibilityResult eligibilityResult = customerInsightAgent.analyzeEligibility(customerId, isin); | ||
| return ResponseEntity.ok(new CustomerEligibilityAnalysisResponse(customerId, isin, eligibilityResult)); | ||
| } |
There was a problem hiding this comment.
The new REST endpoint /ai/analyze/{customerId} should be documented in the OpenAPI specification file customer-api-data.yaml as per project conventions. All REST endpoints should have corresponding OpenAPI definitions in the *-api-data module.
| @GetMapping("/analyze/{customerId}") | ||
| public ResponseEntity<CustomerEligibilityAnalysisResponse> analyze( | ||
| @PathVariable UUID customerId, | ||
| @RequestParam String isin) { |
There was a problem hiding this comment.
No description provided.