Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc/chinese readme #59

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 45 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
## 📃 NextAGIFuture

<p align="center">
<a href="./README.md">English</a> |
<a href="./README_cn.md">简体中文</a> |
<a href="./README_docu.md">Getting Started</a>
<a href="./README.md">English</a> |
<a href="#how-to-get-started">Getting Started</a>
</p>

A chatbot, RAG, agent, and multi-agent application project based on LangChain, LangGraph, and other frameworks, open-source, and capable of offline deployment.
<video src="https://private-user-images.githubusercontent.com/49232224/365880079-72564225-6675-4eda-b1c6-c87bb3e4bd24.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5Mzg2MzksIm5iZiI6MTcyNTkzODMzOSwicGF0aCI6Ii80OTIzMjIyNC8zNjU4ODAwNzktNzI1NjQyMjUtNjY3NS00ZWRhLWIxYzYtYzg3YmIzZTRiZDI0Lm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDAzMTg1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVlZTVkZmQxY2YxZDRhMWJmYTY1ZmRjNzAxMzAwODJjNjZiMjQxOGRjMTkzZTlkYTA3ZTRiN2M4OWFhYjM2NDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.E2MtHMi_cgeo6p7LKdIUj-iJt9JHA2li8pVxbI6Wazc" data-canonical-src="https://private-user-images.githubusercontent.com/49232224/365880079-72564225-6675-4eda-b1c6-c87bb3e4bd24.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5Mzg2MzksIm5iZiI6MTcyNTkzODMzOSwicGF0aCI6Ii80OTIzMjIyNC8zNjU4ODAwNzktNzI1NjQyMjUtNjY3NS00ZWRhLWIxYzYtYzg3YmIzZTRiZDI0Lm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDAzMTg1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVlZTVkZmQxY2YxZDRhMWJmYTY1ZmRjNzAxMzAwODJjNjZiMjQxOGRjMTkzZTlkYTA3ZTRiN2M4OWFhYjM2NDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.E2MtHMi_cgeo6p7LKdIUj-iJt9JHA2li8pVxbI6Wazc" controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" style="max-height:640px; min-height: 200px">
</video>
</video>

### 🤖️ Overview

