|
1 | 1 | # Spring AI Agent |
2 | 2 |
|
3 | | -A comprehensive AI-powered agent built with Spring AI framework, featuring multimodal chat capabilities, document analysis, RAG (Retrieval-Augmented Generation), persistent memory, tool integration, and Testcontainers support for development. |
| 3 | +A comprehensive AI-powered agent built with Spring AI framework, featuring multimodal chat capabilities, document analysis, RAG (Retrieval-Augmented Generation), persistent memory, tool integration, and Model Context Protocol (MCP) client functionality. |
4 | 4 |
|
5 | | -## Related Documentation |
| 5 | +## Features |
6 | 6 |
|
7 | | -This project is part of a larger microservices ecosystem: |
| 7 | +- **Multimodal Chat Interface** - Text conversations with document upload support (PDF, JPG, JPEG, PNG) |
| 8 | +- **Persistent Memory** - JDBC-based chat memory for conversation continuity across sessions |
| 9 | +- **RAG Implementation** - Knowledge base integration using pgvector for document retrieval |
| 10 | +- **Tool Integration** - Custom function calling capabilities for extended functionality |
| 11 | +- **MCP Client** - Connects to Travel and Backoffice services via Model Context Protocol |
| 12 | +- **Multiple AI Models** - Support for Claude Sonnet 4 and Amazon Nova |
8 | 13 |
|
9 | | -- [Travel Service Documentation](../travel/README.md) - Travel booking service with hotel and flight management |
10 | | -- [Backoffice Service Documentation](../backoffice/README.md) - Expense management and currency conversion service |
11 | | - |
12 | | -## Project Overview |
13 | | - |
14 | | -### Description |
15 | | - |
16 | | -The Spring AI Agent is a demonstration of how to build modern AI-powered applications using the Spring AI framework. It provides a complete set of capabilities for interacting with AI models, including: |
17 | | - |
18 | | -- Text-based conversations with persistent memory using JDBC-based chat memory |
19 | | -- Document analysis (PDF, JPG, JPEG, PNG) with multimodal AI models |
20 | | -- Retrieval-Augmented Generation (RAG) for knowledge base integration using pgvector |
21 | | -- Tool integration for enhanced capabilities (DateTime tools) |
22 | | -- Model Context Protocol (MCP) client for connecting to external services |
23 | | -- Testcontainers integration for seamless development and testing |
24 | | - |
25 | | -The application serves as the central component in a microservices architecture, connecting to specialized services like the Travel and Backoffice applications through the Model Context Protocol (MCP). |
26 | | - |
27 | | -### Purpose |
28 | | - |
29 | | -This application serves as: |
30 | | - |
31 | | -1. A reference implementation for Spring AI integration in enterprise applications |
32 | | -2. A demonstration of key AI application patterns (RAG, memory, tools, MCP) |
33 | | -3. A practical example of building AI assistants with Spring Boot |
34 | | -4. A showcase for integrating with Amazon Bedrock and other AI services |
35 | | - |
36 | | -### Technology Stack |
37 | | - |
38 | | -- **Java 21**: Latest LTS version with modern language features |
39 | | -- **Spring Boot 3.5.7**: Core framework for building the application |
40 | | -- **Spring AI 1.0.3**: AI integration framework |
41 | | -- **Amazon Bedrock**: AI model provider (OpenAI GPT-OSS-120B, Claude Sonnet 4, Nova Pro/Premier) |
42 | | -- **PostgreSQL 16**: Database with pgvector extension for vector operations |
43 | | -- **Testcontainers 1.21.3**: Integration testing with containerized dependencies |
44 | | -- **Thymeleaf**: Server-side templating for the web interface |
45 | | -- **Docker**: Containerization for database and application |
46 | | - |
47 | | -## Getting Started |
| 14 | +## Quick Start |
48 | 15 |
|
49 | 16 | ### Prerequisites |
50 | 17 |
|
51 | | -- Java 21 or higher |
52 | | -- Maven 3.8 or higher |
| 18 | +- Java 21+ |
| 19 | +- Maven 3.8+ |
53 | 20 | - Docker (for Testcontainers) |
54 | 21 | - AWS account with Amazon Bedrock access |
55 | 22 |
|
56 | | -### Development with Testcontainers |
57 | | - |
58 | | -The application uses Testcontainers for seamless development and testing. No manual database setup is required! |
59 | | - |
60 | | -#### Prerequisites for Full Functionality |
61 | | - |
62 | | -Before starting the AI agent, ensure the dependent services are running: |
63 | | - |
64 | | -1. **Start Travel Service** (port 8081): |
65 | | - ```bash |
66 | | - cd travel/ |
67 | | - mvn spring-boot:test-run |
68 | | - ``` |
69 | | - |
70 | | -2. **Start Backoffice Service** (port 8082): |
71 | | - ```bash |
72 | | - cd backoffice/ |
73 | | - mvn spring-boot:test-run |
74 | | - ``` |
75 | | - |
76 | | -These services provide MCP tools that the AI agent can use for travel booking and expense management. |
77 | | - |
78 | | -#### Running the AI Agent |
| 23 | +### Running the Application |
79 | 24 |
|
80 | 25 | ```bash |
81 | | -cd ai-agent/ |
82 | 26 | mvn spring-boot:test-run |
83 | 27 | ``` |
84 | 28 |
|
85 | | -This will: |
86 | | -- Automatically start a PostgreSQL container with pgvector extension |
87 | | -- Initialize the `ai_agent_db` database |
88 | | -- Configure the application to use the containerized database |
89 | | -- Connect to the travel and backoffice services via MCP |
90 | | -- Start the application on port 8080 |
| 29 | +The application will start on port 8080 with automatic PostgreSQL setup via Testcontainers. |
91 | 30 |
|
92 | | -The container will be named `ai-agent-postgres` for easy identification. |
| 31 | +Access the web interface at: http://localhost:8080 |
93 | 32 |
|
94 | | -### AWS Configuration |
| 33 | +## Configuration |
95 | 34 |
|
96 | | -1. Configure AWS credentials: |
97 | | - ```bash |
98 | | - aws configure |
99 | | - ``` |
| 35 | +### AWS Bedrock Setup |
100 | 36 |
|
101 | | -2. Ensure you have access to Amazon Bedrock and the required models (Claude Sonnet 4). |
| 37 | +Configure AWS credentials and region: |
102 | 38 |
|
103 | | -### Building and Running the Application |
| 39 | +```bash |
| 40 | +aws configure |
| 41 | +export AWS_REGION=us-east-1 |
| 42 | +``` |
104 | 43 |
|
105 | | -1. **With Testcontainers (Recommended for Development):** |
106 | | - ```bash |
107 | | - cd ai-agent/ |
108 | | - mvn spring-boot:test-run |
109 | | - ``` |
| 44 | +Ensure access to required models: |
110 | 45 |
|
111 | | -2. **Traditional Build and Run:** |
112 | | - ```bash |
113 | | - cd ai-agent/ |
114 | | - mvn clean package |
115 | | - mvn spring-boot:run |
116 | | - ``` |
| 46 | +- `global.anthropic.claude-sonnet-4-20250514-v1:0` |
| 47 | +- `us.amazon.nova-pro-v1:0` (optional) |
117 | 48 |
|
118 | | -3. The application will be available at: |
119 | | - ``` |
120 | | - http://localhost:8080 |
121 | | - ``` |
| 49 | +## Architecture |
122 | 50 |
|
123 | | -## Contributing |
| 51 | +The AI Agent follows a layered architecture: |
124 | 52 |
|
125 | | -Contributions are welcome! Please feel free to submit a Pull Request. |
| 53 | +- **Web Layer** - Thymeleaf templates and REST controllers |
| 54 | +- **Service Layer** - Chat service with memory and RAG integration |
| 55 | +- **Integration Layer** - MCP client for external services |
| 56 | +- **Data Layer** - PostgreSQL with pgvector extension |
126 | 57 |
|
127 | | -## License |
| 58 | +## Technology Stack |
128 | 59 |
|
129 | | -This project is licensed under the MIT License - see the LICENSE file for details. |
| 60 | +- **Spring Boot 3.5.7** - Core framework |
| 61 | +- **Spring AI 1.0.3** - AI integration framework |
| 62 | +- **Amazon Bedrock** - AI model provider |
| 63 | +- **PostgreSQL 16** with pgvector extension |
| 64 | +- **Testcontainers 1.21.3** - Development and testing |
| 65 | +- **Thymeleaf** - Web templating engine |
0 commit comments