Skip to content

一个用于简化Spring Boot应用程序中AI功能集成的starter包,支持聊天功能和文档处理(RAG - 检索增强生成)

License

Notifications You must be signed in to change notification settings

wb04307201/easy-ai

Repository files navigation

Easy AI 简单易用的AI功能集成

一个用于简化Spring Boot应用程序中AI功能集成的starter包,支持聊天功能和文档处理(RAG - 检索增强生成)。

star fork star fork
MIT JDK SpringBoot

功能特性

  • 🤖 AI聊天功能:支持普通聊天和流式聊天
  • 📄 文档处理:支持文档上传、存储、读取和检索
  • 🧠 RAG支持:基于向量存储的检索增强生成
  • ⚙️ 自动配置:通过Spring Boot自动配置简化集成
  • 🎛️ 可配置:丰富的配置选项,满足不同场景需求

快速开始

引入依赖

增加 JitPack 仓库

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

引入jar

<dependency>
    <groupId>com.github.wb04307201.easy-ai</groupId>
    <artifactId>easy-ai-spring-boot-starter</artifactId>
    <version>1.0.1</version>
</dependency>

安装向量数据库

通过docker安装chromadb数据库

docker run -it --rm --name chroma -p 8000:8000 ghcr.io/chroma-core/chroma:1.0.0

安装大语言模型

默认通过ollama使用大模型,下载并安装

ollama pull qwen3
ollama pull nomic-embed-text

添加相关配置

spring:
  application:
    name: spring_ai_demo
  ai:
    ollama:
      chat:
        options:
          model: qwen3
      embedding:
        options:
          model: nomic-embed-text
      base-url: http://localhost:11434
    vectorstore:
      chroma:
        client:
          host: http://localhost
          port: 8000
        collection-name: SpringAiCollection
        initialize-schema: true
    easy:
      enableRag: true
  servlet:
    multipart:
      max-file-size: 10MB
      max-request-size: 10MB

使用检索增强生成(RAG)辅助对话

当未上传知识库时
img_4.png
显然开始胡说八道了

现在让我们上传一些知识库,访问文档上传界面http://localhost:8080//easy/ai/list
img.png
状态列显示“向量存储完”即文档已转入知识库

访问聊天界面http://localhost:8080//easy/ai/chat
img_5.png

About

一个用于简化Spring Boot应用程序中AI功能集成的starter包,支持聊天功能和文档处理(RAG - 检索增强生成)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published