mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 10:28:42 +00:00
docs: update the framework of doc site (#207)
Signed-off-by: Carson Yang <yangchuansheng33@gmail.com>
This commit is contained in:
8
docSite/content/docs/installation/reference/_index.md
Normal file
8
docSite/content/docs/installation/reference/_index.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
weight: 750
|
||||
title: "配置说明"
|
||||
description: "FastGPT 配置指南"
|
||||
icon: quick_reference_all
|
||||
draft: false
|
||||
images: []
|
||||
---
|
66
docSite/content/docs/installation/reference/chatglm2.md
Normal file
66
docSite/content/docs/installation/reference/chatglm2.md
Normal file
@@ -0,0 +1,66 @@
|
||||
---
|
||||
title: "接入 ChatGLM2-6B"
|
||||
description: " 将 FastGPT 接入私有化模型 ChatGLM2-6B"
|
||||
icon: "model_training"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 753
|
||||
---
|
||||
|
||||
## 前言
|
||||
|
||||
FastGPT 允许你使用自己的 OpenAI API KEY 来快速调用 OpenAI 接口,目前集成了 GPT-3.5, GPT-4 和 embedding,可构建自己的知识库。但考虑到数据安全的问题,我们并不能将所有的数据都交付给云端大模型。
|
||||
|
||||
那么如何在 FastGPT 上接入私有化模型呢?本文就以清华的 ChatGLM2 为例,为各位讲解如何在 FastGPT 中接入私有化模型。
|
||||
|
||||
## ChatGLM2-6B 简介
|
||||
|
||||
ChatGLM2-6B 是开源中英双语对话模型 ChatGLM-6B 的第二代版本,具体介绍可参阅 [ChatGLM2-6B 项目主页](https://github.com/THUDM/ChatGLM2-6B)。
|
||||
|
||||
{{% alert context="warning" %}}
|
||||
注意,ChatGLM2-6B 权重对学术研究完全开放,在获得官方的书面许可后,亦允许商业使用。本教程只是介绍了一种用法,无权给予任何授权!
|
||||
{{% /alert %}}
|
||||
|
||||
## 推荐配置
|
||||
|
||||
依据官方数据,同样是生成 8192 长度,量化等级为 FP16 要占用 12.8GB 显存、int8 为 8.1GB 显存、int4 为 5.1GB 显存,量化后会稍微影响性能,但不多。
|
||||
|
||||
因此推荐配置如下:
|
||||
|
||||
{{< table "table-hover table-striped" >}}
|
||||
| 类型 | 内存 | 显存 | 硬盘空间 | 启动命令 |
|
||||
|------|---------|---------|----------|--------------------------|
|
||||
| fp16 | >=16GB | >=16GB | >=25GB | python openai_api.py 16 |
|
||||
| int8 | >=16GB | >=9GB | >=25GB | python openai_api.py 8 |
|
||||
| int4 | >=16GB | >=6GB | >=25GB | python openai_api.py 4 |
|
||||
{{< /table >}}
|
||||
|
||||
## 环境配置
|
||||
|
||||
+ Python 3.8.10
|
||||
+ CUDA 11.8
|
||||
+ 科学上网环境
|
||||
|
||||
## 部署步骤
|
||||
|
||||
1. 根据上面的环境配置配置好环境,具体教程自行 GPT;
|
||||
2. 在命令行输入命令 `pip install -r requirments.txt`;
|
||||
3. 打开你需要启动的 py 文件,在代码的第 76 行配置 token,这里的 token 只是加一层验证,防止接口被人盗用;
|
||||
4. 执行命令 `python openai_api.py 16`。这里的数字根据上面的配置进行选择。
|
||||
|
||||
然后等待模型下载,直到模型加载完毕为止。如果出现报错先问 GPT。
|
||||
|
||||
启动成功后应该会显示如下地址:
|
||||
|
||||

|
||||
|
||||
> 这里的 `http://0.0.0.0:6006` 就是连接地址。
|
||||
|
||||
然后现在回到 .env.local 文件,依照以下方式配置地址:
|
||||
|
||||
```bash
|
||||
OPENAI_BASE_URL=http://127.0.0.1:6006/v1
|
||||
OPENAIKEY=sk-aaabbbcccdddeeefffggghhhiiijjjkkk # 这里是你在代码中配置的 token,这里的 OPENAIKEY 可以任意填写
|
||||
```
|
||||
|
||||
这样就成功接入 ChatGLM2-6B 了。
|
117
docSite/content/docs/installation/reference/configuration.md
Normal file
117
docSite/content/docs/installation/reference/configuration.md
Normal file
@@ -0,0 +1,117 @@
|
||||
---
|
||||
title: "配置详解"
|
||||
description: "FastGPT 配置参数介绍"
|
||||
icon: "settings"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 751
|
||||
---
|
||||
|
||||
由于环境变量不利于配置复杂的内容,新版 FastGPT 采用了 ConfigMap 的形式挂载配置文件,你可以在 `client/data/config.json` 看到默认的配置文件。可以参考 [docker-compose 快速部署](/docs/installation/docker/) 来挂载配置文件。
|
||||
|
||||
开发环境下,你需要将示例配置文件 `config.json` 复制成 `config.local.json` 文件才会生效。
|
||||
|
||||
注意: 为了方便介绍,文档介绍里会把注释写到 json 文件,实际运行时候 json 文件不能包含注释。
|
||||
|
||||
这个配置文件中包含了前端页面定制、系统级参数、AI 对话的模型等……
|
||||
|
||||
{{% alert context="warning" %}}
|
||||
注意:下面的配置介绍仅是局部介绍,你需要完整挂载整个 `config.json`,不能仅挂载一部分。你可以直接在默认的 config.json 基础上根据下面的介绍进行修改。
|
||||
{{% /alert %}}
|
||||
|
||||
## 基础字段粗略说明
|
||||
|
||||
这里介绍一些基础的配置字段:
|
||||
|
||||
```json
|
||||
// 这个配置会控制前端的一些样式
|
||||
"FeConfig": {
|
||||
"show_emptyChat": true, // 对话页面,空内容时,是否展示介绍页
|
||||
"show_register": false, // 是否展示注册按键(包括忘记密码,注册账号和三方登录)
|
||||
"show_appStore": false, // 是否展示应用市场(不过目前权限还没做好,放开也没用)
|
||||
"show_userDetail": false, // 是否展示用户详情(账号余额、OpenAI 绑定)
|
||||
"show_git": true, // 是否展示 Git
|
||||
"systemTitle": "FastGPT", // 系统的 title
|
||||
"authorText": "Made by FastGPT Team.", // 签名
|
||||
"gitLoginKey": "" // Git 登录凭证
|
||||
},
|
||||
...
|
||||
...
|
||||
// 这个配置文件是系统级参数
|
||||
"SystemParams": {
|
||||
"gitLoginSecret": "", // Git 登录凭证
|
||||
"vectorMaxProcess": 15, // 向量生成最大进程,结合数据库性能和 key 来设置
|
||||
"qaMaxProcess": 15, // QA 生成最大进程,结合数据库性能和 key 来设置
|
||||
"pgIvfflatProbe": 20 // pg vector 搜索探针。没有设置索引前可忽略,通常 50w 组以上才需要设置。
|
||||
},
|
||||
...
|
||||
```
|
||||
|
||||
## 完整配置参数
|
||||
|
||||
```json
|
||||
{
|
||||
"FeConfig": {
|
||||
"show_emptyChat": true,
|
||||
"show_register": false,
|
||||
"show_appStore": false,
|
||||
"show_userDetail": false,
|
||||
"show_git": true,
|
||||
"systemTitle": "FastGPT",
|
||||
"authorText": "Made by FastGPT Team.",
|
||||
"gitLoginKey": "",
|
||||
"scripts": []
|
||||
},
|
||||
"SystemParams": {
|
||||
"gitLoginSecret": "",
|
||||
"vectorMaxProcess": 15,
|
||||
"qaMaxProcess": 15,
|
||||
"pgIvfflatProbe": 20
|
||||
},
|
||||
"plugins": {},
|
||||
"ChatModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo",
|
||||
"name": "GPT35-4k",
|
||||
"contextMaxToken": 4000,
|
||||
"quoteMaxToken": 2000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"contextMaxToken": 16000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "GPT4-8k",
|
||||
"contextMaxToken": 8000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 0,
|
||||
"defaultSystem": ""
|
||||
}
|
||||
],
|
||||
"QAModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"maxToken": 16000,
|
||||
"price": 0
|
||||
}
|
||||
],
|
||||
"VectorModels": [
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
"price": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
74
docSite/content/docs/installation/reference/models.md
Normal file
74
docSite/content/docs/installation/reference/models.md
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
title: "多模型支持"
|
||||
description: "如何接入除了 GPT 以外的其他大模型"
|
||||
icon: "model_training"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 752
|
||||
---
|
||||
|
||||
默认情况下,FastGPT 只配置了 GPT 的 3 个模型,如果你需要接入其他模型,需要进行一些额外配置。
|
||||
|
||||
## 部署 one-api
|
||||
|
||||
首先你需要部署一个 [one-api](/docs/installation/one-api/),并添加对应的【渠道】
|
||||
|
||||

|
||||
|
||||
## 添加 FastGPT 配置
|
||||
|
||||
可以在 `/client/src/data/config.json` 里找到配置文件(本地开发需要复制成 config.local.json),配置文件中有一项是对话模型配置:
|
||||
|
||||
```json
|
||||
"ChatModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo", // 这里的模型需要对应 OneAPI 的模型
|
||||
"name": "FastAI-4k", // 对外展示的名称
|
||||
"contextMaxToken": 4000, // 最大长下文 token,无论什么模型都按 GPT35 的计算。GPT 外的模型需要自行大致计算下这个值。可以调用官方接口去比对 Token 的倍率,然后在这里粗略计算。
|
||||
// 例如:文心一言的中英文 token 基本是 1:1,而 GPT 的中文 Token 是 2:1,如果文心一言官方最大 Token 是 4000,那么这里就可以填 8000,保险点就填 7000.
|
||||
"quoteMaxToken": 2000, // 引用知识库的最大 Token
|
||||
"maxTemperature": 1.2, // 最大温度
|
||||
"price": 1.5, // 1个token 价格 => 1.5 / 100000 * 1000 = 0.015元/1k token
|
||||
"defaultSystem": "" // 默认的系统提示词
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "FastAI-16k",
|
||||
"contextMaxToken": 16000,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 3,
|
||||
"defaultSystem": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "FastAI-Plus",
|
||||
"contextMaxToken": 8000,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"price": 45,
|
||||
"defaultSystem": ""
|
||||
}
|
||||
],
|
||||
```
|
||||
|
||||
### 添加新模型
|
||||
|
||||
以添加文心一言为例:
|
||||
|
||||
```json
|
||||
"ChatModels": [
|
||||
...
|
||||
{
|
||||
"model": "ERNIE-Bot",
|
||||
"name": "文心一言",
|
||||
"contextMaxToken": 4000,
|
||||
"quoteMaxToken": 2000,
|
||||
"maxTemperature": 1,
|
||||
"price": 1.2
|
||||
}
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
添加完后,重启应用即可在选择文心一言模型进行对话。
|
Reference in New Issue
Block a user