Compare commits
15 Commits
v4.6.6-alp
...
v4.6.7-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e2adb22f0 | ||
|
|
c031e6dcc9 | ||
|
|
8ee7407c4c | ||
|
|
006ad17c6a | ||
|
|
414b693303 | ||
|
|
dfa6586e5e | ||
|
|
5968bfeb12 | ||
|
|
5876a47da6 | ||
|
|
13eda40443 | ||
|
|
84cc4baf21 | ||
|
|
dfa4c0831c | ||
|
|
9329ddeac5 | ||
|
|
8d17f96600 | ||
|
|
3f088bce6a | ||
|
|
331d18c88f |
4
.github/sync_imgs.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
yangchuansheng/fastgpt-imgs:
|
||||
- source: docSite/assets/imgs/
|
||||
dest: imgs/
|
||||
deleteOrphaned: true
|
||||
9
.github/workflows/deploy-docs.yml
vendored
@@ -45,6 +45,10 @@ jobs:
|
||||
- 'docSite/content/docs/**'
|
||||
base: main
|
||||
|
||||
- name: Add cdn for images
|
||||
run: |
|
||||
sed -i "s#\](/imgs/#\](https://cdn.jsdelivr.us/gh/yangchuansheng/fastgpt-imgs@main/imgs/#g" $(grep -rl "\](/imgs/" docSite/content/docs)
|
||||
|
||||
# Step 3 - Install Hugo (specific version)
|
||||
- name: Install Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
@@ -68,3 +72,8 @@ jobs:
|
||||
vercel-args: '--prod --local-config ../vercel.json' # Optional
|
||||
working-directory: docSite/public
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GH_PAT }}
|
||||
publish_dir: docSite/public
|
||||
|
||||
4
.github/workflows/deploy-preview.yml
vendored
@@ -45,6 +45,10 @@ jobs:
|
||||
- 'docSite/content/docs/**'
|
||||
base: main
|
||||
|
||||
- name: Add cdn for images
|
||||
run: |
|
||||
sed -i "s#\](/imgs/#\](https://cdn.jsdelivr.us/gh/yangchuansheng/fastgpt-imgs@main/imgs/#g" $(grep -rl "\](/imgs/" docSite/content/docs)
|
||||
|
||||
# Step 3 - Install Hugo (specific version)
|
||||
- name: Install Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
|
||||
35
.github/workflows/sync_imgs.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Sync images
|
||||
on:
|
||||
pull_request_target:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- docSite/assets/imgs/**
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- docSite/assets/imgs/**
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
if: ${{ (github.event_name == 'pull_request_target') }}
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Run GitHub File Sync
|
||||
uses: BetaHuhn/repo-file-sync-action@v1.21.0
|
||||
with:
|
||||
GH_PAT: ${{ secrets.IMG_GH_PAT }}
|
||||
CONFIG_PATH: .github/sync_imgs.yml
|
||||
ORIGINAL_MESSAGE: true
|
||||
SKIP_PR: true
|
||||
COMMIT_EACH_FILE: false
|
||||
5
.gitignore
vendored
@@ -36,4 +36,7 @@ dist/
|
||||
docSite/public/
|
||||
docSite/resources/_gen/
|
||||
docSite/.vercel
|
||||
*.local.*
|
||||
*.local.*
|
||||
|
||||
|
||||
.idea/
|
||||
|
||||
9
.imgbotconfig
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"schedule": "daily", // daily|weekly|monthly
|
||||
"ignoredFiles": [
|
||||
"*.svg",
|
||||
"packages/*",
|
||||
"projects/*",
|
||||
],
|
||||
"minKBReduced": 200, // delay new prs until size reduction meets this threshold (default to 10)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
||||
|
||||
[](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Dfastgpt)
|
||||
|
||||
由于需要部署数据库,部署完后需要等待 2~4 分钟才能正常访问。默认用了最低配置,首次访问时会有些慢。
|
||||
由于需要部署数据库,部署完后需要等待 2~4 分钟才能正常访问。默认用了最低配置,首次访问时会有些慢。相关使用教程可查看:[Sealos 部署 FastGPT](https://doc.fastgpt.in/docs/development/sealos/)
|
||||
|
||||
* [快开始本地开发](https://doc.fastgpt.in/docs/development/intro/)
|
||||
* [部署 FastGPT](https://doc.fastgpt.in/docs/development/sealos)
|
||||
|
||||
17
dev.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# 打包命令
|
||||
|
||||
```sh
|
||||
# Build image, not proxy
|
||||
docker build -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.4.7 --build-arg name=app .
|
||||
|
||||
# build image with proxy
|
||||
docker build -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.4.7 --build-arg name=app --build-arg proxy=taobao .
|
||||
```
|
||||
|
||||
# Pg 常用索引
|
||||
|
||||
```sql
|
||||
CREATE INDEX IF NOT EXISTS modelData_dataset_id_index ON modeldata (dataset_id);
|
||||
CREATE INDEX IF NOT EXISTS modelData_collection_id_index ON modeldata (collection_id);
|
||||
CREATE INDEX IF NOT EXISTS modelData_teamId_index ON modeldata (team_id);
|
||||
```
|
||||
@@ -1,3 +1,42 @@
|
||||
#content {
|
||||
font-family: JetBrains Mono, LXGW WenKai Screen, -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", "Ubuntu";
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.docs-content h1 {
|
||||
font-size: 2.4rem;
|
||||
}
|
||||
|
||||
.docs-content .main-content h2 {
|
||||
margin-top: 2rem !important;
|
||||
margin-bottom: 1rem !important;
|
||||
font-size: 1.9rem;
|
||||
}
|
||||
|
||||
.docs-content .main-content h3 {
|
||||
margin-top: 1.6rem !important;
|
||||
margin-bottom: 0.6rem !important;
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
|
||||
.docs-content .main-content h4 {
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.docs-content .main-content ol, .docs-content .main-content ul {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.docs-content .main-content ol > li {
|
||||
margin-left: -1.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
.docs-content .main-content ol > li::before {
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.docs-content .main-content img, .docs-content .main-content svg:not(.gitinfo svg):not(a svg) {
|
||||
max-width: 80% !important;
|
||||
height: auto;
|
||||
|
||||
|
Before Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 24 KiB |
BIN
docSite/assets/imgs/functional-arch.webp
Normal file
|
After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 36 KiB |
BIN
docSite/assets/imgs/sealos-fastgpt.webp
Normal file
|
After Width: | Height: | Size: 164 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 148 KiB After Width: | Height: | Size: 148 KiB |
@@ -33,7 +33,7 @@ FastGPT 商业版是基于 FastGPT 开源版的增强版本,增加了一些独
|
||||
|
||||
## 商业版软件价格
|
||||
|
||||
FastGPT 商业版软件根据不同的部署方式,分为 4 类收费模式。下面列举各种部署方式一些常规内容,如仍有问题,可[联系咨询](https://fael3z0zfze.feishu.cn/share/base/form/shrcnRxj3utrzjywsom96Px4sud)
|
||||
FastGPT 商业版软件根据不同的部署方式,分为 3 类收费模式。下面列举各种部署方式一些常规内容,如仍有问题,可[联系咨询](https://fael3z0zfze.feishu.cn/share/base/form/shrcnRxj3utrzjywsom96Px4sud)
|
||||
|
||||
**共有服务**
|
||||
|
||||
@@ -44,16 +44,19 @@ FastGPT 商业版软件根据不同的部署方式,分为 4 类收费模式。
|
||||
**特有服务**
|
||||
|
||||
{{< table "table-hover table-striped-columns" >}}
|
||||
| 部署方式 | 特有服务 | 上线时长 | 价格 |
|
||||
| 部署方式 | 特有服务 | 上线时长 | 标品价格 |
|
||||
| ---- | ---- | ---- | ---- |
|
||||
| Sealos公有云部署 | 1. 6个版本的升级服务。<br>2. 赠送 8000 元 Sealos 云资源额度。 | 半天 | 10000元/年 |
|
||||
| Sealos全托管 | 1. 有效期内免费升级。<br>2. 免运维服务&数据库。<br>3. 赠送 10000 元 Sealos 云资源额度。 | 半天 | 3000元起/月(3个月起)<br>或<br>30000元起/年 |
|
||||
| Sealos全托管 | 1. 有效期内免费升级。<br>2. 免运维服务&数据库。 | 半天 | 3000元起/月(3个月起)<br>或<br>30000元起/年 |
|
||||
| 自有服务器-单机版 | 1. 6个版本的升级服务。 | 14天内 | 60000元/套(不限时长) |
|
||||
| 自有服务器-Sealos版 | 1. 6个版本的升级服务。 | 14天内 | 150000元/套(不限时长)|
|
||||
| 自有服务器-高可用版 | 1. 6个版本的升级服务。 | 14天内 | 150000元/套(不限时长)|
|
||||
{{< /table >}}
|
||||
|
||||
{{% alert icon="🤖 " context="success" %}}
|
||||
6个版本的升级服务不是指只能用 6 个版本,而是指依赖 FastGPT 团队提供的升级服务。大部分时候,建议自行升级,也不麻烦。
|
||||
- 6个版本的升级服务不是指只能用 6 个版本,而是指依赖 FastGPT 团队提供的升级服务。大部分时候,建议自行升级,也不麻烦。
|
||||
- 全托管版本适合技术人员紧缺的团队,仅需关注业务推动,无需关心服务是否正常运行。
|
||||
- 单机版和高可用版可以完全部署在自己服务器中。
|
||||
- 单机版适合中小团队对内提供服务,需要自己维护数据库备份等。
|
||||
- 高可用版适合对外提供在线服务,包含可视化监控、多副本、负载均衡、数据库自动备份等生产环境的基础设施。
|
||||
{{% /alert %}}
|
||||
|
||||
|
||||
@@ -94,4 +97,4 @@ FastGPT 商业版软件根据不同的部署方式,分为 4 类收费模式。
|
||||
|
||||
Sealos 云服务属于按量计费,下面是它的价格表:
|
||||
|
||||

|
||||

|
||||
|
||||
@@ -11,6 +11,6 @@ FastGPT 是一个由用户和贡献者参与推动的开源项目,如果您对
|
||||
|
||||
+ 📱 扫码加入社区微信交流群👇
|
||||
|
||||
<img width="400px" src="https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg" />
|
||||
<img width="400px" src="https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg" class="medium-zoom-image" />
|
||||
|
||||
+ 🐞 请将任何 FastGPT 的 Bug、问题和需求提交到 [GitHub Issue](https://github.com/labring/fastgpt/issues/new/choose)。
|
||||
@@ -29,7 +29,7 @@ weight: 106
|
||||
|
||||
### 全文检索
|
||||
|
||||
才用传统的全文检索方式。适合查找关键的主谓语等。
|
||||
采用传统的全文检索方式。适合查找关键的主谓语等。
|
||||
|
||||
### 混合检索
|
||||
|
||||
@@ -55,4 +55,4 @@ FastGPT 会使用 `RRF` 对重排结果、向量搜索结果、全文检索结
|
||||
|
||||
一个`0-1`的数值,会过滤掉一些低相关度的搜索结果。
|
||||
|
||||
该值仅在`语义检索`或使用`结果重排`时生效。
|
||||
该值仅在`语义检索`或使用`结果重排`时生效。
|
||||
|
||||
@@ -25,13 +25,13 @@ curl https://doc.fastgpt.in/docs/intro/
|
||||
|
||||
### 1. 新建知识库,选择 Web 站点同步
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
### 2. 点击配置站点信息
|
||||
|
||||

|
||||

|
||||
|
||||
### 3. 填写网址和选择器
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ weight: 708
|
||||
```json
|
||||
{
|
||||
"SystemParams": {
|
||||
"pluginBaseUrl": "", // 商业版接口地址
|
||||
"vectorMaxProcess": 15, // 向量生成最大进程,结合数据库性能和 key 来设置
|
||||
"qaMaxProcess": 15, // QA 生成最大进程,结合数据库性能和 key 来设置
|
||||
"pgHNSWEfSearch": 100 // pg vector 索引参数,越大精度高但速度慢
|
||||
@@ -169,7 +168,6 @@ weight: 708
|
||||
```json
|
||||
{
|
||||
"systemEnv": {
|
||||
"pluginBaseUrl": "", // 商业版接口地址
|
||||
"vectorMaxProcess": 15, // 向量生成最大进程,结合数据库性能和 key 来设置
|
||||
"qaMaxProcess": 15, // QA 生成最大进程,结合数据库性能和 key 来设置
|
||||
"pgHNSWEfSearch": 100 // pg vector 索引参数,越大精度高但速度慢
|
||||
@@ -234,7 +232,8 @@ weight: 708
|
||||
"name": "GPT35-16k",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 16000,
|
||||
"price": 0
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0
|
||||
}
|
||||
],
|
||||
"cqModels": [ // 问题分类模型
|
||||
@@ -254,6 +253,7 @@ weight: 708
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
@@ -264,7 +264,8 @@ weight: 708
|
||||
"name": "GPT35-1106",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"outputPrice": 0,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
@@ -276,7 +277,7 @@ weight: 708
|
||||
"maxContext": 1600,
|
||||
"maxResponse": 4000,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"outputPrice": 0
|
||||
}
|
||||
],
|
||||
"vectorModels": [ // 向量模型
|
||||
|
||||
@@ -28,7 +28,7 @@ weight: 910
|
||||
### 源码部署
|
||||
|
||||
1. 根据上面的环境配置配置好环境,具体教程自行 GPT;
|
||||
2. 下载 [python 文件](app.py)
|
||||
2. 下载 [python 文件](https://github.com/labring/FastGPT/tree/main/python/reranker/bge-reranker-base)
|
||||
3. 在命令行输入命令 `pip install -r requirments.txt`;
|
||||
4. 按照[https://huggingface.co/BAAI/bge-reranker-base](https://huggingface.co/BAAI/bge-reranker-base)下载模型仓库到app.py同级目录
|
||||
5. 添加环境变量 `export ACCESS_TOKEN=XXXXXX` 配置 token,这里的 token 只是加一层验证,防止接口被人盗用,默认值为 `ACCESS_TOKEN` ;
|
||||
|
||||
@@ -10,13 +10,18 @@ weight: 707
|
||||
## 推荐配置
|
||||
|
||||
{{< table "table-hover table-striped-columns" >}}
|
||||
| 环境 | 推荐配置(单节点) |
|
||||
| ---- | ---- |
|
||||
| 测试 | 2c2g |
|
||||
| 100w 组向量 | 4c16g |
|
||||
| 500w 组向量 | 16c64g |
|
||||
| 环境 | 最低配置(单节点) | 推荐配置 |
|
||||
| ---- | ---- | ---- |
|
||||
| 测试 | 2c2g | 2c4g |
|
||||
| 100w 组向量 | 4c8g 50GB | 4c16g 50GB |
|
||||
| 500w 组向量 | 8c32g | 16c64g 200GB |
|
||||
{{< /table >}}
|
||||
|
||||
## 部署架构图
|
||||
|
||||

|
||||
|
||||
|
||||
### 1. 准备好代理环境(国外服务器可忽略)
|
||||
|
||||
确保可以访问 OpenAI,具体方案可以参考:[代理方案](/docs/development/proxy/)。或直接在 Sealos 上 [部署 OneAPI](/docs/development/one-api),既解决代理问题也能实现多 Key 轮询、接入其他大模型。
|
||||
@@ -27,7 +32,7 @@ FastGPT 使用了 one-api 项目来管理模型池,其可以兼容 OpenAI 、A
|
||||
|
||||
可选择 [Sealos 快速部署 OneAPI](/docs/development/one-api),更多部署方法可参考该项目的 [README](https://github.com/songquanpeng/one-api),也可以直接通过以下按钮一键部署:
|
||||
|
||||
[](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Done-api)
|
||||
<a href="https://template.cloud.sealos.io/deploy?templateName=one-api" rel="external" target="_blank"><img src="https://cdn.jsdelivr.us/gh/labring-actions/templates@main/Deploy-on-Sealos.svg" alt="Deploy on Sealos"/></a>
|
||||
|
||||
## 一、安装 Docker 和 docker-compose
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ weight: 705
|
||||
|
||||
## 开始本地开发
|
||||
|
||||
**Tips**
|
||||
|
||||
{{% alert context="success" %}}
|
||||
1. 用户默认的时区为 `Asia/Shanghai`,非 linux 环境时候,获取系统时间会异常,本地开发时候,可以将用户的时区调整成 UTC(+0)。
|
||||
2. 建议先服务器装好**数据库**,再进行本地开发。
|
||||
{{% /alert %}}
|
||||
|
||||
### 1. Fork 存储库
|
||||
|
||||
@@ -62,7 +62,7 @@ git clone git@github.com:<github_username>/FastGPT.git
|
||||
|
||||
**注意:json 配置文件不能包含注释,介绍中为了方便看才加入的注释**
|
||||
|
||||
这个文件大部分时候不需要修改。只需要关注 SystemParams 里的参数:
|
||||
这个文件大部分时候不需要修改。只需要关注 `systemEnv` 里的参数:
|
||||
|
||||
- `vectorMaxProcess`: 向量生成最大进程,根据数据库和 key 的并发数来决定,通常单个 120 号,2c4g 服务器设置 10~15。
|
||||
- `qaMaxProcess`: QA 生成最大进程
|
||||
@@ -115,4 +115,4 @@ FastGPT 在`pnpm i`后会执行`postinstall`脚本,用于自动生成`ChakraUI
|
||||
|
||||
遇到困难了吗?有任何问题吗? 加入微信群与开发者和用户保持沟通。
|
||||
|
||||
<center><image width="400px" src="https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg" /></center>
|
||||
<img width="400px" src="https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg" class="medium-zoom-image" />
|
||||
|
||||
@@ -17,7 +17,7 @@ MySQL 版本支持多实例,高并发。
|
||||
|
||||
直接点击以下按钮即可一键部署 👇
|
||||
|
||||
[](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Done-api)
|
||||
<a href="https://template.cloud.sealos.io/deploy?templateName=one-api" rel="external" target="_blank"><img src="https://cdn.jsdelivr.us/gh/labring-actions/templates@main/Deploy-on-Sealos.svg" alt="Deploy on Sealos"/></a>
|
||||
|
||||
部署完后会跳转「应用管理」,数据库在另一个应用「数据库」中。需要等待 1~3 分钟数据库运行后才能访问成功。
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ FastGPT 的 API Key **有 2 类**,一类是全局通用的 key (无法直接
|
||||
|
||||
| 通用key | 应用特定 key |
|
||||
| --------------------- | --------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
## 基本配置
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ weight: 860
|
||||
## 配置教程
|
||||
### 1. 配置身份校验地址
|
||||
|
||||

|
||||

|
||||
|
||||
配置校验地址后,在每次分享链接使用时,都会向对应的地址发起校验和上报请求。
|
||||
|
||||
@@ -251,7 +251,7 @@ curl --location --request POST '{{host}}/shareAuth/finish' \
|
||||
|
||||
### 1. 创建3个Laf接口
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
@@ -19,13 +19,17 @@ images: []
|
||||
|
||||
## 通用问题
|
||||
|
||||
### 能否纯本地允许
|
||||
|
||||
可以。需要准备好向量模型和LLM模型。
|
||||
|
||||
### insufficient_user_quota user quota is not enough
|
||||
|
||||
OneAPI 账号的余额不足,默认 root 用户只有 200 刀,可以手动修改。
|
||||
|
||||
### xxx渠道找不到
|
||||
|
||||
OneAPI 中没有配置该模型渠道。
|
||||
OneAPI 中没有配置该模型渠道。或者是修改了配置文件中一部分的模型,但没有全部修改。
|
||||
|
||||
### 页面中可以正常回复,API 报错
|
||||
|
||||
@@ -35,6 +39,15 @@ OneAPI 中没有配置该模型渠道。
|
||||
|
||||
OneAPI 的 API Key 配置错误,需要修改`OPENAI_API_KEY`环境变量,并重启容器(先 stop 然后 rm 掉,最后再 up -d 运行一次)。可以`exec`进入容器,`env`查看环境变量是否生效。
|
||||
|
||||
### 其他模型没法进行问题分类/内容提取
|
||||
|
||||
需要给其他模型配置`toolChoice=false`,就会默认走提示词模式。目前内置提示词仅针对了商业模型API进行测试,国内外的商业模型基本都可用。
|
||||
|
||||
### 页面崩溃
|
||||
|
||||
1. 关闭翻译
|
||||
2. 检查配置文件是否正常加载,如果没有正常加载会导致缺失系统信息,在某些操作下会导致空指针。
|
||||
|
||||
## Docker 部署常见问题
|
||||
|
||||
### 如何更新?
|
||||
@@ -96,7 +109,7 @@ mongo连接失败,检查
|
||||
|
||||
### TypeError: Cannot read properties of null (reading 'useMemo' )
|
||||
|
||||
用 Node18 试试,可能最新的 Node 有问题。 本地开发流程:
|
||||
删除所有的`node_modules`,用 Node18 重新 install 试试,可能最新的 Node 有问题。 本地开发流程:
|
||||
|
||||
1. 根目录: `pnpm i`
|
||||
2. 复制 `config.json` -> `config.local.json`
|
||||
|
||||
@@ -7,9 +7,14 @@ toc: true
|
||||
weight: 706
|
||||
---
|
||||
|
||||
## 部署架构图
|
||||
|
||||

|
||||
|
||||
## 一键部署
|
||||
Sealos 的服务器在国外,不需要额外处理网络问题,无需服务器、无需魔法、无需域名,支持高并发 & 动态伸缩。点击以下按钮即可一键部署 👇
|
||||
|
||||
[](https://cloud.sealos.io/?openapp=system-fastdeploy%3FtemplateName%3Dfastgpt)
|
||||
<a href="https://template.cloud.sealos.io/deploy?templateName=fastgpt" rel="external" target="_blank"><img src="https://cdn.jsdelivr.us/gh/labring-actions/templates@main/Deploy-on-Sealos.svg" alt="Deploy on Sealos"/></a>
|
||||
|
||||
由于需要部署数据库,部署完后需要等待 2~4 分钟才能正常访问。默认用了最低配置,首次访问时会有些慢。
|
||||
|
||||
@@ -19,11 +24,13 @@ Sealos 的服务器在国外,不需要额外处理网络问题,无需服务
|
||||
|
||||

|
||||
|
||||
> 用户名:`root`
|
||||
>
|
||||
> 密码就是刚刚一键部署时设置的环境变量
|
||||
### 登录
|
||||
|
||||
## 修改配置文件和环境变量
|
||||
用户名:`root`
|
||||
|
||||
密码是刚刚一键部署时设置的`root_password`
|
||||
|
||||
### 修改配置文件和环境变量
|
||||
|
||||
在 Sealos 中,你可以打开`应用管理`(App Launchpad)看到部署的 FastGPT,可以打开`数据库`(Database)看到对应的数据库。
|
||||
|
||||
@@ -35,13 +42,9 @@ Sealos 的服务器在国外,不需要额外处理网络问题,无需服务
|
||||
在 Sealos 上,FastGPT 一共运行了 1 个服务和 2 个数据库,如暂停和删除请注意数据库一同操作。(你可以白天启动,晚上暂停它们,省钱大法)
|
||||
{{% /alert %}}
|
||||
|
||||
## 更新
|
||||
### 更新
|
||||
|
||||
点击重启会自动拉取最新镜像更新,请确保镜像`tag`正确。
|
||||
|
||||
## 部署架构图
|
||||
|
||||

|
||||
点击变更或重启会自动拉取镜像更新,请确保镜像`tag`正确。建议不要使用`latest`,改成固定版本号。
|
||||
|
||||
## Sealos 使用
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ CREATE INDEX CONCURRENTLY vector_index ON modeldata USING hnsw (vector vector_ip
|
||||
|
||||
| | |
|
||||
| --------------------- | --------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,16 @@ weight: 830
|
||||
|
||||
为了减少代码重复度,我们对配置文件做了一些修改:[点击查看最新的配置文件](/docs/development/configuration/)
|
||||
|
||||
## 商业版变更
|
||||
|
||||
1. 更新商业版镜像到 4.6.6 版本。
|
||||
2. 将旧版配置文件中的 `SystemParams.pluginBaseUrl` 放置到环境变量中:
|
||||
|
||||
PRO_URL=商业版镜像地址(此处不再需要以 /api 结尾),例如:
|
||||
PRO_URL=http://fastgpt-plugin.ns-hsss5d.svc.cluster.local:3000
|
||||
|
||||
3. 原本在配置文件中的 `FeConfig` 已被移除,可以直接打开新的商业版镜像外网地址进行配置。包括 FastGPT 的各个参数和模型都可以直接在商业版镜像中配置,无需再变更 `config.json` 文件。
|
||||
|
||||
## V4.6.6 更新说明
|
||||
|
||||
1. 查看 [FastGPT 2024 RoadMap](https://github.com/labring/FastGPT?tab=readme-ov-file#-%E5%9C%A8%E7%BA%BF%E4%BD%BF%E7%94%A8)
|
||||
|
||||
33
docSite/content/docs/development/upgrading/467.md
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: 'V4.6.7(需要初始化)'
|
||||
description: 'FastGPT V4.6.7'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 829
|
||||
---
|
||||
|
||||
## 1。执行初始化 API
|
||||
|
||||
发起 1 个 HTTP 请求 ({{rootkey}} 替换成环境变量里的 `rootkey`,{{host}} 替换成自己域名)
|
||||
|
||||
1. https://xxxxx/api/admin/initv464
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{{host}}/api/admin/initv467' \
|
||||
--header 'rootkey: {{rootkey}}' \
|
||||
--header 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
初始化说明:
|
||||
1. 将 images 重新关联到数据集(不初始化也问题不大,就是可能会留下永久脏数据)
|
||||
|
||||
|
||||
## V4.6.7 更新说明
|
||||
|
||||
1. 修改了知识库UI及新的导入交互方式。
|
||||
2. 优化知识库和对话的数据索引。
|
||||
3. 知识库 openAPI,支持通过 API 操作知识库。(文档待补充)
|
||||
4. 新增 - 输入框变量提示。输入 { 号后将会获得可用变量提示。根据社区针对高级编排的反馈,我们计划于 2 月份的版本中,优化变量内容,支持模块的局部变量以及更多全局变量写入。
|
||||
5. 修复 - API 对话时,chatId 冲突问题。
|
||||
6. 修复 - Iframe 嵌入网页可能导致的 window.onLoad 冲突。
|
||||
@@ -36,13 +36,13 @@ FastGPT 升级包括两个步骤:
|
||||
|
||||
2. 选择对应的应用 - 点击右边三个点 - 变更
|
||||
|
||||

|
||||

|
||||
|
||||
3. 修改镜像 - 确认变更
|
||||
|
||||
如果要修改配置文件,可以拉到下面的`配置文件`进行修改。
|
||||
|
||||

|
||||

|
||||
|
||||
## Docker-Compose 修改镜像
|
||||
|
||||
@@ -66,7 +66,7 @@ docker-compose up -d
|
||||
|
||||
Sealos 中,你可以在下图中找到你的域名:
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
### 如何获取 rootkey
|
||||
|
||||
@@ -113,9 +113,9 @@ Tips: 建议根据不同的场景,每种知识库仅选择1类数据类型,
|
||||
|
||||
| 通用模板配置及效果 | 问答模板配置及效果 |
|
||||
| --- | --- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
#### 严格模板
|
||||
|
||||
@@ -123,7 +123,7 @@ Tips: 建议根据不同的场景,每种知识库仅选择1类数据类型,
|
||||
|
||||
| 非严格模板效果 | 选择严格模板 | 严格模板效果 |
|
||||
| --- | --- | --- |
|
||||
|  |  | |
|
||||
|  |  | |
|
||||
|
||||
#### 提示词设计思路
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ FastGPT 采用了 RAG 中的 Embedding 方案构建知识库,要使用好 Fast
|
||||
|
||||
FastGPT 采用了 `PostgresSQL` 的 `PG Vector` 插件作为向量检索器,索引为`HNSW`。且`PostgresSQL`仅用于向量检索,`MongoDB`用于其他数据的存取。
|
||||
|
||||
在`PostgresSQL`的表中,设置一个 `index` 字段用于存储向量,以及一个`data_id`用于在`MongoDB`中寻找对应的映射值。多个`index`可以对应一组`data_id`,也就是说,一组向量可以对应多组数据。在进行检索时,相同数据会进行合并。
|
||||
在`MongoDB`的`dataset.datas`表中,会存储向量原数据的信息,同时有一个`indexes`字段,会记录其对应的向量ID,这是一个数组,也就是说,一组向量可以对应多组数据。
|
||||
|
||||
在`PostgresSQL`的表中,设置一个 `index` 字段用于存储向量。在检索时,会先召回向量,再根据向量的ID,去`MongoDB`中寻找原数据内容,如果对应了同一组原数据,则进行合并,向量得分取最高得分。
|
||||
|
||||

|
||||
|
||||
@@ -80,7 +82,7 @@ FastGPT 采用了 `PostgresSQL` 的 `PG Vector` 插件作为向量检索器,
|
||||
|
||||
有些数据较为独特,可能需要单独的进行预处理分割后再导入 FastGPT,此时可以选择 csv 导入,可批量的将处理好的数据导入。
|
||||
|
||||

|
||||

|
||||
|
||||
### 导入数据方案5 - API导入
|
||||
|
||||
|
||||
@@ -69,9 +69,9 @@ HTTP 模块允许你调用任意 GET/POST 类型的 HTTP 接口,从而实现
|
||||
2. 可以通过内容提取模块,实现自然语言转结构化数据,从而实现复杂的逻辑操作。
|
||||
3. 内容提取 + HTTP 模块允许你无限扩展。
|
||||
|
||||
**难点**
|
||||
**困难点**
|
||||
|
||||
1. 模型对连续对话的分类和提取能力不足
|
||||
1. 模型对连续对话时,分类和提取能力不足
|
||||
|
||||
|
||||
# 附件
|
||||
|
||||
@@ -40,7 +40,7 @@ weight: 406
|
||||
|
||||
1. 找到查询天气的 API 接口
|
||||
|
||||

|
||||

|
||||
|
||||
2. 由于我想要的效果是用户可以随意问接下来一周内任意时间的天气(比如用户可以问“接下来一周的天气适合晾被子吗”),所以选择了上面接口的这个格式:https://api.vvhan.com/api/weather?city=徐州&type=week
|
||||
|
||||
@@ -109,7 +109,7 @@ if __name__ == '__main__':
|
||||
|
||||
第一步就是对用户问题进行分类,如图红框部分:
|
||||
|
||||

|
||||

|
||||
|
||||
### 接口参数获取及处理
|
||||
|
||||
@@ -132,7 +132,7 @@ if __name__ == '__main__':
|
||||
|
||||
如图:
|
||||
|
||||

|
||||

|
||||
|
||||
### AI 总结回复
|
||||
|
||||
@@ -147,7 +147,7 @@ if __name__ == '__main__':
|
||||
|
||||
如图:
|
||||
|
||||

|
||||

|
||||
|
||||
## 模块编排
|
||||
|
||||
@@ -1526,7 +1526,7 @@ PS2:配置中的问题分类还包含着“联网搜索”,这个是另一
|
||||
|
||||
## 效果图
|
||||
|
||||

|
||||

|
||||
|
||||
## 后记
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ defaultContentLanguage = 'zh-cn'
|
||||
["JetBrains Mono", "500, 700"]
|
||||
]
|
||||
|
||||
sans_serif_font = "LXGW WenKai Screen" # Default is System font
|
||||
secondary_font = "LXGW WenKai Screen" # Default is System font
|
||||
#sans_serif_font = "LXGW WenKai Screen" # Default is System font
|
||||
#secondary_font = "LXGW WenKai Screen" # Default is System font
|
||||
mono_font = "JetBrains Mono" # Default is System font
|
||||
|
||||
[params.footer]
|
||||
|
||||
32
docSite/layouts/docs/_markup/render-image.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{{ $dest := .Destination }}
|
||||
{{ $text := .PlainText }}
|
||||
{{ $url := urls.Parse $dest }}
|
||||
|
||||
{{ if .Title }}
|
||||
<figure>
|
||||
{{ if eq $url.Scheme "" }}
|
||||
{{ with $image := resources.Get $dest }}
|
||||
{{ if eq $image.MediaType.SubType "svg" }}
|
||||
{{ $image.Content | safeHTML }}
|
||||
{{ else }}
|
||||
<img src="{{ $image.RelPermalink | safeURL }}" alt="{{ $text }}" width="{{ $image.Width }}" height="{{ $image.Height }}" loading="lazy" class="medium-zoom-image">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<img src="{{ $dest | safeURL }}" alt="{{ $text }}" loading="lazy" class="medium-zoom-image">
|
||||
{{ end }}
|
||||
<figcaption>{{ .Title | markdownify }}</figcaption>
|
||||
</figure>
|
||||
{{ else }}
|
||||
{{ if eq $url.Scheme "" }}
|
||||
{{ with $image := resources.Get $dest }}
|
||||
{{ if eq $image.MediaType.SubType "svg" }}
|
||||
{{ $image.Content | safeHTML }}
|
||||
{{ else }}
|
||||
<img src="{{ $image.RelPermalink | safeURL }}" alt="{{ $text }}" width="{{ $image.Width }}" height="{{ $image.Height }}" loading="lazy" class="medium-zoom-image">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
<img src="{{ $dest | safeURL }}" alt="{{ $text }}" loading="lazy" class="medium-zoom-image">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@@ -58,13 +58,13 @@
|
||||
|
||||
<!-- change -->
|
||||
<script
|
||||
src="https://jsdelivr.icloudnative.io/npm/medium-zoom/dist/medium-zoom.min.js"
|
||||
src="https://cdn.jsdelivr.us/npm/medium-zoom/dist/medium-zoom.min.js"
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
></script>
|
||||
|
||||
<script>
|
||||
const images = Array.from(document.querySelectorAll(".main-content img"));
|
||||
const images = Array.from(document.querySelectorAll('.medium-zoom-image'));
|
||||
images.forEach((img) => {
|
||||
mediumZoom(img, {
|
||||
margin: 0 /* The space outside the zoomed image */,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<head>
|
||||
<script defer type="text/javascript" src="{{ "js/jsdelivr-auto-fallback.js" | absURL }}"></script>
|
||||
<meta charset="utf-8" />
|
||||
<title>
|
||||
{{- $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
|
||||
@@ -105,5 +106,6 @@
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<!-- change -->
|
||||
<link rel="stylesheet" href="https://jsdelivr.icloudnative.io/npm/lxgw-wenkai-screen-webfont@1.1.0/style.css" />
|
||||
<link rel="preload" href="https://cdn.jsdelivr.us/npm/lxgw-wenkai-screen-webfont@1.1.0/style.css" as="style" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.us/npm/lxgw-wenkai-screen-webfont@1.1.0/style.css" />
|
||||
</head>
|
||||
179
docSite/static/js/jsdelivr-auto-fallback.js
Normal file
@@ -0,0 +1,179 @@
|
||||
((document) => {
|
||||
'use strict';
|
||||
let fastNode;
|
||||
let failed;
|
||||
let isRunning;
|
||||
const DEST_LIST = [
|
||||
'cdn.jsdelivr.us',
|
||||
'jsd.cdn.zzko.cn',
|
||||
'jsd.onmicrosoft.cn'
|
||||
];
|
||||
const PREFIX = '//';
|
||||
const SOURCE = DEST_LIST[0];
|
||||
const starTime = Date.now();
|
||||
const TIMEOUT = 1000;
|
||||
const STORE_KEY = 'jsdelivr-auto-fallback';
|
||||
const TEST_PATH = '/gh/PipecraftNet/jsdelivr-auto-fallback@main/empty.css?';
|
||||
const shouldReplace = (text) => text && text.includes(PREFIX + SOURCE);
|
||||
const replace = (text) => text.replace(PREFIX + SOURCE, PREFIX + fastNode);
|
||||
const setTimeout = window.setTimeout;
|
||||
const $ = document.querySelectorAll.bind(document);
|
||||
|
||||
const replaceElementSrc = () => {
|
||||
let element;
|
||||
let value;
|
||||
for (element of $('link[rel="stylesheet"]')) {
|
||||
value = element.href;
|
||||
if (shouldReplace(value) && !value.includes(TEST_PATH)) {
|
||||
element.href = replace(value);
|
||||
}
|
||||
}
|
||||
|
||||
for (element of $('script')) {
|
||||
value = element.src;
|
||||
if (shouldReplace(value)) {
|
||||
const newNode = document.createElement('script');
|
||||
newNode.src = replace(value);
|
||||
element.defer = true;
|
||||
element.src = '';
|
||||
element.before(newNode);
|
||||
element.remove();
|
||||
}
|
||||
}
|
||||
|
||||
for (element of $('img')) {
|
||||
value = element.src;
|
||||
if (shouldReplace(value)) {
|
||||
// Used to cancel loading. Without this line it will remain pending status.
|
||||
element.src = '';
|
||||
element.src = replace(value);
|
||||
}
|
||||
}
|
||||
|
||||
// All elements that have a style attribute
|
||||
for (element of $('*[style]')) {
|
||||
value = element.getAttribute('style');
|
||||
if (shouldReplace(value)) {
|
||||
element.setAttribute('style', replace(value));
|
||||
}
|
||||
}
|
||||
|
||||
for (element of $('style')) {
|
||||
value = element.innerHTML;
|
||||
if (shouldReplace(value)) {
|
||||
element.innerHTML = replace(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const tryReplace = () => {
|
||||
if (!isRunning && failed && fastNode) {
|
||||
console.warn(SOURCE + ' is not available. Use ' + fastNode);
|
||||
isRunning = true;
|
||||
setTimeout(replaceElementSrc, 0);
|
||||
// Some need to wait for a while
|
||||
setTimeout(replaceElementSrc, 20);
|
||||
// Replace dynamically added elements
|
||||
setInterval(replaceElementSrc, 500);
|
||||
}
|
||||
};
|
||||
|
||||
const checkAvailable = (url, callback) => {
|
||||
let timeoutId;
|
||||
const newNode = document.createElement('link');
|
||||
const handleResult = (isSuccess) => {
|
||||
if (!timeoutId) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = 0;
|
||||
// Used to cancel loading. Without this line it will remain pending status.
|
||||
if (!isSuccess) newNode.href = 'data:text/css;base64,';
|
||||
newNode.remove();
|
||||
callback(isSuccess);
|
||||
};
|
||||
|
||||
timeoutId = setTimeout(handleResult, TIMEOUT);
|
||||
|
||||
newNode.addEventListener('error', () => handleResult(false));
|
||||
newNode.addEventListener('load', () => handleResult(true));
|
||||
newNode.rel = 'stylesheet';
|
||||
newNode.text = 'text/css';
|
||||
newNode.href = url + TEST_PATH + starTime;
|
||||
document.head.insertAdjacentElement('afterbegin', newNode);
|
||||
};
|
||||
|
||||
const cached = (() => {
|
||||
try {
|
||||
return Object.assign(
|
||||
{},
|
||||
JSON.parse(localStorage.getItem(STORE_KEY) || '{}')
|
||||
);
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
})();
|
||||
|
||||
const main = () => {
|
||||
cached.time = starTime;
|
||||
cached.failed = false;
|
||||
cached.fastNode = null;
|
||||
|
||||
for (const url of DEST_LIST) {
|
||||
checkAvailable('https://' + url, (isAvailable) => {
|
||||
// console.log(url, Date.now() - starTime, Boolean(isAvailable));
|
||||
if (!isAvailable && url === SOURCE) {
|
||||
failed = true;
|
||||
cached.failed = true;
|
||||
}
|
||||
|
||||
if (isAvailable && !fastNode) {
|
||||
fastNode = url;
|
||||
}
|
||||
|
||||
if (isAvailable && !cached.fastNode) {
|
||||
cached.fastNode = url;
|
||||
}
|
||||
|
||||
tryReplace();
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
// If all domains are timeout
|
||||
if (failed && !fastNode) {
|
||||
fastNode = DEST_LIST[1];
|
||||
tryReplace();
|
||||
}
|
||||
|
||||
localStorage.setItem(STORE_KEY, JSON.stringify(cached));
|
||||
}, TIMEOUT + 100);
|
||||
};
|
||||
|
||||
if (
|
||||
cached.time &&
|
||||
starTime - cached.time < 60 * 60 * 1000 &&
|
||||
cached.failed &&
|
||||
cached.fastNode
|
||||
) {
|
||||
failed = true;
|
||||
fastNode = cached.fastNode;
|
||||
tryReplace();
|
||||
setTimeout(main, 1000);
|
||||
} else if (document.head) {
|
||||
main();
|
||||
} else {
|
||||
const observer = new MutationObserver(() => {
|
||||
if (document.head) {
|
||||
observer.disconnect();
|
||||
main();
|
||||
}
|
||||
});
|
||||
const observerOptions = {
|
||||
childList: true,
|
||||
subtree: true
|
||||
};
|
||||
observer.observe(document, observerOptions);
|
||||
}
|
||||
})(document);
|
||||
@@ -1,43 +0,0 @@
|
||||
mixed-port: 7890
|
||||
allow-lan: false
|
||||
bind-address: '*'
|
||||
mode: rule
|
||||
log-level: warning
|
||||
dns:
|
||||
enable: true
|
||||
ipv6: false
|
||||
nameserver:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
cache-size: 400
|
||||
proxies:
|
||||
|
||||
proxy-groups:
|
||||
- {
|
||||
name: '♻️ 自动选择',
|
||||
type: url-test,
|
||||
proxies:
|
||||
[
|
||||
香港V02×1.5,
|
||||
ABC,
|
||||
印度01,
|
||||
台湾03,
|
||||
新加坡02,
|
||||
新加坡03,
|
||||
日本01,
|
||||
日本02,
|
||||
新加坡01,
|
||||
美国01,
|
||||
美国02,
|
||||
台湾01,
|
||||
台湾02
|
||||
],
|
||||
url: 'https://api.openai.com',
|
||||
interval: 3600
|
||||
}
|
||||
rules:
|
||||
- 'DOMAIN-SUFFIX,google.com,♻️ 自动选择'
|
||||
- 'DOMAIN-SUFFIX,ai.fastgpt.in,♻️ 自动选择'
|
||||
- 'DOMAIN-SUFFIX,openai.com,♻️ 自动选择'
|
||||
- 'DOMAIN-SUFFIX,api.openai.com,♻️ 自动选择'
|
||||
- 'MATCH,DIRECT'
|
||||
@@ -1,18 +0,0 @@
|
||||
export ALL_PROXY=socks5://127.0.0.1:7891
|
||||
export http_proxy=http://127.0.0.1:7890
|
||||
export https_proxy=http://127.0.0.1:7890
|
||||
export HTTP_PROXY=http://127.0.0.1:7890
|
||||
export HTTPS_PROXY=http://127.0.0.1:7890
|
||||
|
||||
OLD_PROCESS=$(pgrep clash)
|
||||
if [ ! -z "$OLD_PROCESS" ]; then
|
||||
echo "Killing old process: $OLD_PROCESS"
|
||||
kill $OLD_PROCESS
|
||||
fi
|
||||
sleep 2
|
||||
|
||||
cd /root/fastgpt/clash/fast
|
||||
rm -f ./nohup.out || true
|
||||
rm -f ./cache.db || true
|
||||
nohup ./clash-linux-amd64-v3 -d ./ &
|
||||
echo "Restart clash fast"
|
||||
@@ -1,10 +0,0 @@
|
||||
export ALL_PROXY=''
|
||||
export http_proxy=''
|
||||
export https_proxy=''
|
||||
export HTTP_PROXY=''
|
||||
export HTTPS_PROXY=''
|
||||
OLD_PROCESS=$(pgrep clash)
|
||||
if [ ! -z "$OLD_PROCESS" ]; then
|
||||
echo "Killing old process: $OLD_PROCESS"
|
||||
kill $OLD_PROCESS
|
||||
fi
|
||||
11
packages/global/common/file/api.d.ts
vendored
@@ -1,9 +1,15 @@
|
||||
export type UploadImgProps = {
|
||||
base64Img: string;
|
||||
import { MongoImageTypeEnum } from './image/constants';
|
||||
|
||||
export type preUploadImgProps = {
|
||||
type: `${MongoImageTypeEnum}`;
|
||||
|
||||
expiredTime?: Date;
|
||||
metadata?: Record<string, any>;
|
||||
shareId?: string;
|
||||
};
|
||||
export type UploadImgProps = preUploadImgProps & {
|
||||
base64Img: string;
|
||||
};
|
||||
|
||||
export type UrlFetchParams = {
|
||||
urlList: string[];
|
||||
@@ -11,6 +17,7 @@ export type UrlFetchParams = {
|
||||
};
|
||||
export type UrlFetchResponse = {
|
||||
url: string;
|
||||
title: string;
|
||||
content: string;
|
||||
selector?: string;
|
||||
}[];
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
export enum BucketNameEnum {
|
||||
dataset = 'dataset'
|
||||
}
|
||||
export const bucketNameMap = {
|
||||
[BucketNameEnum.dataset]: {
|
||||
label: 'common.file.bucket.dataset'
|
||||
}
|
||||
};
|
||||
|
||||
export const FileBaseUrl = '/api/common/file/read';
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
export const fileImgs = [
|
||||
{ suffix: 'pdf', src: '/imgs/files/pdf.svg' },
|
||||
{ suffix: 'csv', src: '/imgs/files/csv.svg' },
|
||||
{ suffix: '(doc|docs)', src: '/imgs/files/doc.svg' },
|
||||
{ suffix: 'txt', src: '/imgs/files/txt.svg' },
|
||||
{ suffix: 'md', src: '/imgs/files/markdown.svg' }
|
||||
{ suffix: 'pdf', src: 'file/fill/pdf' },
|
||||
{ suffix: 'csv', src: 'file/fill/csv' },
|
||||
{ suffix: '(doc|docs)', src: 'file/fill/doc' },
|
||||
{ suffix: 'txt', src: 'file/fill/txt' },
|
||||
{ suffix: 'md', src: 'file/fill/markdown' },
|
||||
{ suffix: 'html', src: 'file/fill/html' }
|
||||
|
||||
// { suffix: '.', src: '/imgs/files/file.svg' }
|
||||
];
|
||||
|
||||
export function getFileIcon(name = '', defaultImg = '/imgs/files/file.svg') {
|
||||
export function getFileIcon(name = '', defaultImg = 'file/fill/file') {
|
||||
return fileImgs.find((item) => new RegExp(item.suffix, 'gi').test(name))?.src || defaultImg;
|
||||
}
|
||||
|
||||
52
packages/global/common/file/image/constants.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
export const imageBaseUrl = '/api/system/img/';
|
||||
|
||||
export enum MongoImageTypeEnum {
|
||||
systemAvatar = 'systemAvatar',
|
||||
appAvatar = 'appAvatar',
|
||||
pluginAvatar = 'pluginAvatar',
|
||||
datasetAvatar = 'datasetAvatar',
|
||||
userAvatar = 'userAvatar',
|
||||
teamAvatar = 'teamAvatar',
|
||||
|
||||
chatImage = 'chatImage',
|
||||
collectionImage = 'collectionImage'
|
||||
}
|
||||
export const mongoImageTypeMap = {
|
||||
[MongoImageTypeEnum.systemAvatar]: {
|
||||
label: 'common.file.type.appAvatar',
|
||||
unique: true
|
||||
},
|
||||
[MongoImageTypeEnum.appAvatar]: {
|
||||
label: 'common.file.type.appAvatar',
|
||||
unique: true
|
||||
},
|
||||
[MongoImageTypeEnum.pluginAvatar]: {
|
||||
label: 'common.file.type.pluginAvatar',
|
||||
unique: true
|
||||
},
|
||||
[MongoImageTypeEnum.datasetAvatar]: {
|
||||
label: 'common.file.type.datasetAvatar',
|
||||
unique: true
|
||||
},
|
||||
[MongoImageTypeEnum.userAvatar]: {
|
||||
label: 'common.file.type.userAvatar',
|
||||
unique: true
|
||||
},
|
||||
[MongoImageTypeEnum.teamAvatar]: {
|
||||
label: 'common.file.type.teamAvatar',
|
||||
unique: true
|
||||
},
|
||||
|
||||
[MongoImageTypeEnum.chatImage]: {
|
||||
label: 'common.file.type.chatImage',
|
||||
unique: false
|
||||
},
|
||||
[MongoImageTypeEnum.collectionImage]: {
|
||||
label: 'common.file.type.collectionImage',
|
||||
unique: false
|
||||
}
|
||||
};
|
||||
|
||||
export const uniqueImageTypeList = Object.entries(mongoImageTypeMap)
|
||||
.filter(([key, value]) => value.unique)
|
||||
.map(([key]) => key as `${MongoImageTypeEnum}`);
|
||||
14
packages/global/common/file/image/type.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { MongoImageTypeEnum } from './constants';
|
||||
|
||||
export type MongoImageSchemaType = {
|
||||
_id: string;
|
||||
teamId: string;
|
||||
binary: Buffer;
|
||||
createTime: Date;
|
||||
expiredTime?: Date;
|
||||
type: `${MongoImageTypeEnum}`;
|
||||
|
||||
metadata?: {
|
||||
relatedId?: string; // This id is associated with a set of images
|
||||
};
|
||||
};
|
||||
10
packages/global/common/math/date.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// The number of days left in the month is calculated as 30 days per month, and less than 1 day is calculated as 1 day
|
||||
export const getMonthRemainingDays = () => {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = now.getMonth();
|
||||
const date = now.getDate();
|
||||
const days = new Date(year, month + 1, 0).getDate();
|
||||
const remainingDays = days - date;
|
||||
return remainingDays + 1;
|
||||
};
|
||||
@@ -15,10 +15,10 @@ export const simpleMarkdownText = (rawText: string) => {
|
||||
return `[${cleanedLinkText}](${url})`;
|
||||
});
|
||||
|
||||
// replace special \.* ……
|
||||
const reg1 = /\\([-.!`_(){}\[\]])/g;
|
||||
// replace special #\.* ……
|
||||
const reg1 = /\\([#`!*()+-_\[\]{}\\.])/g;
|
||||
if (reg1.test(rawText)) {
|
||||
rawText = rawText.replace(/\\([`!*()+-_\[\]{}\\.])/g, '$1');
|
||||
rawText = rawText.replace(reg1, '$1');
|
||||
}
|
||||
|
||||
// replace \\n
|
||||
@@ -45,14 +45,15 @@ export const uploadMarkdownBase64 = async ({
|
||||
uploadImgController
|
||||
}: {
|
||||
rawText: string;
|
||||
uploadImgController: (base64: string) => Promise<string>;
|
||||
uploadImgController?: (base64: string) => Promise<string>;
|
||||
}) => {
|
||||
// match base64, upload and replace it
|
||||
const base64Regex = /data:image\/.*;base64,([^\)]+)/g;
|
||||
const base64Arr = rawText.match(base64Regex) || [];
|
||||
// upload base64 and replace it
|
||||
await Promise.all(
|
||||
base64Arr.map(async (base64Img) => {
|
||||
if (uploadImgController) {
|
||||
// match base64, upload and replace it
|
||||
const base64Regex = /data:image\/.*;base64,([^\)]+)/g;
|
||||
const base64Arr = rawText.match(base64Regex) || [];
|
||||
|
||||
// upload base64 and replace it
|
||||
for await (const base64Img of base64Arr) {
|
||||
try {
|
||||
const str = await uploadImgController(base64Img);
|
||||
|
||||
@@ -61,8 +62,8 @@ export const uploadMarkdownBase64 = async ({
|
||||
rawText = rawText.replace(base64Img, '');
|
||||
rawText = rawText.replace(/!\[.*\]\(\)/g, '');
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove white space on both sides of the picture
|
||||
const trimReg = /(!\[.*\]\(.*\))\s*/g;
|
||||
@@ -70,5 +71,20 @@ export const uploadMarkdownBase64 = async ({
|
||||
rawText = rawText.replace(trimReg, '$1');
|
||||
}
|
||||
|
||||
return simpleMarkdownText(rawText);
|
||||
return rawText;
|
||||
};
|
||||
|
||||
export const markdownProcess = async ({
|
||||
rawText,
|
||||
uploadImgController
|
||||
}: {
|
||||
rawText: string;
|
||||
uploadImgController?: (base64: string) => Promise<string>;
|
||||
}) => {
|
||||
const imageProcess = await uploadMarkdownBase64({
|
||||
rawText,
|
||||
uploadImgController
|
||||
});
|
||||
|
||||
return simpleMarkdownText(imageProcess);
|
||||
};
|
||||
|
||||
@@ -13,13 +13,12 @@ export const splitText2Chunks = (props: {
|
||||
chunkLen: number;
|
||||
overlapRatio?: number;
|
||||
customReg?: string[];
|
||||
countTokens?: boolean;
|
||||
}): {
|
||||
chunks: string[];
|
||||
tokens: number;
|
||||
chars: number;
|
||||
overlapRatio?: number;
|
||||
} => {
|
||||
let { text = '', chunkLen, overlapRatio = 0.2, customReg = [], countTokens = true } = props;
|
||||
let { text = '', chunkLen, overlapRatio = 0.2, customReg = [] } = props;
|
||||
const splitMarker = 'SPLIT_HERE_SPLIT_HERE';
|
||||
const codeBlockMarker = 'CODE_BLOCK_LINE_MARKER';
|
||||
const overlapLen = Math.round(chunkLen * overlapRatio);
|
||||
@@ -240,13 +239,11 @@ export const splitText2Chunks = (props: {
|
||||
mdTitle: ''
|
||||
}).map((chunk) => chunk?.replaceAll(codeBlockMarker, '\n') || ''); // restore code block
|
||||
|
||||
const tokens = countTokens
|
||||
? chunks.reduce((sum, chunk) => sum + countPromptTokens(chunk, 'system'), 0)
|
||||
: 0;
|
||||
const chars = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
||||
|
||||
return {
|
||||
chunks,
|
||||
tokens
|
||||
chars
|
||||
};
|
||||
} catch (err) {
|
||||
throw new Error(getErrText(err));
|
||||
|
||||
@@ -33,6 +33,12 @@ export function countPromptTokens(
|
||||
) {
|
||||
const enc = getTikTokenEnc();
|
||||
const text = `${role}\n${prompt}`;
|
||||
|
||||
// too large a text will block the thread
|
||||
if (text.length > 15000) {
|
||||
return text.length * 1.7;
|
||||
}
|
||||
|
||||
try {
|
||||
const encodeText = enc.encode(text);
|
||||
return encodeText.length + role.length; // 补充 role 估算值
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export const formatTime2YMDHM = (time: Date) => dayjs(time).format('YYYY-MM-DD HH:mm');
|
||||
export const formatTime2YMDHM = (time?: Date) =>
|
||||
time ? dayjs(time).format('YYYY-MM-DD HH:mm') : '';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import crypto from 'crypto';
|
||||
import { customAlphabet } from 'nanoid';
|
||||
|
||||
/* check string is a web link */
|
||||
export function strIsLink(str?: string) {
|
||||
@@ -36,3 +37,7 @@ export function replaceVariable(text: string, obj: Record<string, string | numbe
|
||||
}
|
||||
return text || '';
|
||||
}
|
||||
|
||||
export const getNanoid = (size = 12) => {
|
||||
return customAlphabet('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', size)();
|
||||
};
|
||||
|
||||
@@ -51,10 +51,15 @@ export type FastGPTFeConfigsType = {
|
||||
favicon?: string;
|
||||
customApiDomain?: string;
|
||||
customSharePageDomain?: string;
|
||||
subscription?: {
|
||||
datasetStoreFreeSize?: number;
|
||||
datasetStorePrice?: number;
|
||||
};
|
||||
|
||||
uploadFileMaxSize?: number;
|
||||
};
|
||||
|
||||
export type SystemEnvType = {
|
||||
pluginBaseUrl?: string;
|
||||
openapiPrefix?: string;
|
||||
vectorMaxProcess: number;
|
||||
qaMaxProcess: number;
|
||||
@@ -64,4 +69,5 @@ export type SystemEnvType = {
|
||||
declare global {
|
||||
var feConfigs: FastGPTFeConfigsType;
|
||||
var systemEnv: SystemEnvType;
|
||||
var systemInitd: boolean;
|
||||
}
|
||||
|
||||
2
packages/global/core/app/type.d.ts
vendored
@@ -4,7 +4,7 @@ import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import type { AIChatModuleProps, DatasetModuleProps } from '../module/node/type.d';
|
||||
import { VariableInputEnum } from '../module/constants';
|
||||
import { SelectedDatasetType } from '../module/api';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constant';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
|
||||
export interface AppSchema {
|
||||
_id: string;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ModuleOutputKeyEnum, ModuleInputKeyEnum } from '../module/constants';
|
||||
import type { FlowNodeInputItemType } from '../module/node/type.d';
|
||||
import { getGuideModule, splitGuideModule } from '../module/utils';
|
||||
import { ModuleItemType } from '../module/type.d';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constant';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
|
||||
export const getDefaultAppForm = (templateId = 'fastgpt-universal'): AppSimpleEditFormType => {
|
||||
return {
|
||||
|
||||
@@ -31,16 +31,16 @@ export enum ChatSourceEnum {
|
||||
}
|
||||
export const ChatSourceMap = {
|
||||
[ChatSourceEnum.test]: {
|
||||
name: 'chat.logs.test'
|
||||
name: 'core.chat.logs.test'
|
||||
},
|
||||
[ChatSourceEnum.online]: {
|
||||
name: 'chat.logs.online'
|
||||
name: 'core.chat.logs.online'
|
||||
},
|
||||
[ChatSourceEnum.share]: {
|
||||
name: 'chat.logs.share'
|
||||
name: 'core.chat.logs.share'
|
||||
},
|
||||
[ChatSourceEnum.api]: {
|
||||
name: 'chat.logs.api'
|
||||
name: 'core.chat.logs.api'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
4
packages/global/core/chat/type.d.ts
vendored
@@ -4,7 +4,7 @@ import { ChatRoleEnum, ChatSourceEnum, ChatStatusEnum } from './constants';
|
||||
import { FlowNodeTypeEnum } from '../module/node/constant';
|
||||
import { ModuleOutputKeyEnum } from '../module/constants';
|
||||
import { AppSchema } from '../app/type';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constant';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
|
||||
export type ChatSchema = {
|
||||
_id: string;
|
||||
@@ -22,6 +22,7 @@ export type ChatSchema = {
|
||||
shareId?: string;
|
||||
outLinkUid?: string;
|
||||
content: ChatItemType[];
|
||||
metadata?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type ChatWithAppSchema = Omit<ChatSchema, 'appId'> & {
|
||||
@@ -91,6 +92,7 @@ export type moduleDispatchResType = {
|
||||
runningTime?: number;
|
||||
inputTokens?: number;
|
||||
outputTokens?: number;
|
||||
charsLength?: number;
|
||||
model?: string;
|
||||
query?: string;
|
||||
contextTotalLen?: number;
|
||||
|
||||
50
packages/global/core/dataset/api.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { DatasetDataIndexItemType, DatasetSchemaType } from './type';
|
||||
import { DatasetCollectionTrainingModeEnum, DatasetCollectionTypeEnum } from './constant';
|
||||
import { TrainingModeEnum, DatasetCollectionTypeEnum } from './constants';
|
||||
import type { LLMModelItemType } from '../ai/model.d';
|
||||
|
||||
/* ================= dataset ===================== */
|
||||
@@ -16,28 +16,47 @@ export type DatasetUpdateBody = {
|
||||
};
|
||||
|
||||
/* ================= collection ===================== */
|
||||
export type CreateDatasetCollectionParams = {
|
||||
datasetId: string;
|
||||
export type DatasetCollectionChunkMetadataType = {
|
||||
parentId?: string;
|
||||
trainingType?: `${TrainingModeEnum}`;
|
||||
chunkSize?: number;
|
||||
chunkSplitter?: string;
|
||||
qaPrompt?: string;
|
||||
metadata?: Record<string, any>;
|
||||
};
|
||||
export type CreateDatasetCollectionParams = DatasetCollectionChunkMetadataType & {
|
||||
datasetId: string;
|
||||
name: string;
|
||||
type: `${DatasetCollectionTypeEnum}`;
|
||||
trainingType?: `${DatasetCollectionTrainingModeEnum}`;
|
||||
chunkSize?: number;
|
||||
fileId?: string;
|
||||
rawLink?: string;
|
||||
qaPrompt?: string;
|
||||
rawTextLength?: number;
|
||||
hashRawText?: string;
|
||||
metadata?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type ApiCreateDatasetCollectionParams = DatasetCollectionChunkMetadataType & {
|
||||
datasetId: string;
|
||||
};
|
||||
export type TextCreateDatasetCollectionParams = ApiCreateDatasetCollectionParams & {
|
||||
name: string;
|
||||
text: string;
|
||||
};
|
||||
export type LinkCreateDatasetCollectionParams = ApiCreateDatasetCollectionParams & {
|
||||
link: string;
|
||||
};
|
||||
export type FileCreateDatasetCollectionParams = ApiCreateDatasetCollectionParams & {
|
||||
name: string;
|
||||
rawTextLength: number;
|
||||
hashRawText: string;
|
||||
|
||||
fileMetadata?: Record<string, any>;
|
||||
collectionMetadata?: Record<string, any>;
|
||||
};
|
||||
|
||||
/* ================= data ===================== */
|
||||
export type PgSearchRawType = {
|
||||
id: string;
|
||||
team_id: string;
|
||||
tmb_id: string;
|
||||
collection_id: string;
|
||||
data_id: string;
|
||||
score: number;
|
||||
};
|
||||
export type PushDatasetDataChunkProps = {
|
||||
@@ -51,3 +70,14 @@ export type PostWebsiteSyncParams = {
|
||||
datasetId: string;
|
||||
billId: string;
|
||||
};
|
||||
|
||||
export type PushDatasetDataProps = {
|
||||
collectionId: string;
|
||||
data: PushDatasetDataChunkProps[];
|
||||
trainingMode: `${TrainingModeEnum}`;
|
||||
prompt?: string;
|
||||
billId?: string;
|
||||
};
|
||||
export type PushDatasetDataResponse = {
|
||||
insertLen: number;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ export enum DatasetTypeEnum {
|
||||
}
|
||||
export const DatasetTypeMap = {
|
||||
[DatasetTypeEnum.folder]: {
|
||||
icon: 'core/dataset/folderDataset',
|
||||
icon: 'common/folderFill',
|
||||
label: 'core.dataset.Folder Dataset',
|
||||
collectionLabel: 'common.Folder'
|
||||
},
|
||||
@@ -53,23 +53,7 @@ export const DatasetCollectionTypeMap = {
|
||||
name: 'core.dataset.link'
|
||||
},
|
||||
[DatasetCollectionTypeEnum.virtual]: {
|
||||
name: 'core.dataset.Virtual File'
|
||||
}
|
||||
};
|
||||
export enum DatasetCollectionTrainingModeEnum {
|
||||
manual = 'manual',
|
||||
chunk = 'chunk',
|
||||
qa = 'qa'
|
||||
}
|
||||
export const DatasetCollectionTrainingTypeMap = {
|
||||
[DatasetCollectionTrainingModeEnum.manual]: {
|
||||
label: 'core.dataset.collection.training.type manual'
|
||||
},
|
||||
[DatasetCollectionTrainingModeEnum.chunk]: {
|
||||
label: 'core.dataset.collection.training.type chunk'
|
||||
},
|
||||
[DatasetCollectionTrainingModeEnum.qa]: {
|
||||
label: 'core.dataset.collection.training.type qa'
|
||||
name: 'core.dataset.Manual collection'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -120,10 +104,12 @@ export enum TrainingModeEnum {
|
||||
|
||||
export const TrainingTypeMap = {
|
||||
[TrainingModeEnum.chunk]: {
|
||||
label: 'core.dataset.training.type chunk'
|
||||
label: 'core.dataset.training.Chunk mode',
|
||||
tooltip: 'core.dataset.import.Chunk Split Tip'
|
||||
},
|
||||
[TrainingModeEnum.qa]: {
|
||||
label: 'core.dataset.training.type qa'
|
||||
label: 'core.dataset.training.QA mode',
|
||||
tooltip: 'core.dataset.import.QA Import Tip'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -184,4 +170,8 @@ export const SearchScoreTypeMap = {
|
||||
}
|
||||
};
|
||||
|
||||
export const FolderAvatarSrc = '/imgs/files/folder.svg';
|
||||
export const FolderIcon = 'file/fill/folder';
|
||||
export const FolderImgUrl = '/imgs/files/folder.svg';
|
||||
|
||||
export const CustomCollectionIcon = 'common/linkBlue';
|
||||
export const LinkCollectionIcon = 'common/linkBlue';
|
||||
2
packages/global/core/dataset/controller.d.ts
vendored
@@ -21,7 +21,7 @@ export type UpdateDatasetDataProps = {
|
||||
};
|
||||
|
||||
export type PatchIndexesProps = {
|
||||
type: 'create' | 'update' | 'delete';
|
||||
type: 'create' | 'update' | 'delete' | 'unChange';
|
||||
index: Omit<DatasetDataIndexItemType, 'dataId'> & {
|
||||
dataId?: string;
|
||||
};
|
||||
|
||||
10
packages/global/core/dataset/type.d.ts
vendored
@@ -8,7 +8,7 @@ import {
|
||||
DatasetTypeEnum,
|
||||
SearchScoreTypeEnum,
|
||||
TrainingModeEnum
|
||||
} from './constant';
|
||||
} from './constants';
|
||||
|
||||
/* schema */
|
||||
export type DatasetSchemaType = {
|
||||
@@ -42,15 +42,21 @@ export type DatasetCollectionSchemaType = {
|
||||
type: `${DatasetCollectionTypeEnum}`;
|
||||
createTime: Date;
|
||||
updateTime: Date;
|
||||
|
||||
trainingType: `${TrainingModeEnum}`;
|
||||
chunkSize: number;
|
||||
chunkSplitter?: string;
|
||||
qaPrompt?: string;
|
||||
|
||||
fileId?: string;
|
||||
rawLink?: string;
|
||||
qaPrompt?: string;
|
||||
|
||||
rawTextLength?: number;
|
||||
hashRawText?: string;
|
||||
metadata?: {
|
||||
webPageSelector?: string;
|
||||
relatedImgId?: string; // The id of the associated image collections
|
||||
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DatasetCollectionTypeEnum, DatasetDataIndexTypeEnum } from './constant';
|
||||
import { TrainingModeEnum, DatasetCollectionTypeEnum, DatasetDataIndexTypeEnum } from './constants';
|
||||
import { getFileIcon } from '../../common/file/icon';
|
||||
import { strIsLink } from '../../common/string/tools';
|
||||
|
||||
@@ -7,18 +7,13 @@ export function getCollectionIcon(
|
||||
name = ''
|
||||
) {
|
||||
if (type === DatasetCollectionTypeEnum.folder) {
|
||||
return '/imgs/files/folder.svg';
|
||||
return 'common/folderFill';
|
||||
}
|
||||
if (type === DatasetCollectionTypeEnum.link) {
|
||||
return '/imgs/files/link.svg';
|
||||
return 'common/linkBlue';
|
||||
}
|
||||
if (type === DatasetCollectionTypeEnum.virtual) {
|
||||
if (name === '手动录入') {
|
||||
return '/imgs/files/manual.svg';
|
||||
} else if (name === '手动标注') {
|
||||
return '/imgs/files/mark.svg';
|
||||
}
|
||||
return '/imgs/files/collection.svg';
|
||||
return 'file/fill/manual';
|
||||
}
|
||||
return getFileIcon(name);
|
||||
}
|
||||
@@ -30,19 +25,14 @@ export function getSourceNameIcon({
|
||||
sourceId?: string;
|
||||
}) {
|
||||
if (strIsLink(sourceId)) {
|
||||
return '/imgs/files/link.svg';
|
||||
return 'common/linkBlue';
|
||||
}
|
||||
const fileIcon = getFileIcon(sourceName, '');
|
||||
if (fileIcon) {
|
||||
return fileIcon;
|
||||
}
|
||||
|
||||
if (sourceName === '手动录入') {
|
||||
return '/imgs/files/manual.svg';
|
||||
} else if (sourceName === '手动标注') {
|
||||
return '/imgs/files/mark.svg';
|
||||
}
|
||||
return '/imgs/files/collection.svg';
|
||||
return 'file/fill/manual';
|
||||
}
|
||||
|
||||
export function getDefaultIndex(props?: { q?: string; a?: string; dataId?: string }) {
|
||||
@@ -55,3 +45,8 @@ export function getDefaultIndex(props?: { q?: string; a?: string; dataId?: strin
|
||||
dataId
|
||||
};
|
||||
}
|
||||
|
||||
export const predictDataLimitLength = (mode: `${TrainingModeEnum}`, data: any[]) => {
|
||||
if (mode === TrainingModeEnum.qa) return data.length * 20;
|
||||
return data.length;
|
||||
};
|
||||
|
||||
@@ -113,5 +113,16 @@ export enum VariableInputEnum {
|
||||
textarea = 'textarea',
|
||||
select = 'select'
|
||||
}
|
||||
export const variableMap = {
|
||||
[VariableInputEnum.input]: {
|
||||
icon: 'core/app/variable/input'
|
||||
},
|
||||
[VariableInputEnum.textarea]: {
|
||||
icon: 'core/app/variable/textarea'
|
||||
},
|
||||
[VariableInputEnum.select]: {
|
||||
icon: 'core/app/variable/select'
|
||||
}
|
||||
};
|
||||
|
||||
export const DYNAMIC_INPUT_KEY = 'DYNAMIC_INPUT_KEY';
|
||||
|
||||
@@ -54,10 +54,9 @@ export enum FlowNodeTypeEnum {
|
||||
pluginModule = 'pluginModule',
|
||||
pluginInput = 'pluginInput',
|
||||
pluginOutput = 'pluginOutput',
|
||||
cfr = 'cfr',
|
||||
cfr = 'cfr'
|
||||
|
||||
// abandon
|
||||
variable = 'variable'
|
||||
}
|
||||
|
||||
export const EDGE_TYPE = 'default';
|
||||
|
||||
@@ -23,15 +23,15 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.textAnswer,
|
||||
flowType: FlowNodeTypeEnum.chatNode,
|
||||
avatar: '/imgs/module/AI.png',
|
||||
name: 'AI 对话',
|
||||
intro: 'AI 大模型对话',
|
||||
name: 'core.module.template.Ai chat',
|
||||
intro: 'core.module.template.Ai chat intro',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiModel,
|
||||
type: FlowNodeInputTypeEnum.selectChatModel,
|
||||
label: '对话模型',
|
||||
label: 'core.module.input.label.aiModel',
|
||||
required: true,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
@@ -41,42 +41,31 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatTemperature,
|
||||
type: FlowNodeInputTypeEnum.hidden, // Set in the pop-up window
|
||||
label: '温度',
|
||||
label: '',
|
||||
value: 0,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 0,
|
||||
max: 10,
|
||||
step: 1,
|
||||
markList: [
|
||||
{ label: '严谨', value: 0 },
|
||||
{ label: '发散', value: 10 }
|
||||
],
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatMaxToken,
|
||||
type: FlowNodeInputTypeEnum.hidden, // Set in the pop-up window
|
||||
label: '回复上限',
|
||||
label: '',
|
||||
value: 2000,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 100,
|
||||
max: 4000,
|
||||
step: 50,
|
||||
markList: [
|
||||
{ label: '100', value: 100 },
|
||||
{
|
||||
label: `${4000}`,
|
||||
value: 4000
|
||||
}
|
||||
],
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatIsResponseText,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '返回AI内容',
|
||||
label: '',
|
||||
value: true,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
showTargetInApp: false,
|
||||
@@ -85,7 +74,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatQuoteTemplate,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用内容模板',
|
||||
label: '',
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -93,7 +82,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatQuotePrompt,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用内容提示词',
|
||||
label: '',
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -110,7 +99,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiSystemPrompt,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
label: '系统提示词',
|
||||
label: 'core.ai.Prompt',
|
||||
max: 300,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
description: chatNodeSystemPromptTip,
|
||||
@@ -122,8 +111,8 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatDatasetQuote,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '引用内容',
|
||||
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
|
||||
label: 'core.module.input.label.Quote',
|
||||
description: 'core.module.input.description.Quote',
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
@@ -134,16 +123,16 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
Output_Template_UserChatInput,
|
||||
{
|
||||
key: ModuleOutputKeyEnum.history,
|
||||
label: '新的上下文',
|
||||
description: '将本次回复内容拼接上历史记录,作为新的上下文返回',
|
||||
label: 'core.module.output.label.New context',
|
||||
description: 'core.module.output.description.New context',
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: ModuleOutputKeyEnum.answerText,
|
||||
label: 'AI回复内容',
|
||||
description: '将在 stream 回复完毕后触发',
|
||||
label: 'core.module.output.label.Ai response content',
|
||||
description: 'core.module.output.description.Ai response content',
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
|
||||
@@ -9,19 +9,17 @@ export const AssignedAnswerModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.textAnswer,
|
||||
flowType: FlowNodeTypeEnum.answerNode,
|
||||
avatar: '/imgs/module/reply.png',
|
||||
name: '指定回复',
|
||||
intro: '该模块可以直接回复一段指定的内容。常用于引导、提示',
|
||||
name: 'core.module.template.Assigned reply',
|
||||
intro: 'core.module.template.Assigned reply intro',
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.answerText,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '回复的内容',
|
||||
description:
|
||||
'可以使用 \\n 来实现连续换行。\n可以通过外部模块输入实现回复,外部模块输入时会覆盖当前填写的内容。\n如传入非字符串类型数据将会自动转成字符串',
|
||||
placeholder:
|
||||
'可以使用 \\n 来实现连续换行。\n可以通过外部模块输入实现回复,外部模块输入时会覆盖当前填写的内容。\n如传入非字符串类型数据将会自动转成字符串',
|
||||
label: 'core.module.input.label.Response content',
|
||||
description: 'core.module.input.description.Response content',
|
||||
placeholder: 'core.module.input.description.Response content',
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
}
|
||||
|
||||
@@ -17,12 +17,8 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.functionCall,
|
||||
flowType: FlowNodeTypeEnum.classifyQuestion,
|
||||
avatar: '/imgs/module/cq.png',
|
||||
name: '问题分类',
|
||||
intro: `根据用户的历史记录和当前问题判断该次提问的类型。可以添加多组问题类型,下面是一个模板例子:
|
||||
类型1: 打招呼
|
||||
类型2: 关于商品“使用”问题
|
||||
类型3: 关于商品“购买”问题
|
||||
类型4: 其他问题`,
|
||||
name: 'core.module.template.Classify question',
|
||||
intro: `core.module.template.Classify question intro`,
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
@@ -30,7 +26,7 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.aiModel,
|
||||
type: FlowNodeInputTypeEnum.selectCQModel,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '分类模型',
|
||||
label: 'core.module.input.label.Classify model',
|
||||
required: true,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -39,11 +35,9 @@ export const ClassifyQuestionModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.aiSystemPrompt,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '背景知识',
|
||||
description:
|
||||
'你可以添加一些特定内容的介绍,从而更好的识别用户的问题类型。这个内容通常是给模型介绍一个它不知道的内容。',
|
||||
placeholder:
|
||||
'例如: \n1. AIGC(人工智能生成内容)是指使用人工智能技术自动或半自动地生成数字内容,如文本、图像、音乐、视频等。\n2. AIGC技术包括但不限于自然语言处理、计算机视觉、机器学习和深度学习。这些技术可以创建新内容或修改现有内容,以满足特定的创意、教育、娱乐或信息需求。',
|
||||
label: 'core.module.input.label.Background',
|
||||
description: 'core.module.input.description.Background',
|
||||
placeholder: 'core.module.input.placeholder.Classify background',
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
},
|
||||
|
||||
@@ -17,8 +17,8 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.functionCall,
|
||||
flowType: FlowNodeTypeEnum.contentExtract,
|
||||
avatar: '/imgs/module/extract.png',
|
||||
name: '文本内容提取',
|
||||
intro: '可从文本中提取指定的数据,例如:sql语句、搜索关键词、代码等',
|
||||
name: 'core.module.template.Extract field',
|
||||
intro: 'core.module.template.Extract field intro',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
@@ -26,7 +26,7 @@ export const ContextExtractModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.aiModel,
|
||||
type: FlowNodeInputTypeEnum.selectExtractModel,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '提取模型',
|
||||
label: 'core.module.input.label.LLM',
|
||||
required: true,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
|
||||
@@ -12,22 +12,22 @@ import {
|
||||
} from '../../constants';
|
||||
import { Input_Template_Switch, Input_Template_UserChatInput } from '../input';
|
||||
import { Output_Template_Finish, Output_Template_UserChatInput } from '../output';
|
||||
import { DatasetSearchModeEnum } from '../../../dataset/constant';
|
||||
import { DatasetSearchModeEnum } from '../../../dataset/constants';
|
||||
|
||||
export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.datasetSearchNode,
|
||||
templateType: ModuleTemplateTypeEnum.functionCall,
|
||||
flowType: FlowNodeTypeEnum.datasetSearchNode,
|
||||
avatar: '/imgs/module/db.png',
|
||||
name: '知识库搜索',
|
||||
intro: '去知识库中搜索对应的答案。可作为 AI 对话引用参考。',
|
||||
name: 'core.module.template.Dataset search',
|
||||
intro: 'core.module.template.Dataset search intro',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetSelectList,
|
||||
type: FlowNodeInputTypeEnum.selectDataset,
|
||||
label: '关联的知识库',
|
||||
label: 'core.module.input.label.Select dataset',
|
||||
value: [],
|
||||
valueType: ModuleIOValueTypeEnum.selectDataset,
|
||||
list: [],
|
||||
@@ -38,7 +38,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetSimilarity,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '最低相关性',
|
||||
label: '',
|
||||
value: 0.4,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 0,
|
||||
@@ -54,8 +54,7 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetLimit,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用上限',
|
||||
description: '单次搜索最大的 Tokens 数量,中文约1字=1.7Tokens,英文约1字=1Tokens',
|
||||
label: '',
|
||||
value: 1500,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
showTargetInApp: false,
|
||||
@@ -93,23 +92,22 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
Output_Template_UserChatInput,
|
||||
{
|
||||
key: ModuleOutputKeyEnum.datasetIsEmpty,
|
||||
label: '搜索结果为空',
|
||||
label: 'core.module.output.label.Search result empty',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: ModuleOutputKeyEnum.datasetUnEmpty,
|
||||
label: '搜索结果不为空',
|
||||
label: 'core.module.output.label.Search result not empty',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
targets: []
|
||||
},
|
||||
{
|
||||
key: ModuleOutputKeyEnum.datasetQuoteQA,
|
||||
label: '引用内容',
|
||||
description:
|
||||
'始终返回数组,如果希望搜索结果为空时执行额外操作,需要用到上面的两个输入以及目标模块的触发器',
|
||||
label: 'core.module.output.label.Quote',
|
||||
description: 'core.module.output.label.Quote intro',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
targets: []
|
||||
|
||||
@@ -17,8 +17,8 @@ export const HttpModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.externalCall,
|
||||
flowType: FlowNodeTypeEnum.httpRequest,
|
||||
avatar: '/imgs/module/http.png',
|
||||
name: 'HTTP模块',
|
||||
intro: '可以发出一个 HTTP POST 请求,实现更为复杂的操作(联网搜索、数据库查询等)',
|
||||
name: 'core.module.template.Http request',
|
||||
intro: 'core.module.template.Http request intro',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
|
||||
@@ -22,8 +22,8 @@ export const RunAppModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.externalCall,
|
||||
flowType: FlowNodeTypeEnum.runApp,
|
||||
avatar: '/imgs/module/app.png',
|
||||
name: '应用调用',
|
||||
intro: '可以选择一个其他应用进行调用',
|
||||
name: 'core.module.template.Running app',
|
||||
intro: 'core.module.template.Running app intro',
|
||||
showStatus: true,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
|
||||
@@ -8,7 +8,7 @@ export const RunPluginModule: FlowModuleTemplateType = {
|
||||
flowType: FlowNodeTypeEnum.pluginModule,
|
||||
avatar: '/imgs/module/custom.png',
|
||||
intro: '',
|
||||
name: '自定义模块',
|
||||
name: '',
|
||||
showStatus: false,
|
||||
inputs: [], // [{key:'pluginId'},...]
|
||||
outputs: []
|
||||
|
||||
@@ -8,14 +8,14 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.userGuide,
|
||||
flowType: FlowNodeTypeEnum.userGuide,
|
||||
avatar: '/imgs/module/userGuide.png',
|
||||
name: '用户引导',
|
||||
name: 'core.module.template.User guide',
|
||||
intro: userGuideTip,
|
||||
inputs: [
|
||||
{
|
||||
key: ModuleInputKeyEnum.welcomeText,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '开场白',
|
||||
label: 'core.app.Welcome Text',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -23,7 +23,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.variables,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '对话框变量',
|
||||
label: 'core.module.Variable',
|
||||
value: [],
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -32,7 +32,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.questionGuide,
|
||||
valueType: ModuleIOValueTypeEnum.boolean,
|
||||
type: FlowNodeInputTypeEnum.switch,
|
||||
label: '问题引导',
|
||||
label: '',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
@@ -40,7 +40,7 @@ export const UserGuideModule: FlowModuleTemplateType = {
|
||||
key: ModuleInputKeyEnum.tts,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
label: '语音播报',
|
||||
label: '',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ export const UserInputModule: FlowModuleTemplateType = {
|
||||
templateType: ModuleTemplateTypeEnum.systemInput,
|
||||
flowType: FlowNodeTypeEnum.questionInput,
|
||||
avatar: '/imgs/module/userChatInput.png',
|
||||
name: '用户问题(入口)',
|
||||
intro: '用户输入的内容。该模块通常作为应用的入口,用户在发送消息后会首先执行该模块。',
|
||||
name: 'core.module.template.Chat entrance',
|
||||
intro: 'core.module.template.Chat entrance intro',
|
||||
inputs: [
|
||||
{
|
||||
key: ModuleInputKeyEnum.userChatInput,
|
||||
type: FlowNodeInputTypeEnum.systemInput,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
label: '用户问题',
|
||||
label: 'core.module.input.label.user question',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export const UserInputModule: FlowModuleTemplateType = {
|
||||
outputs: [
|
||||
{
|
||||
key: ModuleOutputKeyEnum.userChatInput,
|
||||
label: '用户问题',
|
||||
label: 'core.module.input.label.user question',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
targets: []
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
export const chatNodeSystemPromptTip =
|
||||
'模型固定的引导词,通过调整该内容,可以引导模型聊天方向。该内容会被固定在上下文的开头。可使用变量,例如 {{language}}';
|
||||
export const userGuideTip = '可以在对话前设置引导语,设置全局变量,设置下一步指引';
|
||||
export const welcomeTextTip =
|
||||
'每次对话开始前,发送一个初始内容。支持标准 Markdown 语法,可使用的额外标记:\n[快捷按键]: 用户点击后可以直接发送该问题';
|
||||
export const variableTip =
|
||||
'可以在对话开始前,要求用户填写一些内容作为本轮对话的特定变量。该模块位于开场引导之后。\n变量可以通过 {{变量key}} 的形式注入到其他模块 string 类型的输入中,例如:提示词、限定词等';
|
||||
export const chatNodeSystemPromptTip = 'core.app.tip.chatNodeSystemPromptTip';
|
||||
export const userGuideTip = 'core.app.tip.userGuideTip';
|
||||
export const welcomeTextTip = 'core.app.tip.welcomeTextTip';
|
||||
export const variableTip = 'core.app.tip.variableTip';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { FlowNodeInputTypeEnum, FlowNodeTypeEnum } from './node/constant';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum } from './constants';
|
||||
import { ModuleIOValueTypeEnum, ModuleInputKeyEnum, variableMap } from './constants';
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './node/type';
|
||||
import { AppTTSConfigType, ModuleItemType, VariableItemType } from './type';
|
||||
import { Input_Template_Switch } from './template/input';
|
||||
@@ -94,3 +94,12 @@ export function plugin2ModuleIO(
|
||||
: []
|
||||
};
|
||||
}
|
||||
|
||||
export const formatVariablesIcon = (
|
||||
variables: VariableItemType[]
|
||||
): (VariableItemType & { icon: string })[] => {
|
||||
return variables.map((item) => ({
|
||||
...item,
|
||||
icon: variableMap[item.type]?.icon
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"encoding": "^0.1.13",
|
||||
"js-tiktoken": "^1.0.7",
|
||||
"openai": "4.23.0",
|
||||
"pdfjs-dist": "^4.0.269",
|
||||
"nanoid": "^4.0.1",
|
||||
"timezones-list": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
1
packages/global/support/user/api.d.ts
vendored
@@ -3,7 +3,6 @@ import { OAuthEnum } from './constant';
|
||||
export type PostLoginProps = {
|
||||
username: string;
|
||||
password: string;
|
||||
tmbId?: string;
|
||||
};
|
||||
|
||||
export type OauthLoginProps = {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
export enum InformTypeEnum {
|
||||
system = 'system'
|
||||
system = 'system',
|
||||
admin = 'admin'
|
||||
}
|
||||
|
||||
export const InformTypeMap = {
|
||||
[InformTypeEnum.system]: {
|
||||
label: '系统通知'
|
||||
},
|
||||
[InformTypeEnum.admin]: {
|
||||
label: '管理员'
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { InformTypeEnum } from './constant';
|
||||
import { InformTypeEnum } from './constants';
|
||||
|
||||
export type SendInformProps = {
|
||||
tmbId?: string;
|
||||
|
||||
1
packages/global/support/user/team/type.d.ts
vendored
@@ -9,7 +9,6 @@ export type TeamSchema = {
|
||||
createTime: Date;
|
||||
balance: number;
|
||||
maxSize: number;
|
||||
lastDatasetBillTime: Date;
|
||||
limit: {
|
||||
lastExportDatasetTime: Date;
|
||||
lastWebsiteSyncTime: Date;
|
||||
|
||||
1
packages/global/support/user/type.d.ts
vendored
@@ -13,6 +13,7 @@ export type UserModelSchema = {
|
||||
createTime: number;
|
||||
timezone: string;
|
||||
status: `${UserStatusEnum}`;
|
||||
lastLoginTmbId?: string;
|
||||
openaiAccount?: {
|
||||
key: string;
|
||||
baseUrl: string;
|
||||
|
||||
3
packages/global/support/wallet/bill/api.d.ts
vendored
@@ -3,8 +3,7 @@ import { BillListItemCountType, BillListItemType } from './type';
|
||||
|
||||
export type CreateTrainingBillProps = {
|
||||
name: string;
|
||||
vectorModel?: string;
|
||||
agentModel?: string;
|
||||
datasetId: string;
|
||||
};
|
||||
|
||||
export type ConcatBillProps = BillListItemCountType & {
|
||||
|
||||
@@ -7,7 +7,7 @@ export enum BillSourceEnum {
|
||||
api = 'api',
|
||||
shareLink = 'shareLink',
|
||||
training = 'training',
|
||||
datasetStore = 'datasetStore'
|
||||
datasetExpand = 'datasetExpand'
|
||||
}
|
||||
|
||||
export const BillSourceMap: Record<`${BillSourceEnum}`, string> = {
|
||||
@@ -15,5 +15,5 @@ export const BillSourceMap: Record<`${BillSourceEnum}`, string> = {
|
||||
[BillSourceEnum.api]: 'Api',
|
||||
[BillSourceEnum.shareLink]: '免登录链接',
|
||||
[BillSourceEnum.training]: '数据训练',
|
||||
[BillSourceEnum.datasetStore]: '知识库存储'
|
||||
[BillSourceEnum.datasetExpand]: '知识库扩容'
|
||||
};
|
||||
|
||||
@@ -4,9 +4,8 @@ import { BillSourceEnum } from './constants';
|
||||
export type BillListItemCountType = {
|
||||
inputTokens?: number;
|
||||
outputTokens?: number;
|
||||
textLen?: number;
|
||||
charsLength?: number;
|
||||
duration?: number;
|
||||
dataLen?: number;
|
||||
|
||||
// abandon
|
||||
tokenLen?: number;
|
||||
|
||||
4
packages/global/support/wallet/sub/api.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export type SubDatasetSizeParams = {
|
||||
size: number;
|
||||
renew: boolean;
|
||||
};
|
||||
37
packages/global/support/wallet/sub/constants.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
export enum SubTypeEnum {
|
||||
datasetStore = 'datasetStore'
|
||||
}
|
||||
|
||||
export const subTypeMap = {
|
||||
[SubTypeEnum.datasetStore]: {
|
||||
label: 'support.user.team.subscription.type.datasetStore'
|
||||
}
|
||||
};
|
||||
|
||||
export enum SubModeEnum {
|
||||
month = 'month',
|
||||
year = 'year'
|
||||
}
|
||||
|
||||
export const subModeMap = {
|
||||
[SubModeEnum.month]: {
|
||||
label: 'support.user.team.subscription.mode.month'
|
||||
},
|
||||
[SubModeEnum.year]: {
|
||||
label: 'support.user.team.subscription.mode.year'
|
||||
}
|
||||
};
|
||||
|
||||
export enum SubStatusEnum {
|
||||
active = 'active',
|
||||
expired = 'expired'
|
||||
}
|
||||
|
||||
export const subStatusMap = {
|
||||
[SubStatusEnum.active]: {
|
||||
label: 'support.user.team.subscription.status.active'
|
||||
},
|
||||
[SubStatusEnum.expired]: {
|
||||
label: 'support.user.team.subscription.status.expired'
|
||||
}
|
||||
};
|
||||
12
packages/global/support/wallet/sub/type.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { SubModeEnum, SubStatusEnum, SubTypeEnum } from './constants';
|
||||
|
||||
export type TeamSubSchema = {
|
||||
teamId: string;
|
||||
type: `${SubTypeEnum}`;
|
||||
mode: `${SubModeEnum}`;
|
||||
status: `${SubStatusEnum}`;
|
||||
renew: boolean;
|
||||
startTime: Date;
|
||||
expiredTime: Date;
|
||||
datasetStoreAmount?: number;
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios, { Method, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { FastGPTProUrl } from '../system/constants';
|
||||
|
||||
interface ConfigType {
|
||||
headers?: { [key: string]: string };
|
||||
@@ -70,7 +71,7 @@ instance.interceptors.request.use(requestStart, (err) => Promise.reject(err));
|
||||
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err));
|
||||
|
||||
export function request(url: string, data: any, config: ConfigType, method: Method): any {
|
||||
if (!global.systemEnv || !global.systemEnv?.pluginBaseUrl) {
|
||||
if (!FastGPTProUrl) {
|
||||
console.log('未部署商业版接口', url);
|
||||
return Promise.reject('The The request was denied...');
|
||||
}
|
||||
@@ -84,7 +85,7 @@ export function request(url: string, data: any, config: ConfigType, method: Meth
|
||||
|
||||
return instance
|
||||
.request({
|
||||
baseURL: global.systemEnv.pluginBaseUrl,
|
||||
baseURL: FastGPTProUrl,
|
||||
url,
|
||||
method,
|
||||
data: ['POST', 'PUT'].includes(method) ? data : null,
|
||||
|
||||
6
packages/service/common/file/constants.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import path from 'path';
|
||||
|
||||
export const tmpFileDirPath =
|
||||
process.env.NODE_ENV === 'production' ? '/app/tmp' : path.join(process.cwd(), 'tmp');
|
||||
|
||||
export const previewMaxCharCount = 3000;
|
||||