Content
# My AI Agent 🤖
## Project Introduction
My AI Agent is an intelligent agent service built based on Spring Boot and Spring AI frameworks, integrating modern large model capabilities, providing conversation memory, multi-modal interaction, and other functions. This project integrates with Alibaba Cloud's Lingji large model service to achieve intelligent human-computer interaction experience and supports knowledge base question answering 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 large model capabilities
- **Memory Persistence Module**: Realizes local file persistence of conversation state
- **Image Search Service**: Independent MCP service module
- **Knowledge Base Module**: Vector database storage and retrieval service based on PGVector
- **Intelligent Agent Module**: Realizes AI autonomous decision-making and tool calling capabilities
## Core Functions
- ✅ **Intelligent Conversation**: Accesses Alibaba Cloud Lingji model, supports natural language interaction
- ✅ **Conversation Memory**: Persistent conversation memory based on file system, maintains context continuity
- ✅ **Image Search**: Independent module supports image-based search function
- ✅ **Intelligent Agent**:
- Supports AI autonomous decision-making and task planning
- Tool calling capabilities in multi-turn conversations
- Reasoning and execution based on ReAct mode
- Flexible tool registration and usage mechanism
- ✅ **Knowledge Base Question Answering**:
- Supports Markdown document upload and management
- Intelligent question answering based on RAG technology
- Efficient vector retrieval using PGVector
- Supports document CRUD operations
## Technical 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 Lingji model access)
### Installation and Running
1. Clone the project to local
```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
├── my-image-search-mcp-server/ # Image search service module
├── .mvn/ # Maven wrapper configuration
├── pom.xml # Maven project configuration
└── README.md # Project documentation
```
## Configuration Description
Main configuration items include:
- **Chat Memory Storage Path**: Defaults to `/tmp` folder under the project root directory
- **Model Parameters**: Can adjust large model parameter settings in application configuration
- **Service Port**: Defaults to Spring Boot standard port 8080
- **Vector Database Configuration**:
- PostgreSQL connection information
- pgvector related parameter settings
## API Interface
### Health Check
```
GET /health
Response: "ok"
```
### Knowledge Base Management Interface
```
# 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 question answering
POST /api/knowledge/qa
Content-Type: application/json
{
"question": "Your question"
}
```
## Advanced Features
### File Persistence Conversation Memory
The project implements a file persistence conversation memory mechanism based on Kryo serialization, supporting session state saving and recovery, ensuring conversation continuity and context understanding.
### Intelligent Agent System
- Intelligent agent implementation based on ReAct (Reasoning and Acting) mode
- Supports autonomous decision-making and tool calling in multi-turn conversations
- Flexible tool registration mechanism, supporting dynamic expansion
- State management and execution process control
- Supports streaming output and asynchronous processing
### Image Search Service
Independent image search module adopts Spring AI MCP service architecture, providing multi-modal interaction capabilities.
### RAG Knowledge Base Question Answering
- High-performance vector storage based on PGVector
- Supports semantic retrieval and relevance ranking of documents
- Intelligent query rewriting optimizes retrieval effect
- Supports processing and vectorization of multiple document formats
## Contribution Guide
Welcome to participate in project contributions! Please follow these steps:
1. Fork this repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Submit 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 Apache License 2.0, see LICENSE file for details.
## Contact Us
If you have any questions or suggestions, please feel free to contact us through Issues or the following ways:
- Email: xzhuzhu961@gmail.com
---
Enjoy using! 🚀
Connection Info
You Might Also Like
markitdown
Python tool for converting files and office documents to Markdown.
OpenAI Whisper
OpenAI Whisper MCP Server - 基于本地 Whisper CLI 的离线语音识别与翻译,无需 API Key,支持...
oh-my-opencode
Background agents · Curated agents like oracle, librarians, frontend...
claude-flow
Claude-Flow v2.7.0 is an enterprise AI orchestration platform.
ai-engineering-from-scratch
Learn it. Build it. Ship it for others. The most comprehensive open-source...
chatbox
User-friendly Desktop Client App for AI Models/LLMs (GPT, Claude, Gemini, Ollama...)