![image](https://github.com/user-attachments/assets/22583a25-4cee-43af-9d8e-38a491377875)

#### work flow

![image](https://github.com/user-attachments/assets/a4e33565-7acf-45d9-8e82-5a740cd88344)
![image](https://github.com/user-attachments/assets/4d5874f1-aeb0-47c5-b907-21878a2fa4d9)

#### Image

![image](https://github.com/user-attachments/assets/4097b087-0309-4aab-8be9-a06fdc9d4964)

#### Human in the loop (human approval or let the LLM rethink or ask human for help)

<p>
<img src="https://github.com/user-attachments/assets/ec53f7de-10cb-4001-897a-2695da9cf6bf" alt="image" style="width: 49%; display: inline-block;">
<img src="https://github.com/user-attachments/assets/1c7d383d-e6bf-42b8-94ec-9f0c37be19b8" alt="image" style="width: 49%; display: inline-block;">
</p>



NextAGIFuture aims to be an open-source platform for developing large language model (LLM) applications. It is an LLM-based application utilizing the concepts of
LangChain and LangGraph. The goal is to create a suite of LLMOps solutions that supports chatbots, RAG applications, agents, and multi-agent systems, with the capability for offline operation.

Inspired by the [StreetLamb](https://github.com/StreetLamb) project and its [tribe](https://github.com/StreetLamb/tribe) project , NextAGIFuture adopts much of the approach and code.
Building on this foundation, it introduces some new features and directions of its own.

Some of the layout in this project references [Lobe-chat](https://github.com/lobehub/lobe-chat), [Dify](https://github.com/langgenius/dify), and [fastgpt](https://github.com/labring/FastGPT).
Some of the layout in this project references [Lobe-chat](https://github.com/lobehub/lobe-chat), [Dify](https://github.com/langgenius/dify), and [fastgpt](https://github.com/labring/FastGPT).
They are all excellent open-source projects, thanks🙇‍.

### 👨‍💻 Development
Expand All @@ -44,7 +51,7 @@ Project tech stack: LangChain + LangGraph + React + Next.js + Chakra UI + Postgr
- [x] SimpleRAG
- [x] Hierarchical Agent
- [x] Sequential Agent
- [ ] Work-Flow ---On Progress
- [ ] Work-Flow ---On Progress
- [ ] More muti-agent

2 Model
Expand All @@ -58,9 +65,9 @@ Project tech stack: LangChain + LangGraph + React + Next.js + Chakra UI + Postgr

3 Ohters

- [x] Function call
- [x] Tools Calling
- [x] I18n
- [ ] Langchin Templates
- [ ] Langchain Templates

### 🏘️Highlights

Expand All @@ -74,20 +81,29 @@ Project tech stack: LangChain + LangGraph + React + Next.js + Chakra UI + Postgr

### How to get started

#### 1. Preparation
#### 1. Preparation

##### 1.1 Clone the Code

git clone https://github.com/Onelevenvy/NextAGIFuture.git

##### 1.2 Copy Environment Configuration File

```bash
cp .env.example .env
```

##### 1.3 Generate Secret Keys

Some environment variables in the .env file have a default value of changethis.
You have to change them with a secret key, to generate secret keys you can run the following command:

```bash
python -c "import secrets; print(secrets.token_urlsafe(32))"
```

Copy the content and use that as password / secret key. And run that again to generate another secure key.

##### 1.3 Insatll postgres,qdrant,redis

```bash
Expand All @@ -96,29 +112,38 @@ docker compose up -d
```

#### 2.Run Backend
##### 2.1 Installation of the basic environment

##### 2.1 Installation of the basic environment

Server startup requires Python 3.10.x. It is recommended to use pyenv for quick installation of the Python environment.

To install additional Python versions, use pyenv install.

```bash
pyenv install 3.10
```

To switch to the "3.10" Python environment, use the following command:

```bash
pyenv global 3.10
```

Follow these steps :
Navigate to the "backen" directory:

```bash
cd backend
```

activate the environment.

```bash
poetry env use 3.10
poetry install
```
##### 2.2 initiral data

##### 2.2 initiral data

```bash
# Let the DB start
Expand All @@ -130,31 +155,34 @@ alembic upgrade head
# Create initial data in DB
python /app/app/initial_data.py
```
##### 2.3 run unicorn

##### 2.3 run unicorn

```bash
uvicorn app.main:app --reload --log-level debug
```

##### 2.4 run celery (Not necessary, unless you want to use the rag function)

```bash
poetry run celery -A app.core.celery_app.celery_app worker --loglevel=debug
```

#### 3.Run Frontend

##### 3.1 Enter the web directory and install the dependencies

```bash
cd web
pnpm install
```

##### 3.2 Start the web service

```bash
cd web
pnpm dev

# or pnpm build then pnpm start
```



### Note:
This project is developed by simultaneously learning and mastering technologies such as LangGraph, FastAPI, and Next.js, while building LLM applications. This approach helps improve our skills and allows us to experience the enjoyment brought by LLMs. The project code may undergo significant changes and may contain bugs. We also hope that like-minded individuals will join us and grow together.
184 changes: 184 additions & 0 deletions README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
## 📃 NextAGIFuture

<p align="center">
<a href="./README_cn.md">简体中文</a> |
<a href="./README.md">English</a> |
<a href="./README.md#how-to-get-started">Getting Started</a>
</p>

一个基于 LangChain、LangGraph 和其他框架的聊天机器人、RAG、代理和多代理应用项目,开源且能够离线部署。
<video src="https://private-user-images.githubusercontent.com/49232224/365880079-72564225-6675-4eda-b1c6-c87bb3e4bd24.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5Mzg2MzksIm5iZiI6MTcyNTkzODMzOSwicGF0aCI6Ii80OTIzMjIyNC8zNjU4ODAwNzktNzI1NjQyMjUtNjY3NS00ZWRhLWIxYzYtYzg3YmIzZTRiZDI0Lm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDAzMTg1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVlZTVkZmQxY2YxZDRhMWJmYTY1ZmRjNzAxMzAwODJjNjZiMjQxOGRjMTkzZTlkYTA3ZTRiN2M4OWFhYjM2NDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.E2MtHMi_cgeo6p7LKdIUj-iJt9JHA2li8pVxbI6Wazc" data-canonical-src="https://private-user-images.githubusercontent.com/49232224/365880079-72564225-6675-4eda-b1c6-c87bb3e4bd24.mp4?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5Mzg2MzksIm5iZiI6MTcyNTkzODMzOSwicGF0aCI6Ii80OTIzMjIyNC8zNjU4ODAwNzktNzI1NjQyMjUtNjY3NS00ZWRhLWIxYzYtYzg3YmIzZTRiZDI0Lm1wND9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEwVDAzMTg1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVlZTVkZmQxY2YxZDRhMWJmYTY1ZmRjNzAxMzAwODJjNjZiMjQxOGRjMTkzZTlkYTA3ZTRiN2M4OWFhYjM2NDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.E2MtHMi_cgeo6p7LKdIUj-iJt9JHA2li8pVxbI6Wazc" controls="controls" muted="muted" class="d-block rounded-bottom-2 border-top width-fit" style="max-height:640px; min-height: 200px">
</video>

### 🤖️ 概览

![image](https://github.com/user-attachments/assets/22583a25-4cee-43af-9d8e-38a491377875)

#### 工作流程

![image](https://github.com/user-attachments/assets/a4e33565-7acf-45d9-8e82-5a740cd88344)
![image](https://github.com/user-attachments/assets/4d5874f1-aeb0-47c5-b907-21878a2fa4d9)

#### 图像

![image](https://github.com/user-attachments/assets/4097b087-0309-4aab-8be9-a06fdc9d4964)

#### 人在回路中(人工审批或让 LLM 重新思考或寻求人工帮助)

<p>
<img src="https://github.com/user-attachments/assets/ec53f7de-10cb-4001-897a-2695da9cf6bf" alt="image" style="width: 49%; display: inline-block;">
<img src="https://github.com/user-attachments/assets/1c7d383d-e6bf-42b8-94ec-9f0c37be19b8" alt="image" style="width: 49%; display: inline-block;">
</p>

NextAGIFuture 旨在成为一个开源的大语言模型(LLM)应用开发平台。它是一个基于 LangChain 和 LangGraph 概念的 LLM 应用。目标是创建一套支持聊天机器人、RAG 应用、代理和多代理系统的 LLMOps 解决方案,并具备离线运行能力。

受 [StreetLamb](https://github.com/StreetLamb) 项目及其 [tribe](https://github.com/StreetLamb/tribe) 项目的启发,NextAGIFuture 采用了许多相同的方法和代码。在此基础上,它引入了一些新的功能和方向。

本项目的一些布局参考了 [Lobe-chat](https://github.com/lobehub/lobe-chat)、[Dify](https://github.com/langgenius/dify) 和 [fastgpt](https://github.com/labring/FastGPT)。它们都是优秀的开源项目,在此表示感谢 🙇‍。

### 👨‍💻 开发

项目技术栈:LangChain + LangGraph + React + Next.js + Chakra UI + PostgreSQL

### 💡 路线图

1 应用

- [x] 聊天机器人
- [x] 简单 RAG
- [x] 层次代理
- [x] 顺序代理
- [ ] 工作流 ---进行中
- [ ] 更多多代理系统

2 模型

- [x] OpenAI
- [x] ZhipuAI
- [x] Siliconflow
- [x] Ollama
- [ ] Qwen
- [ ] Xinference

3 其他

- [x] Tools Calling
- [x] I18n
- [ ] Langchain Templates

### 🏘️ 亮点

- 持久化对话:保存并维护聊天历史,允许您继续对话。
- 可观察性:使用 LangSmith 实时监控和跟踪您的代理性能和输出,确保它们高效运行。
- 工具调用:使您的代理能够使用外部工具和 API。
- 检索增强生成:使您的代理能够利用您的内部知识库进行推理。
- Human-in-the-loop:在工具调用前启用人工审批。
- 开源模型:使用开源 LLM 模型,如 llama、Qwen 和 Glm。
- 多租户:管理和支持多个用户和团队。

### 如何开始

#### 1. 准备工作

##### 1.1 克隆代码

git clone https://github.com/Onelevenvy/NextAGIFuture.git

##### 1.2 复制环境配置文件

```bash
cp .env.example .env
```

##### 1.3 生成密钥

.env 文件中的一些环境变量默认值为 changethis。
您必须将它们更改为密钥,要生成密钥,可以运行以下命令:

```bash
python -c "import secrets; print(secrets.token_urlsafe(32))"
```

复制内容并将其用作密码/密钥。再次运行该命令以生成另一个安全密钥。

##### 1.3 安装 postgres、qdrant、redis

```bash
cd nextagi
docker compose up -d
```

#### 2.运行后端

##### 2.1 安装基本环境

服务器启动需要 Python 3.10.x。建议使用 pyenv 快速安装 Python 环境。

要安装其他 Python 版本,请使用 pyenv install。

```bash
pyenv install 3.10
```

要切换到 "3.10" Python 环境,请使用以下命令:

```bash
pyenv global 3.10
```

按照以下步骤操作:
导航到 "backend" 目录:

```bash
cd backend
```

激活环境。

```bash
poetry env use 3.10
poetry install
```

##### 2.2 初始化数据

```bash
# 让数据库启动
python /app/app/backend_pre_start.py

# 运行迁移
alembic upgrade head

# 在数据库中创建初始数据
python /app/app/initial_data.py
```

##### 2.3 运行 unicorn

```bash
uvicorn app.main:app --reload --log-level debug
```

##### 2.4 运行 celery(非必需,除非您想使用 rag 功能)

```bash
poetry run celery -A app.core.celery_app.celery_app worker --loglevel=debug
```

#### 3.运行前端

##### 3.1 进入 web 目录并安装依赖

```bash
cd web
pnpm install
```

##### 3.2 启动 web 服务

```bash
cd web
pnpm dev

# 或者 pnpm build 然后 pnpm start
```
Loading