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 to provide features such as dialogue memory and multimodal interaction. This project integrates the Alibaba Cloud Lingjun large model service to achieve an 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 Dialogue Module**: Integrates Spring AI and Alibaba Cloud large model capabilities
- **Memory Persistence Module**: Implements local file persistence of session state
- **Image Search Service**: Independent MCP Server module
- **Knowledge Base Module**: Vector database storage and retrieval service based on PGVector
- **Intelligent Agent Module**: Implements AI autonomous decision-making and tool calling capabilities
## Core Features
- ✅ **Intelligent Dialogue**: Access to Alibaba Cloud Lingjun model, supporting natural language interaction
- ✅ **Dialogue Memory**: Session memory persistence based on the file system, maintaining context coherence
- ✅ **Image Search**: Independent module supports image-based search functions
- ✅ **Intelligent Agent**:
- Supports AI autonomous decision-making and task planning
- Tool calling capabilities in multi-turn dialogues
- Reasoning and execution based on the ReAct pattern
- Flexible tool registration and usage mechanism
- ✅ **Knowledge Base Question Answering**:
- Supports Markdown document uploading and management
- Intelligent question answering based on RAG technology
- Uses PGVector for efficient vector retrieval
- Supports CRUD operations for documents
## Technology 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 Lingjun model access)
### 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/ # Dialogue 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
The main configuration items include:
- **Chat memory storage path**: Defaults to the `/tmp` folder in the project root directory
- **Model parameters**: You can adjust the parameter settings of the large model in the application configuration
- **Service port**: Defaults to the Spring Boot standard port 8080
- **Vector database configuration**:
- PostgreSQL connection information
- pgvector related parameter settings
## API Interfaces
### 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 Dialogue Memory
The project implements a file persistence dialogue memory mechanism based on Kryo serialization, supporting the saving and restoring of session states, ensuring dialogue coherence and contextual understanding.
### Intelligent Agent System
- Intelligent agent implementation based on the ReAct (Reasoning and Acting) pattern
- Supports autonomous decision-making and tool calling in multi-turn dialogues
- 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 Question Answering
- High-performance vector storage based on PGVector
- Supports semantic retrieval and relevance ranking of documents
- Intelligent query rewriting optimizes retrieval results
- Supports processing and vectorization of various 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. 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, please feel free to contact us through Issues or the following methods:
- Email: xzhuzhu961@gmail.com
---
Enjoy your use! 🚀
Connection Info
You Might Also Like
markitdown
Python tool for converting files and office documents to Markdown.
Fetch
Retrieve and process content from web pages by converting HTML into markdown format.
chatbox
User-friendly Desktop Client App for AI Models/LLMs (GPT, Claude, Gemini, Ollama...)
mcp_connect
MCPOmni Connect is a versatile command-line interface (CLI) client designed...
mcp_omni_connect
OmniCoreAgent: A Python framework for building autonomous AI agents that...
vulnerable-mcp-servers-lab
A lab for security training on intentionally vulnerable MCP servers.