# pictureAlgorithmAgentBackend **Repository Path**: yeyu8866/picture-algorithm-agent-backend ## Basic Information - **Project Name**: pictureAlgorithmAgentBackend - **Description**: 图像算法智能体——springboot后端部分 - **Primary Language**: Unknown - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-19 - **Last Updated**: 2026-04-02 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AI 图像处理系统 - 后端项目 基于 Spring Boot 3 + LangChain4J + MyBatis Plus 的 AI 图像处理系统后端。通过自然语言指令或直接指定算法类型,智能调用底层图像处理算法服务。 ## 技术栈 | 组件 | 版本 | 说明 | |------|------|------| | JDK | 17+ | Java 运行环境 | | Spring Boot | 3.2.3 | 主框架 | | MyBatis Plus | 3.5.5 | ORM 框架 | | MySQL | 8.0+ | 关系数据库 | | Redis | 3.2.1 | 缓存(无密码) | | LangChain4J | 1.0.0-beta1 | LLM 集成框架 | | Ollama | - | 本地 LLM 运行时 | | Knife4j | 4.4.0 | API 文档 UI | ## 项目结构 ``` pictureAlgorithmAgent/ ├── pom.xml # 父工程 POM ├── pojo/ # 数据对象模块 │ ├── entity/ # 实体类(4 个) │ ├── dto/ # 数据传输对象 │ └── vo/ # 视图对象 ├── common/ # 公共工具模块 │ ├── constants/ # 常量类 │ └── util/ # 工具类 └── server/ # 服务启动模块 ├── config/ # 配置类 ├── controller/ # 控制器(4 个) ├── service/ # 服务接口 ├── service/impl/ # 服务实现 ├── mapper/ # Mapper 接口 ├── agent/ # LangChain4J Agent └── client/ # HTTP 客户端 ``` ## 快速开始 ### 1. 环境要求 - JDK 17+ - MySQL 8.0+(密码:1234) - Redis 3.2.100(无密码) - Maven 3.8+ - Ollama + qwen3:8b 模型 ### 2. 数据库初始化 ```bash # 连接 MySQL mysql -u root -p1234 # 执行初始化脚本 source server/src/main/resources/sql/init.sql ``` ### 3. 启动服务 ```bash # 启动 Redis redis-server # 启动 Ollama ollama run qwen2.5:3b # 启动后端项目 cd pictureAlgorithmAgent mvn spring-boot:run -pl server -am ``` ### 4. 访问 API 文档 启动后访问:http://localhost:8080/swagger-ui.html ## API 接口 ### 图片处理 | 接口 | 方法 | 路径 | 描述 | |------|------|------|------| | 图片处理(自然语言) | POST | /api/process | 接收图片 + 自然语言指令 | | 图片处理(快捷) | POST | /api/process/quick | 直接指定算法类型 | | 健康检查 | GET | /api/services/health | 检查所有服务状态 | | 单服务健康检查 | GET | /api/services/health/{name} | 检查单个服务 | | 历史记录 | GET | /api/history | 获取处理记录 | | 算法列表 | GET | /api/algorithms | 获取算法服务列表 | ## 算法服务 | 服务编码 | 服务名称 | 端口 | 功能 | |----------|----------|------|------| | emotion | 表情识别服务 | 5001 | 人脸表情识别与标注 | | sci | 低光增强服务 | 5002 | 低光照图像增强 | | esrgan | 超分辨率服务 | 5003 | 图像超分辨率/放大 | | restormer | 去噪去模糊服务 | 5004 | 图像去噪/去模糊/去雨 | ## 数据库表 | 表名 | 说明 | |------|------| | algorithm_services | 算法服务配置表 | | processing_records | 图片处理记录表 | | system_logs | 系统日志表 | | llm_call_logs | LLM 调用日志表 | ## 配置说明 ### application.yml 关键配置 ```yaml # 数据库配置(密码:1234) spring: datasource: url: jdbc:mysql://localhost:3306/ai_image_processor username: root password: 1234 # Redis 配置(无密码) data: redis: host: localhost port: 6379 password: # LangChain4J + Ollama 配置 langchain4j: ollama: chat-model: base-url: http://localhost:11434 model-name: qwen2.5:3b temperature: 0.1 # 算法服务配置 algorithm: services: emotion: base-url: http://localhost:5001 sci: base-url: http://localhost:5002 esrgan: base-url: http://localhost:5003 restormer: base-url: http://localhost:5004 ``` ## Redis 缓存设计 | Key 前缀 | 说明 | TTL | |----------|------|-----| | service:status:{code} | 服务健康状态 | 30s | | session:{sessionId} | 会话临时数据 | 10min | | record:recent:{sessionId} | 最近处理记录 | 5min | | ratelimit:{ip} | 请求限流计数 | 60s | ## 开发说明 ### 添加新算法服务 1. 在 `algorithm_services` 表插入新记录 2. 在 `AlgorithmServicesProperties` 添加配置 3. 在 `ImageProcessingTools` 添加新 Tool 方法 ### LangChain4J Agent 扩展 ```java @Tool("新工具描述") public String newTool(String base64Image) { return agentService.callAlgorithm("serviceCode", base64Image); } ``` ## 许可证 Apache License 2.0