2024-02-15 14:29:57 +08:00
## Getting Started
2023-08-09 20:35:59 +08:00
2024-04-08 23:07:23 +08:00
[READ THIS IN ENGLISH ](README_en.md )
2024-02-16 14:14:18 +08:00
**LangChain4j-AIDeepin**
2024-04-08 23:07:23 +08:00
基于 ChatGPT 等大语言模型与 Langchain4j 等应用框架实现,开源、可离线部署的检索增强生成(RAG)项目。
2024-02-15 15:31:49 +08:00
2024-03-05 23:56:57 +08:00
> **该项目如对您有帮助,欢迎点赞**
2024-03-12 00:41:49 +08:00
## 体验网址
2024-03-05 23:56:57 +08:00
[http://www.aideepin.com ](http://www.aideepin.com/ )
2024-03-12 00:41:49 +08:00
## 功能点
2024-02-15 15:41:10 +08:00
2024-02-16 14:14:18 +08:00
* 注册& 登录
* 多会话(多角色)
* 图片生成(文生图、修图、图生图)
* 提示词
* 额度控制
* 基于大模型的知识库( RAG)
2024-04-08 00:17:23 +08:00
* 基于大模型的搜索( RAG)
2024-02-27 23:55:53 +08:00
* 多模型随意切换
2024-04-08 00:17:23 +08:00
* 多搜索引擎随意切换
2023-08-09 20:35:59 +08:00
2024-03-12 00:41:49 +08:00
## 接入的模型:
2024-03-05 23:56:57 +08:00
2024-02-27 23:55:53 +08:00
* ChatGPT 3.5
* 通义千问
2024-03-05 00:20:04 +08:00
* 文心一言
2024-03-14 20:19:53 +08:00
* ollama
2024-02-27 23:55:53 +08:00
* DALL-E 2
2024-02-15 15:31:49 +08:00
2024-04-08 00:17:23 +08:00
## 接入的搜索引擎
Google
Bing (TODO)
百度 (TODO)
2024-03-12 00:41:49 +08:00
## 技术栈
2024-02-15 15:31:49 +08:00
2024-02-27 23:55:53 +08:00
该仓库为后端服务,前端项目见[langchain4j-aideepin-web](https://github.com/moyangzhan/langchain4j-aideepin-web)
2024-02-15 15:31:49 +08:00
后端:
jdk17
springboot3.0.5
2024-02-18 09:23:33 +08:00
[langchain4j(Java version of LangChain) ](https://github.com/langchain4j/langchain4j )
2024-02-15 15:31:49 +08:00
**Postgresql(需要安装[pgvector](https://github.com/pgvector/pgvector)扩展)**
前端:
vue3+typescript+pnpm
2023-08-09 20:35:59 +08:00
2024-03-12 00:41:49 +08:00
## 如何部署
2023-08-09 20:35:59 +08:00
2024-03-12 00:41:49 +08:00
### 初始化
2023-08-09 20:35:59 +08:00
2024-03-14 20:19:53 +08:00
**a. 初始化数据库**
2023-08-09 20:35:59 +08:00
2024-02-15 15:31:49 +08:00
* 创建数据库aideepin
* 执行docs/create.sql
2024-04-08 00:17:23 +08:00
* 填充各模型的配置(至少设置一个)
2023-08-09 20:35:59 +08:00
2024-03-12 09:07:11 +08:00
openai的secretKey
2024-03-14 20:19:53 +08:00
2024-02-15 14:29:57 +08:00
```plaintext
2024-03-14 20:19:53 +08:00
update adi_sys_config set value = '{"secret_key":"my_openai_secret_key","models":["gpt-3.5-turbo"]}' where name = 'openai_setting';
2024-03-12 09:07:11 +08:00
```
灵积大模型平台的apiKey
2024-03-14 20:19:53 +08:00
2024-03-12 09:07:11 +08:00
```plaintext
2024-03-14 20:19:53 +08:00
update adi_sys_config set value = '{"api_key":"my_dashcope_api_key","models":["my model name,eg:qwen-max"]}' where name = 'dashscope_setting';
2023-08-09 20:35:59 +08:00
```
2024-03-12 09:07:11 +08:00
千帆大模型平台的配置
2024-03-14 20:19:53 +08:00
2024-03-12 09:07:11 +08:00
```plaintext
2024-03-14 20:19:53 +08:00
update adi_sys_config set value = '{"api_key":"my_qianfan_api_key","secret_key":"my_qianfan_secret_key","models":["my model name,eg:ERNIE-Bot"]}' where name = 'qianfan_setting';
```
ollama的配置
```
update adi_sys_config set value = '{"base_url":"my_ollama_base_url","models":["my model name,eg:tinydolphin"]}' where name = 'ollama_setting';
2024-03-12 09:07:11 +08:00
```
2024-04-08 00:17:23 +08:00
* 填充搜索引擎的配置
Google的配置
```
update adi_sys_config set value = '{"url":"https://www.googleapis.com/customsearch/v1","key":"my key from cloud.google.com","cx":"my cx from programmablesearchengine.google.com"}' where name = 'google_setting';
```
2024-03-14 20:19:53 +08:00
**b. 修改配置文件**
2023-08-09 20:35:59 +08:00
2024-03-14 20:19:53 +08:00
* postgresql: application-[dev|prod].xml中的spring.datasource
* redis: application-[dev|prod].xml中的spring.data.redis
* mail: application.xml中的spring.mail
2023-08-09 20:35:59 +08:00
2024-03-12 00:41:49 +08:00
### 编译及运行
2023-08-09 20:35:59 +08:00
* 进入项目
2024-02-15 14:29:57 +08:00
```plaintext
2024-02-15 15:31:49 +08:00
cd langchain4j-aideepin
2023-08-09 20:35:59 +08:00
```
* 打包:
```
mvn clean package -Dmaven.test.skip=true
```
2024-02-15 15:31:49 +08:00
* 运行
2023-08-09 20:35:59 +08:00
a. jar包启动:
2024-02-15 14:29:57 +08:00
```plaintext
2024-04-22 19:04:25 +08:00
adi-bootstrap-0.0.1-SNAPSHOT.jarcd adi-bootstrap/target
nohup java -jar -Xms768m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError adi-bootstrap-0.0.1-SNAPSHOT.jar --spring.profiles.active=[dev|prod] dev/null 2>& 1 &
2023-08-09 20:35:59 +08:00
```
b. docker启动
2024-02-15 14:29:57 +08:00
```plaintext
2024-02-18 18:37:45 +08:00
cd adi-bootstrap
2023-08-09 20:35:59 +08:00
docker build . -t aideepin:0.0.1
docker run -d \
--name=aideepin \
-e APP_PROFILE=[dev|prod] \
-v="/data/aideepin/logs:/data/logs" \
aideepin:0.0.1
2024-02-15 15:31:49 +08:00
```
2024-03-12 00:41:49 +08:00
## 待办:
2024-02-15 15:31:49 +08:00
2024-04-22 19:04:25 +08:00
高级RAG
2024-04-08 00:17:23 +08:00
增加搜索引擎( BING、百度)
2024-03-05 23:56:57 +08:00
2024-03-12 00:41:49 +08:00
## 截图
2024-03-05 23:56:57 +08:00
**AI聊天: **
![1691583184761 ](image/README/1691583184761.png )
2024-04-08 00:17:23 +08:00
**AI画图: **
2024-03-05 23:56:57 +08:00
2024-04-08 00:17:23 +08:00
![1691583124744 ](image/README/1691583124744.png "AI绘图" )
2024-03-05 23:56:57 +08:00
**知识库:**
![kbindex ](image/README/kbidx.png )
![kb01 ](image/README/kb01.png )
2024-04-08 00:17:23 +08:00
**向量化:**
2024-03-05 23:56:57 +08:00
![kb02 ](image/README/kb02.png )
![kb03 ](image/README/kb03.png )
2024-04-08 00:17:23 +08:00
**额度统计:**
2024-04-08 23:07:23 +08:00
!![1691583329105.png](image%2FREADME%2F1691583329105.png)