Content
# My AI Agent 🤖
## Project Introduction
My AI Agent is an intelligent agent service built on the Spring Boot and Spring AI frameworks, integrating modern large model capabilities to provide features such as conversation memory and multimodal interaction. This project achieves an intelligent human-computer interaction experience by integrating Alibaba Cloud's Lingji large model service and supports knowledge base question-and-answer capabilities based on RAG (Retrieval-Augmented Generation).
## System Architecture
The project adopts a modular design, mainly including:
- **Core Service Module**: Web service based on Spring Boot
- **AI Conversation Module**: Integrates Spring AI with Alibaba Cloud's large model capabilities
- **Memory Persistence Module**: Implements local file persistence of conversation states
- **Image Search Service**: Independent MCP service module
- **Knowledge Base Module**: Vector database storage and retrieval service based on PGVector
- **Intelligent Agent Module**: Implements AI autonomous decision-making and tool invocation capabilities
## Core Features
- ✅ **Intelligent Conversation**: Access to Alibaba Cloud's Lingji model, supporting natural language interaction
- ✅ **Conversation Memory**: File system-based conversation memory persistence, maintaining contextual coherence
- ✅ **Image Search**: Independent module supporting image-based search functionality
- ✅ **Intelligent Agent**:
- Supports AI autonomous decision-making and task planning
- Tool invocation capability in multi-turn conversations
- Reasoning and execution based on the ReAct model
- Flexible tool registration and usage mechanism
- ✅ **Knowledge Base Q&A**:
- Supports uploading and managing Markdown documents
- Intelligent Q&A based on RAG technology
- Efficient vector retrieval using PGVector
- Supports CRUD operations on documents
## Tech Stack
- **Backend Framework**: Spring Boot 3.4.x
- **AI Framework**: Spring AI (1.0.0-M6.x)
- **Large Model Access**:
- Alibaba Cloud DashScope SDK (2.19.1)
- Spring AI Alibaba (1.0.0-M6.1)
- Ollama integration
- **Vector Database**:
- PostgreSQL with pgvector extension
- Spring AI VectorStore integration
- **Serialization Tool**: Kryo
- **Build Tool**: Maven 3.9.9
- **Other Tools**:
- Hutool (5.8.37)
- Lombok
- **Runtime Environment**: Java 21
## Quick Start
### Environment Requirements
- JDK 21+
- Maven 3.9+
- Alibaba Cloud account and API Key (for accessing Lingji model)
### Installation and Running
1. Clone the project to your local machine
```bash
git clone https://github.com/your-username/my-ai-agent.git
cd my-ai-agent
```
2. Configure environment variables
```bash
# Alibaba Cloud API Key (required)
export ALIBABA_API_KEY=your_api_key_here
```
3. Build the project
```bash
./mvnw clean package
```
4. Run the main application
```bash
java -jar target/my-ai-agent-0.0.1-SNAPSHOT.jar
```
5. Run the image search service (optional)
```bash
cd my-image-search-mcp-server
../mvnw spring-boot:run
```
## Project Structure
```
my-ai-agent/
├── src/main/java/com/yam/myaiagent/
│ ├── chatmemory/ # Conversation memory implementation
│ ├── constant/ # Constant definitions
│ ├── controller/ # HTTP interface controllers
│ ├── service/ # Business logic services
│ └── MyAiAgentApplication.java # Application entry point
├── my-image-search-mcp-server/ # Image search service module
├── .mvn/ # Maven wrapper configuration
├── pom.xml # Maven project configuration
└── README.md # Project documentation
```
## Configuration Instructions
Main configuration items include:
- **Chat Memory Storage Path**: Defaults to the `/tmp` folder under the project root directory
- **Model Parameters**: Can be adjusted in the application configuration for large model settings
- **Service Port**: Defaults to the standard Spring Boot port 8080
- **Vector Database Configuration**:
- PostgreSQL connection information
- pgvector related parameter settings
## API Interfaces
### Health Check
```
GET /health
Response: "ok"
```
### Knowledge Base Management Interfaces
```
# Upload Document
POST /api/knowledge/upload
Content-Type: multipart/form-data
# Get Document List
GET /api/knowledge/documents
# Delete Document
DELETE /api/knowledge/documents/{documentId}
# Knowledge Base Q&A
POST /api/knowledge/qa
Content-Type: application/json
{
"question": "Your question"
}
```
## Advanced Features
### File-Persistent Conversation Memory
The project implements a file-persistent conversation memory mechanism based on Kryo serialization, supporting the saving and restoring of conversation states, ensuring coherence and contextual understanding.
### Intelligent Agent System
- Intelligent agent implementation based on the ReAct (Reasoning and Acting) model
- Supports autonomous decision-making and tool invocation in multi-turn conversations
- Flexible tool registration mechanism, supporting dynamic expansion
- State management and execution flow control
- Supports streaming output and asynchronous processing
### Image Search Service
The independent image search module adopts the Spring AI MCP service architecture, providing multimodal interaction capabilities.
### RAG Knowledge Base Q&A
- High-performance vector storage based on PGVector
- Supports semantic retrieval and relevance ranking of documents
- Intelligent query rewriting to optimize retrieval results
- Supports processing and vectorization of various document formats
## Contribution Guidelines
We welcome contributions to the project! Please follow these steps:
1. Fork this repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Create a Pull Request
## License
This project is open-sourced under the Apache License 2.0. Please see the LICENSE file for details.
## Contact Information
If you have any questions or suggestions, feel free to contact us via Issues or through the following means:
- Email: xzhuzhu961@gmail.com
---
Happy usage! 🚀
Connection Info
You Might Also Like
Fetch
Model Context Protocol Servers
semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
repomix
Repomix packages your codebase into AI-friendly formats for seamless integration.
Serena
A powerful coding agent toolkit providing semantic retrieval and editing...
Blender
BlenderMCP integrates Blender with Claude AI for enhanced 3D modeling.
pydantic-ai
GenAI Agent Framework, the Pydantic way