# rag-ai **Repository Path**: 51tech/rag-ai ## Basic Information - **Project Name**: rag-ai - **Description**: 基于Spring-AI的RAG检索增强生成系统,支持文档资料库搜索的数据库自动查询两种模式。 1、底座使用ruoyi框架,springboot3和vue3版本 2、数据库使用MariaDB,支持向量搜索 3、嵌入模型使用ollama,模型可根据自己服务器性能选择,开发阶段使用deepseek-r1:7b做测试 - **Primary Language**: Java - **License**: LGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 3 - **Created**: 2026-02-06 - **Last Updated**: 2026-06-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RAG-AI Intelligent Q&A and Retrieval-Augmented Generation System ## Project Overview RAG-AI is an intelligent Q&A and Retrieval-Augmented Generation (RAG) system extended from the RuoYi framework. It integrates multiple AI capabilities to provide users with intelligent conversational interaction, data retrieval, and knowledge-based question answering services. The system adopts a frontend-backend separated architecture, supports WebSocket real-time communication, and features high efficiency and scalability. ## Main Features ### Intelligent Dialogue Engine - **RAG Engine**: Knowledge-based Q&A powered by vector-based retrieval and enhanced generation - **QA Engine**: Professional question-answering system supporting context understanding and multi-turn dialogue - **Database Engine**: Natural language to SQL conversion for intelligent database querying - **Streaming Response**: Supports SSE and WebSocket for real-time response streaming ### Knowledge Base Management - **Document Management**: Supports uploading, training, and retrieving documents in multiple formats - **Data Source Configuration**: Supports configuration of multiple database connections and table schemas - **Field Mapping**: Flexible mapping between database fields and the Q&A system - **Incremental Training**: Supports real-time updates and retraining of the knowledge base ### Dialogue Management - **Conversation History**: Saves and retrieves historical conversation records - **Context Memory**: Maintains coherence across multi-turn dialogues - **Role Configuration**: Supports expert role configurations for different scenarios - **Permission Control**: Fine-grained permission management based on the RuoYi framework ### System Monitoring - **Online Users**: Real-time monitoring of user login status - **Operation Logs**: Records user operation trails - **Service Monitoring**: Monitors server resource utilization - **Cache Management**: Monitors Redis cache status ## Technology Stack ### Backend Technologies - **Core Framework**: Spring Boot 2.7.x - **Security Framework**: Spring Security + JWT - **Caching**: Redis - **Database**: MySQL + Druid connection pool - **AI Framework**: Spring AI - **WebSocket**: Spring WebSocket - **Task Scheduling**: Quartz - **Code Generation**: MyBatis-Plus + Velocity ### Frontend Technologies - **Framework**: Vue3 + Vite - **State Management**: Pinia - **UI Components**: Element Plus - **Routing**: Vue Router - **HTTP Client**: Axios - **Rich Text Editor**: WangEditor ## Quick Start ### Environment Requirements - JDK 1.8+ - MySQL 5.7+ - Redis 3.0+ - Node.js 16.0+ ### Backend Deployment 1. **Create Database** ```sql CREATE DATABASE rag_ai DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; ``` 2. **Import SQL Script** ```bash mysql -u root -p rag_ai < sql/java_ai.sql ``` 3. **Modify Configuration Files** ```yaml # application-druid.yml spring: datasource: url: jdbc:mysql://localhost:3306/rag_ai username: your_username password: your_password redis: host: localhost port: 6379 # application.yml ai: vector-similarity: 0.7 vector-limit: 10 ``` 4. **Start Service** ```bash cd /data/skyline/skyline-repo-cache/45/0a89bed8ed1f00581f3483237f778dc016708a891d7d30222e5afd2bbef9a7 ./mvnw spring-boot:run ``` ### Frontend Deployment 1. **Install Dependencies** ```bash cd ui npm install ``` 2. **Start Development Server** ```bash npm run dev ``` 3. **Build Production Version** ```bash npm run build:prod ``` ## Access Addresses - **Backend Service**: `http://localhost:8080` - **Frontend Interface**: `http://localhost:80` - **API Documentation**: `http://localhost:8080/swagger-ui.html` ## Directory Structure ``` rag-ai/ ├── src/main/java/com/ruoyi/ │ ├── chat/ # Chat-related modules │ │ ├── common/ # Common components │ │ ├── config/ # Configuration classes │ │ ├── controller/ # Controllers │ │ ├── domain/ # Entity classes │ │ ├── engine/ # Chat engines │ │ ├── response/ # Response handlers │ │ ├── service/ # Service layer │ │ └── ws/ # WebSocket │ ├── rag/ # RAG core module │ │ ├── advisor/ # AI advisor │ │ ├── controller/ # Controllers │ │ ├── domain/ # Entity classes │ │ ├── engine/ # Engine implementations │ │ ├── mapper/ # Data mappers │ │ ├── service/ # Service layer │ │ ├── tools/ # Utility classes │ │ ├── utils/ # Utility classes │ │ └── vo/ # View objects │ └── ... # Other modules ├── ui/ # Frontend project │ ├── src/ │ │ ├── api/ # API interfaces │ │ ├── views/ # View components │ │ ├── store/ # State management │ │ └── utils/ # Utility classes │ └── ... └── sql/ # SQL scripts ``` ## API Interfaces ### Chat APIs | Endpoint | Method | Description | |----------|--------|-------------| | `/ai/chat/rag/{userId}` | GET | RAG Q&A streaming response | | `/ai/chat/qa/{userId}` | GET | QA Q&A streaming response | | `/ai/chat/db/{userId}` | GET | Database query streaming response | | `/ai/chat/stream/{userId}` | GET | General chat streaming response | ### RAG Configuration APIs | Endpoint | Method | Description | |----------|--------|-------------| | `/rag/config` | CRUD | AI configuration management | | `/rag/document` | CRUD | Document management | | `/rag/table` | CRUD | Table management | | `/rag/field` | CRUD | Field management | | `/rag/datasource` | GET | List of data sources | ## License This project is open-sourced under the MIT License.