Compare commits
25 Commits
v4.6.6-alp
...
v4.6.8-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34602b25df | ||
|
|
fc19c4cf09 | ||
|
|
9188752b41 | ||
|
|
6b40062504 | ||
|
|
72d1503fa3 | ||
|
|
2c6dbe13d9 | ||
|
|
318116627c | ||
|
|
379673cae1 | ||
|
|
aab6ee51eb | ||
|
|
91b7d81c1a | ||
|
|
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)
|
||||
}
|
||||
5
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"inlang.vs-code-extension"
|
||||
]
|
||||
}
|
||||
@@ -78,7 +78,7 @@ COPY --from=builder /app/projects/$name/package.json ./package.json
|
||||
COPY --from=workerDeps /app/worker /app/worker
|
||||
# copy config
|
||||
COPY ./projects/$name/data /app/data
|
||||
|
||||
RUN chown -R nextjs:nodejs /app/data
|
||||
|
||||
ENV NODE_ENV production
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
16
README.md
@@ -57,7 +57,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
||||
- [x] 源文件引用追踪
|
||||
- [x] 模块封装,实现多级复用
|
||||
- [x] 混合检索 & 重排
|
||||
- [ ] 自查询规划
|
||||
- [ ] Tool 模块
|
||||
- [ ] 嵌入 [Laf](https://github.com/labring/laf),实现在线编写 HTTP 模块
|
||||
- [ ] 插件封装功能
|
||||
|
||||
@@ -67,10 +67,10 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
||||
- [x] 支持知识库单独设置向量模型
|
||||
- [x] 源文件存储
|
||||
- [x] 支持手动输入,直接分段,QA 拆分导入
|
||||
- [x] 支持 pdf、word、txt、md 等常用文件,支持 url 读取、CSV 批量导入
|
||||
- [ ] 支持 HTML、csv、PPT、Excel 导入
|
||||
- [x] 支持 pdf,docx,txt,html,md,csv
|
||||
- [x] 支持 url 读取、CSV 批量导入
|
||||
- [ ] 支持 PPT、Excel 导入
|
||||
- [ ] 支持文件阅读器
|
||||
- [ ] 支持差异性文件同步
|
||||
- [ ] 更多的数据预处理方案
|
||||
|
||||
`3` 应用调试能力
|
||||
@@ -81,8 +81,8 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
||||
- [ ] 高级编排 DeBug 模式
|
||||
|
||||
`4` OpenAPI 接口
|
||||
- [x] completions 接口 (对齐 GPT 接口)
|
||||
- [ ] 知识库 CRUD
|
||||
- [x] completions 接口 (chat 模式对齐 GPT 接口)
|
||||
- [x] 知识库 CRUD
|
||||
- [ ] 对话 CRUD
|
||||
|
||||
`5` 运营能力
|
||||
@@ -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)
|
||||
@@ -215,4 +215,4 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
||||
1. 允许作为后台服务直接商用,但不允许提供 SaaS 服务。
|
||||
2. 未经商业授权,任何形式的商用服务均需保留相关版权信息。
|
||||
3. 完整请查看 [FastGPT Open Source License](./LICENSE)
|
||||
4. 联系方式:yujinlong@sealos.io,[点击查看商业版定价策略](https://doc.fastgpt.in/docs/commercial)
|
||||
4. 联系方式:yujinlong@sealos.io,[点击查看商业版定价策略](https://doc.fastgpt.in/docs/commercial)
|
||||
|
||||
70
README_en.md
@@ -49,48 +49,52 @@ Cloud: [fastgpt.in](https://fastgpt.in/)
|
||||
|
||||
## 💡 Features
|
||||
|
||||
1. Powerful visual workflows: Effortlessly craft AI applications
|
||||
`1` Application Orchestration Features
|
||||
|
||||
- [x] Simple mode on deck - no need for manual arrangement
|
||||
- [x] User dialogue pre-guidance
|
||||
- [x] Global variables
|
||||
- [x] Knowledge base search
|
||||
- [x] Dialogue via multiple LLM models
|
||||
- [x] Text magic - convert to structured data
|
||||
- [x] Extend with HTTP
|
||||
- [ ] Embed Laf for on-the-fly HTTP module crafting
|
||||
- [x] Directions for the next dialogue steps
|
||||
- [x] Tracking source file references
|
||||
- [ ] Custom file reader
|
||||
- [ ] Modules are packaged into plug-ins to achieve reuse
|
||||
- [x] Offers a straightforward mode, eliminating the need for complex orchestration
|
||||
- [x] Provides clear next-step instructions in dialogues
|
||||
- [x] Facilitates workflow orchestration
|
||||
- [x] Tracks references in source files
|
||||
- [x] Encapsulates modules for enhanced reuse at multiple levels
|
||||
- [x] Combines search and reordering functions
|
||||
- [ ] Includes a tool module
|
||||
- [ ] Integrates [Laf](https://github.com/labring/laf) for online HTTP module creation
|
||||
- [ ] Plugin encapsulation capabilities
|
||||
|
||||
2. Extensive knowledge base preprocessing
|
||||
`2` Knowledge Base Features
|
||||
|
||||
- [x] Reuse and mix multiple knowledge bases
|
||||
- [x] Track chunk modifications and deletions
|
||||
- [x] Supports manual entries, direct segmentation, and QA split imports
|
||||
- [x] Supports URL fetching and batch CSV imports
|
||||
- [x] Supports Set unique vector models for knowledge bases
|
||||
- [x] Store original files
|
||||
- [ ] File learning Agent
|
||||
- [x] Allows for the mixed use of multiple databases
|
||||
- [x] Keeps track of modifications and deletions in data chunks
|
||||
- [x] Enables specific vector models for each knowledge base
|
||||
- [x] Stores original source files
|
||||
- [x] Supports direct input and segment-based QA import
|
||||
- [x] Compatible with a variety of file formats: pdf, docx, txt, html, md, csv
|
||||
- [x] Facilitates URL reading and bulk CSV importing
|
||||
- [ ] Supports PPT and Excel file import
|
||||
- [ ] Features a file reader
|
||||
- [ ] Offers diverse data preprocessing options
|
||||
|
||||
3. Multiple effect testing channels
|
||||
`3` Application Debugging Features
|
||||
|
||||
- [x] Single-point knowledge base search test
|
||||
- [x] Feedback references and ability to modify and delete during dialogue
|
||||
- [x] Complete context presentation
|
||||
- [ ] Complete module intermediate value presentation
|
||||
- [x] Enables targeted search testing within the knowledge base
|
||||
- [x] Allows feedback, editing, and deletion during conversations
|
||||
- [x] Presents the full context of interactions
|
||||
- [x] Displays all intermediate values within modules
|
||||
- [ ] Advanced DeBug mode for orchestration
|
||||
|
||||
4. OpenAPI
|
||||
`4` OpenAPI Interface
|
||||
|
||||
- [x] completions interface (aligned with GPT interface)
|
||||
- [ ] Knowledge base CRUD
|
||||
- [x] The completions interface (aligned with GPT's chat mode interface)
|
||||
- [x] CRUD operations for the knowledge base
|
||||
- [ ] CRUD operations for conversations
|
||||
|
||||
5. Operational functions
|
||||
`5` Operational Features
|
||||
|
||||
- [x] Share without requiring login
|
||||
- [x] Easy embedding with Iframe
|
||||
- [x] Customizable chat window embedding with features like default open, drag-and-drop
|
||||
- [x] Centralizes conversation records for review and annotation
|
||||
|
||||
- [x] Login-free sharing window
|
||||
- [x] One-click embedding with Iframe
|
||||
- [ ] Unified access to dialogue records
|
||||
|
||||
<a href="#readme">
|
||||
<img src="https://img.shields.io/badge/-Back_to_Top-7d09f1.svg" alt="#" align="right">
|
||||
|
||||
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: 95 KiB After Width: | Height: | Size: 155 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. 填写网址和选择器
|
||||
|
||||
|
||||
@@ -13,154 +13,7 @@ weight: 708
|
||||
|
||||
这个配置文件中包含了系统级参数、AI 对话的模型、function 模型等……
|
||||
|
||||
|
||||
## 旧版本配置文件
|
||||
|
||||
以下配置适合 4.6.6-alpha 之前
|
||||
|
||||
```json
|
||||
{
|
||||
"SystemParams": {
|
||||
"pluginBaseUrl": "", // 商业版接口地址
|
||||
"vectorMaxProcess": 15, // 向量生成最大进程,结合数据库性能和 key 来设置
|
||||
"qaMaxProcess": 15, // QA 生成最大进程,结合数据库性能和 key 来设置
|
||||
"pgHNSWEfSearch": 100 // pg vector 索引参数,越大精度高但速度慢
|
||||
},
|
||||
"ChatModels": [ // 对话模型
|
||||
{
|
||||
"model": "gpt-3.5-turbo-1106",
|
||||
"name": "GPT35-1106",
|
||||
"price": 0, // 除以 100000 后等于1个token的价格
|
||||
"maxContext": 16000, // 最大上下文长度
|
||||
"maxResponse": 4000, // 最大回复长度
|
||||
"quoteMaxToken": 2000, // 最大引用内容长度
|
||||
"maxTemperature": 1.2, // 最大温度值
|
||||
"censor": false, // 是否开启敏感词过滤(商业版)
|
||||
"vision": false, // 支持图片输入
|
||||
"defaultSystemChatPrompt": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 16000,
|
||||
"price": 0,
|
||||
"quoteMaxToken": 8000,
|
||||
"maxTemperature": 1.2,
|
||||
"censor": false,
|
||||
"vision": false,
|
||||
"defaultSystemChatPrompt": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "GPT4-8k",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"price": 0,
|
||||
"quoteMaxToken": 4000,
|
||||
"maxTemperature": 1.2,
|
||||
"censor": false,
|
||||
"vision": false,
|
||||
"defaultSystemChatPrompt": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4-vision-preview",
|
||||
"name": "GPT4-Vision",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"price": 0,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1.2,
|
||||
"censor": false,
|
||||
"vision": true,
|
||||
"defaultSystemChatPrompt": ""
|
||||
}
|
||||
],
|
||||
"QAModels": [ // QA 生成模型
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "GPT35-16k",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 16000,
|
||||
"price": 0
|
||||
}
|
||||
],
|
||||
"CQModels": [ // 问题分类模型
|
||||
{
|
||||
"model": "gpt-3.5-turbo-1106",
|
||||
"name": "GPT35-1106",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"price": 0,
|
||||
"toolChoice": true, // 是否支持openai的 toolChoice, 不支持的模型需要设置为 false,会走提示词生成
|
||||
"functionPrompt": ""
|
||||
},
|
||||
{
|
||||
"model": "gpt-4",
|
||||
"name": "GPT4-8k",
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"price": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
],
|
||||
"ExtractModels": [ // 内容提取模型
|
||||
{
|
||||
"model": "gpt-3.5-turbo-1106",
|
||||
"name": "GPT35-1106",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"price": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
],
|
||||
"QGModels": [ // 生成下一步指引
|
||||
{
|
||||
"model": "gpt-3.5-turbo-1106",
|
||||
"name": "GPT35-1106",
|
||||
"maxContext": 1600,
|
||||
"maxResponse": 4000,
|
||||
"price": 0
|
||||
}
|
||||
],
|
||||
"VectorModels": [ // 向量模型
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
"price": 0.2,
|
||||
"defaultToken": 700,
|
||||
"maxToken": 3000
|
||||
}
|
||||
],
|
||||
"ReRankModels": [], // 重排模型,暂时填空数组
|
||||
"AudioSpeechModels": [
|
||||
{
|
||||
"model": "tts-1",
|
||||
"name": "OpenAI TTS1",
|
||||
"price": 0,
|
||||
"baseUrl": "",
|
||||
"key": "",
|
||||
"voices": [
|
||||
{ "label": "Alloy", "value": "alloy", "bufferId": "openai-Alloy" },
|
||||
{ "label": "Echo", "value": "echo", "bufferId": "openai-Echo" },
|
||||
{ "label": "Fable", "value": "fable", "bufferId": "openai-Fable" },
|
||||
{ "label": "Onyx", "value": "onyx", "bufferId": "openai-Onyx" },
|
||||
{ "label": "Nova", "value": "nova", "bufferId": "openai-Nova" },
|
||||
{ "label": "Shimmer", "value": "shimmer", "bufferId": "openai-Shimmer" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"WhisperModel": {
|
||||
"model": "whisper-1",
|
||||
"name": "Whisper1",
|
||||
"price": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 4.6.6-alpha 版本完整配置参数
|
||||
## 4.6.8 以前版本完整配置参数
|
||||
|
||||
**使用时,请务必去除注释!**
|
||||
|
||||
@@ -169,7 +22,6 @@ weight: 708
|
||||
```json
|
||||
{
|
||||
"systemEnv": {
|
||||
"pluginBaseUrl": "", // 商业版接口地址
|
||||
"vectorMaxProcess": 15, // 向量生成最大进程,结合数据库性能和 key 来设置
|
||||
"qaMaxProcess": 15, // QA 生成最大进程,结合数据库性能和 key 来设置
|
||||
"pgHNSWEfSearch": 100 // pg vector 索引参数,越大精度高但速度慢
|
||||
@@ -234,7 +86,8 @@ weight: 708
|
||||
"name": "GPT35-16k",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 16000,
|
||||
"price": 0
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0
|
||||
}
|
||||
],
|
||||
"cqModels": [ // 问题分类模型
|
||||
@@ -254,6 +107,7 @@ weight: 708
|
||||
"maxContext": 8000,
|
||||
"maxResponse": 8000,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
@@ -264,7 +118,8 @@ weight: 708
|
||||
"name": "GPT35-1106",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 4000,
|
||||
"outputPrice": 0,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
@@ -276,7 +131,7 @@ weight: 708
|
||||
"maxContext": 1600,
|
||||
"maxResponse": 4000,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"outputPrice": 0
|
||||
}
|
||||
],
|
||||
"vectorModels": [ // 向量模型
|
||||
@@ -314,6 +169,134 @@ weight: 708
|
||||
}
|
||||
```
|
||||
|
||||
## 4.6.8 新配置文件
|
||||
|
||||
llm模型全部合并
|
||||
|
||||
```json
|
||||
{
|
||||
"systemEnv": {
|
||||
"openapiPrefix": "fastgpt",
|
||||
"vectorMaxProcess": 15,
|
||||
"qaMaxProcess": 15,
|
||||
"pgHNSWEfSearch": 100
|
||||
},
|
||||
"llmModels": [
|
||||
{
|
||||
"model": "gpt-3.5-turbo-1106", // 模型名
|
||||
"name": "gpt-3.5-turbo", // 别名
|
||||
"maxContext": 16000, // 最大上下文
|
||||
"maxResponse": 4000, // 最大回复
|
||||
"quoteMaxToken": 13000, // 最大引用内容
|
||||
"maxTemperature": 1.2, // 最大温度
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"censor": false,
|
||||
"vision": false, // 是否支持图片输入
|
||||
"datasetProcess": false, // 是否设置为知识库处理模型
|
||||
"toolChoice": true, // 是否支持工具选择
|
||||
"functionCall": false, // 是否支持函数调用
|
||||
"customCQPrompt": "", // 自定义文本分类提示词(不支持工具和函数调用的模型
|
||||
"customExtractPrompt": "", // 自定义内容提取提示词
|
||||
"defaultSystemChatPrompt": "", // 对话默认携带的系统提示词
|
||||
"defaultConfig":{} // 对话默认配置(比如 GLM4 的 top_p
|
||||
},
|
||||
{
|
||||
"model": "gpt-3.5-turbo-16k",
|
||||
"name": "gpt-3.5-turbo-16k",
|
||||
"maxContext": 16000,
|
||||
"maxResponse": 16000,
|
||||
"quoteMaxToken": 13000,
|
||||
"maxTemperature": 1.2,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"censor": false,
|
||||
"vision": false,
|
||||
"datasetProcess": true,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"defaultConfig":{}
|
||||
},
|
||||
{
|
||||
"model": "gpt-4-0125-preview",
|
||||
"name": "gpt-4-turbo",
|
||||
"maxContext": 125000,
|
||||
"maxResponse": 125000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1.2,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"censor": false,
|
||||
"vision": false,
|
||||
"datasetProcess": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"defaultConfig":{}
|
||||
},
|
||||
{
|
||||
"model": "gpt-4-vision-preview",
|
||||
"name": "gpt-4-vision",
|
||||
"maxContext": 128000,
|
||||
"maxResponse": 4000,
|
||||
"quoteMaxToken": 100000,
|
||||
"maxTemperature": 1.2,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"censor": false,
|
||||
"vision": false,
|
||||
"datasetProcess": false,
|
||||
"toolChoice": true,
|
||||
"functionCall": false,
|
||||
"customCQPrompt": "",
|
||||
"customExtractPrompt": "",
|
||||
"defaultSystemChatPrompt": "",
|
||||
"defaultConfig":{}
|
||||
}
|
||||
],
|
||||
"vectorModels": [
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"defaultToken": 700,
|
||||
"maxToken": 3000,
|
||||
"weight": 100,
|
||||
"defaultConfig":{} // 默认配置。例如,如果希望使用 embedding3-large 的话,可以传入 dimensions:1024,来返回1024维度的向量。(目前必须小于1536维度)
|
||||
}
|
||||
],
|
||||
"reRankModels": [],
|
||||
"audioSpeechModels": [
|
||||
{
|
||||
"model": "tts-1",
|
||||
"name": "OpenAI TTS1",
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"voices": [
|
||||
{ "label": "Alloy", "value": "alloy", "bufferId": "openai-Alloy" },
|
||||
{ "label": "Echo", "value": "echo", "bufferId": "openai-Echo" },
|
||||
{ "label": "Fable", "value": "fable", "bufferId": "openai-Fable" },
|
||||
{ "label": "Onyx", "value": "onyx", "bufferId": "openai-Onyx" },
|
||||
{ "label": "Nova", "value": "nova", "bufferId": "openai-Nova" },
|
||||
{ "label": "Shimmer", "value": "shimmer", "bufferId": "openai-Shimmer" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"whisperModel": {
|
||||
"model": "whisper-1",
|
||||
"name": "Whisper1",
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 特殊模型
|
||||
|
||||
### ReRank 接入
|
||||
|
||||
@@ -59,10 +59,10 @@ Authorization 为 sk-aaabbbcccdddeeefffggghhhiiijjjkkk。model 为刚刚在 One
|
||||
|
||||
## 接入 FastGPT
|
||||
|
||||
修改 config.json 配置文件,在 ChatModels 中加入 chatglm2, 在 VectorModels 中加入 M3E 模型:
|
||||
修改 config.json 配置文件,在 llmModels 中加入 chatglm2, 在 vectorModels 中加入 M3E 模型:
|
||||
|
||||
```json
|
||||
"ChatModels": [
|
||||
"llmModels": [
|
||||
//其他对话模型
|
||||
{
|
||||
"model": "chatglm2",
|
||||
@@ -74,7 +74,7 @@ Authorization 为 sk-aaabbbcccdddeeefffggghhhiiijjjkkk。model 为刚刚在 One
|
||||
"defaultSystemChatPrompt": ""
|
||||
}
|
||||
],
|
||||
"VectorModels": [
|
||||
"vectorModels": [
|
||||
{
|
||||
"model": "text-embedding-ada-002",
|
||||
"name": "Embedding-2",
|
||||
|
||||
@@ -99,10 +99,10 @@ Authorization 为 sk-aaabbbcccdddeeefffggghhhiiijjjkkk。model 为刚刚在 One
|
||||
|
||||
## 接入 FastGPT
|
||||
|
||||
修改 config.json 配置文件,在 ChatModels 中加入 chatglm2 模型:
|
||||
修改 config.json 配置文件,在 llmModels 中加入 chatglm2 模型:
|
||||
|
||||
```json
|
||||
"ChatModels": [
|
||||
"llmModels": [
|
||||
//已有模型
|
||||
{
|
||||
"model": "chatglm2",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -89,10 +94,14 @@ curl -O https://raw.githubusercontent.com/labring/FastGPT/main/files/deploy/fast
|
||||
curl -O https://raw.githubusercontent.com/labring/FastGPT/main/projects/app/data/config.json
|
||||
```
|
||||
|
||||
## 三、修改 docker-compose.yml 的环境变量
|
||||
|
||||
## 三、启动容器
|
||||
修改`docker-compose.yml`中的`OPENAI_BASE_URL`(API 接口的地址,需要加/v1)和`CHAT_API_KEY`(API 接口的凭证)。
|
||||
|
||||
修改`docker-compose.yml`中的`OPENAI_BASE_URL`和`CHAT_API_KEY`即可,对应为 API 的地址(别忘记加/v1)和 key。
|
||||
使用 OneAPI 的话,OPENAI_BASE_URL=OneAPI访问地址/v1;CHAT_API_KEY=令牌
|
||||
|
||||
|
||||
## 四、启动容器
|
||||
|
||||
```bash
|
||||
# 在 docker-compose.yml 同级目录下执行
|
||||
@@ -100,7 +109,39 @@ docker-compose pull
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## 四、访问 FastGPT
|
||||
## 四、初始化 Mongo 副本集(4.6.8以前可忽略)
|
||||
|
||||
FastGPT 4.6.8 后使用了 MongoDB 的事务,需要运行在副本集上。副本集没法自动化初始化,需手动操作。
|
||||
|
||||
```bash
|
||||
# 查看 mongo 容器是否正常运行
|
||||
docker ps
|
||||
# 进入容器
|
||||
docker exec -it mongo bash
|
||||
|
||||
# 连接数据库
|
||||
mongo
|
||||
|
||||
# 初始化副本集。
|
||||
rs.initiate({
|
||||
_id: "rs0",
|
||||
members: [
|
||||
{ _id: 0, host: "mongo:27017" }
|
||||
]
|
||||
})
|
||||
# 检查状态。如果提示 rs0 状态,则代表运行成功
|
||||
rs.status()
|
||||
|
||||
# 初始化用户
|
||||
use admin
|
||||
db.createUser({
|
||||
user: "admin",
|
||||
pwd: "password",
|
||||
roles: [{ role: "root", db: "admin" }]
|
||||
});
|
||||
```
|
||||
|
||||
## 五、访问 FastGPT
|
||||
|
||||
目前可以通过 `ip:3000` 直接访问(注意防火墙)。登录用户名为 `root`,密码为`docker-compose.yml`环境变量里设置的 `DEFAULT_ROOT_PSW`。
|
||||
|
||||
|
||||
@@ -19,13 +19,17 @@ images: []
|
||||
|
||||
## 通用问题
|
||||
|
||||
### 能否纯本地允许
|
||||
|
||||
可以。需要准备好向量模型和LLM模型。
|
||||
|
||||
### insufficient_user_quota user quota is not enough
|
||||
|
||||
OneAPI 账号的余额不足,默认 root 用户只有 200 刀,可以手动修改。
|
||||
|
||||
### xxx渠道找不到
|
||||
|
||||
OneAPI 中没有配置该模型渠道。
|
||||
OneAPI 中没有配置该模型渠道。或者是修改了配置文件中一部分的模型,但没有全部修改。
|
||||
|
||||
### 页面中可以正常回复,API 报错
|
||||
|
||||
@@ -35,6 +39,25 @@ OneAPI 中没有配置该模型渠道。
|
||||
|
||||
OneAPI 的 API Key 配置错误,需要修改`OPENAI_API_KEY`环境变量,并重启容器(先 stop 然后 rm 掉,最后再 up -d 运行一次)。可以`exec`进入容器,`env`查看环境变量是否生效。
|
||||
|
||||
### 其他模型没法进行问题分类/内容提取
|
||||
|
||||
需要给其他模型配置`toolChoice=false`,就会默认走提示词模式。目前内置提示词仅针对了商业模型API进行测试,国内外的商业模型基本都可用。
|
||||
|
||||
### 页面崩溃
|
||||
|
||||
1. 关闭翻译
|
||||
2. 检查配置文件是否正常加载,如果没有正常加载会导致缺失系统信息,在某些操作下会导致空指针。
|
||||
|
||||
## 私有部署问题
|
||||
|
||||
### 知识库索引没有进度
|
||||
|
||||
先看日志报错信息。
|
||||
|
||||
1. 可以对话,但是索引没有进度:没有配置向量模型(vectorModels)
|
||||
2. 不能对话,也不能索引:API调用失败。可能是没连上OneAPI或OenAI
|
||||
3. 有进度,但是非常慢:api key不行,OpenAI的免费号,一分钟只有3次还是60次。一天上限200次。
|
||||
|
||||
## Docker 部署常见问题
|
||||
|
||||
### 如何更新?
|
||||
@@ -96,7 +119,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`
|
||||
@@ -21,10 +21,10 @@ weight: 705
|
||||
|
||||
## 开始本地开发
|
||||
|
||||
**Tips**
|
||||
|
||||
{{% alert context="success" %}}
|
||||
1. 用户默认的时区为 `Asia/Shanghai`,非 linux 环境时候,获取系统时间会异常,本地开发时候,可以将用户的时区调整成 UTC(+0)。
|
||||
2. 建议先服务器装好**数据库**,再进行本地开发。
|
||||
{{% /alert %}}
|
||||
|
||||
### 1. Fork 存储库
|
||||
|
||||
@@ -48,6 +48,8 @@ git clone git@github.com:<github_username>/FastGPT.git
|
||||
|
||||
第一次开发,需要先部署数据库,建议本地开发可以随便找一台 2C2G 的轻量小数据库实践。数据库部署教程:[Docker 快速部署](/docs/development/docker/)。部署完了,可以本地访问其数据库。
|
||||
|
||||
Mongo 数据库需要修改副本集的`host`,从原来的`mongo:27017`修改为`ip:27017`。
|
||||
|
||||
### 4. 初始配置
|
||||
|
||||
以下文件均在 `projects/app` 路径下。
|
||||
@@ -62,7 +64,7 @@ git clone git@github.com:<github_username>/FastGPT.git
|
||||
|
||||
**注意:json 配置文件不能包含注释,介绍中为了方便看才加入的注释**
|
||||
|
||||
这个文件大部分时候不需要修改。只需要关注 SystemParams 里的参数:
|
||||
这个文件大部分时候不需要修改。只需要关注 `systemEnv` 里的参数:
|
||||
|
||||
- `vectorMaxProcess`: 向量生成最大进程,根据数据库和 key 的并发数来决定,通常单个 120 号,2c4g 服务器设置 10~15。
|
||||
- `qaMaxProcess`: QA 生成最大进程
|
||||
@@ -115,4 +117,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" />
|
||||
|
||||
@@ -11,13 +11,17 @@ weight: 708
|
||||
* [One API](https://github.com/songquanpeng/one-api) 是一个 OpenAI 接口管理 & 分发系统,可以通过标准的 OpenAI API 格式访问所有的大模型,开箱即用。
|
||||
* FastGPT 可以通过接入 OneAPI 来实现对不同大模型的支持。OneAPI 的部署方法也很简单。
|
||||
|
||||
## FastGPT 与 OneAPI 关系
|
||||
|
||||

|
||||
|
||||
## MySQL 版本
|
||||
|
||||
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 分钟数据库运行后才能访问成功。
|
||||
|
||||
@@ -50,7 +54,14 @@ BATCH_UPDATE_ENABLED=true
|
||||
BATCH_UPDATE_INTERVAL=60
|
||||
```
|
||||
|
||||
## One API使用步骤
|
||||
## One API使用教程
|
||||
|
||||
### 概念
|
||||
|
||||
1. 渠道:
|
||||
1. OneApi 中一个渠道对应一个 `Api Key`,这个 `Api Key` 可以是GPT、微软、ChatGLM、文心一言的。一个`Api Key`通常可以调用同一个厂商的多个模型。
|
||||
2. OneAPI 会根据请求传入的`模型`来决定使用哪一个`Key`,如果一个模型对应了多个`Key`,则会随机调用。
|
||||
2. 令牌:访问 OneAPI 所需的凭证,只需要这`1`个凭证即可访问`OneAPI`上配置的模型。因此`FastGPT`中,只需要配置`OneAPI`的`baseurl`和`令牌`即可。
|
||||
|
||||
### 1. 登录 One API
|
||||
|
||||
@@ -68,7 +79,11 @@ BATCH_UPDATE_INTERVAL=60
|
||||
创建一个令牌
|
||||

|
||||
|
||||
### 3. 修改 FastGPT 的环境变量
|
||||
### 3. 修改账号余额
|
||||
|
||||
OneAPI 默认 root 用户只有 200刀,可以自行修改编辑。
|
||||
|
||||
### 4. 修改 FastGPT 的环境变量
|
||||
|
||||
有了 One API 令牌后,FastGPT 可以通过修改 `baseurl` 和 `key` 去请求到 One API,再由 One API 去请求不同的模型。修改下面两个环境变量:
|
||||
|
||||
@@ -92,21 +107,29 @@ CHAT_API_KEY=sk-xxxxxx
|
||||
可以在 `/projects/app/src/data/config.json` 里找到配置文件(本地开发需要复制成 config.local.json),配置文件中有一项是对话模型配置:
|
||||
|
||||
```json
|
||||
"ChatModels": [
|
||||
"llmModels": [
|
||||
...
|
||||
{
|
||||
"model": "ERNIE-Bot", // 这里的模型需要对应 One API 的模型
|
||||
"name": "文心一言", // 对外展示的名称
|
||||
"maxContext": 8000, // 最大长下文 token,无论什么模型都按 GPT35 的计算。GPT 外的模型需要自行大致计算下这个值。可以调用官方接口去比对 Token 的倍率,然后在这里粗略计算。
|
||||
"maxResponse": 4000, // 最大回复 token
|
||||
// 例如:文心一言的中英文 token 基本是 1:1,而 GPT 的中文 Token 是 2:1,如果文心一言官方最大 Token 是 4000,那么这里就可以填 8000,保险点就填 7000.
|
||||
"quoteMaxToken": 2000, // 引用知识库的最大 Token
|
||||
"maxTemperature": 1, // 最大温度
|
||||
"vision": false, // 是否开启图片识别
|
||||
"defaultSystemChatPrompt": "" // 默认的系统提示词
|
||||
"maxContext": 16000, // 最大上下文
|
||||
"maxResponse": 4000, // 最大回复
|
||||
"quoteMaxToken": 13000, // 最大引用内容
|
||||
"maxTemperature": 1.2, // 最大温度
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"censor": false,
|
||||
"vision": false, // 是否支持图片输入
|
||||
"datasetProcess": false, // 是否设置为知识库处理模型
|
||||
"toolChoice": true, // 是否支持工具选择
|
||||
"functionCall": false, // 是否支持函数调用
|
||||
"customCQPrompt": "", // 自定义文本分类提示词(不支持工具和函数调用的模型
|
||||
"customExtractPrompt": "", // 自定义内容提取提示词
|
||||
"defaultSystemChatPrompt": "", // 对话默认携带的系统提示词
|
||||
"defaultConfig":{} // 对话默认配置(比如 GLM4 的 top_p
|
||||
}
|
||||
...
|
||||
],
|
||||
```
|
||||
|
||||
添加完后,重启 FastGPT 即可在选择文心一言模型进行对话。
|
||||
添加完后,重启 FastGPT 即可在选择文心一言模型进行对话。**添加向量模型也是类似操作,增加到 `vectorModels`里。**
|
||||
|
||||
@@ -25,7 +25,7 @@ FastGPT 的 API Key **有 2 类**,一类是全局通用的 key (无法直接
|
||||
|
||||
| 通用key | 应用特定 key |
|
||||
| --------------------- | --------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
## 基本配置
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions'
|
||||
{{< /markdownify >}}
|
||||
{{< /tab >}}
|
||||
|
||||
{{< tab tabName="detail=true 响应" >}}
|
||||
{{< tab tabName="参数说明" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
{{% alert context="info" %}}
|
||||
@@ -56,7 +56,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions'
|
||||
- chatId: string | undefined 。
|
||||
- 为 `undefined` 时(不传入),不使用 FastGpt 提供的上下文功能,完全通过传入的 messages 构建上下文。 不会将你的记录存储到数据库中,你也无法在记录汇总中查阅到。
|
||||
- 为`非空字符串`时,意味着使用 chatId 进行对话,自动从 FastGpt 数据库取历史记录,并使用 messages 数组最后一个内容作为用户问题。请自行确保 chatId 唯一,长度小于250,通常可以是自己系统的对话框ID。
|
||||
- messages: 结构与 [GPT接口](https://platform.openai.com/docs/api-reference/chat/object) 完全一致。
|
||||
- messages: 结构与 [GPT接口](https://platform.openai.com/docs/api-reference/chat/object) chat模式一致。
|
||||
- detail: 是否返回中间值(模块状态,响应的完整结果等),`stream模式`下会通过`event`进行区分,`非stream模式`结果保存在`responseData`中。
|
||||
- variables: 模块变量,一个对象,会替换模块中,输入框内容里的`{{key}}`
|
||||
{{% /alert %}}
|
||||
|
||||
@@ -41,7 +41,7 @@ weight: 860
|
||||
## 配置教程
|
||||
### 1. 配置身份校验地址
|
||||
|
||||

|
||||

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

|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,9 +7,21 @@ toc: true
|
||||
weight: 706
|
||||
---
|
||||
|
||||
## 部署架构图
|
||||
|
||||

|
||||
|
||||
## 多模型支持
|
||||
|
||||
FastGPT 使用了 one-api 项目来管理模型池,其可以兼容 OpenAI 、Azure 、国内主流模型和本地模型等。
|
||||
|
||||
可参考:[Sealos 快速部署 OneAPI](/docs/development/one-api)
|
||||
|
||||
|
||||
## 一键部署
|
||||
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 +31,13 @@ Sealos 的服务器在国外,不需要额外处理网络问题,无需服务
|
||||
|
||||

|
||||
|
||||
> 用户名:`root`
|
||||
>
|
||||
> 密码就是刚刚一键部署时设置的环境变量
|
||||
### 登录
|
||||
|
||||
## 修改配置文件和环境变量
|
||||
用户名:`root`
|
||||
|
||||
密码是刚刚一键部署时设置的`root_password`
|
||||
|
||||
### 修改配置文件和环境变量
|
||||
|
||||
在 Sealos 中,你可以打开`应用管理`(App Launchpad)看到部署的 FastGPT,可以打开`数据库`(Database)看到对应的数据库。
|
||||
|
||||
@@ -35,13 +49,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)
|
||||
|
||||
35
docSite/content/docs/development/upgrading/467.md
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
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 重新关联到数据集
|
||||
2. 设置 pg 表的 null 值。
|
||||
|
||||
|
||||
## V4.6.7 更新说明
|
||||
|
||||
1. 修改了知识库UI及新的导入交互方式。
|
||||
2. 优化知识库和对话的数据索引。
|
||||
3. 知识库 openAPI,支持通过 [API 操作知识库](/docs/development/openapi/dataset)。
|
||||
4. 新增 - 输入框变量提示。输入 { 号后将会获得可用变量提示。根据社区针对高级编排的反馈,我们计划于 2 月份的版本中,优化变量内容,支持模块的局部变量以及更多全局变量写入。
|
||||
5. 优化 - 切换团队后会保存记录,下次登录时优先登录该团队。
|
||||
6. 修复 - API 对话时,chatId 冲突问题。
|
||||
7. 修复 - Iframe 嵌入网页可能导致的 window.onLoad 冲突。
|
||||
27
docSite/content/docs/development/upgrading/468.md
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
title: 'V4.6.8(进行中)'
|
||||
description: 'FastGPT V4.6.7'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 828
|
||||
---
|
||||
|
||||
## docker 部署 - 更新 Mongo
|
||||
|
||||
开启 Mongo 副本集模式。需要进入 mongo 执行一次 init,参考[初始化Mongo副本集](/docs/development/docker/#四初始化-mongo-副本集),这个比较麻烦,初始化后可以用 mongoshell 之类的连接试试,看能不能连接上。
|
||||
|
||||
## Sealos 部署 - 无需更新 Mongo
|
||||
|
||||
## 修改配置文件
|
||||
|
||||
去除了重复的模型配置,LLM模型都合并到一个属性中:[点击查看最新的配置文件](/docs/development/configuration/)
|
||||
|
||||
## V4.6.8 更新说明
|
||||
|
||||
1. 新增 - 知识库搜索合并模块。
|
||||
1. 优化 - LLM 模型配置,不再区分对话、分类、提取模型。同时支持模型的默认参数,避免不同模型参数冲突,可通过`defaultConfig`传入默认的配置。
|
||||
2. 优化 - HTTP 模块,支持输出字符串自动序列化(JSON可自动转成字符串)
|
||||
3. 优化 - 流响应,参考了`ChatNextWeb`的流,更加丝滑。此外,之前提到的乱码、中断,刷新后又正常了,可能会修复)
|
||||
4. 修复 - 语音输入文件无法上传。
|
||||
5. 修复 - 对话框重新生成无法使用。
|
||||
@@ -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:配置中的问题分类还包含着“联网搜索”,这个是另一
|
||||
|
||||
## 效果图
|
||||
|
||||

|
||||

|
||||
|
||||
## 后记
|
||||
|
||||
|
||||
@@ -30,20 +30,15 @@ FastGPT 从 V4 版本开始采用新的交互方式来构建 AI 应用。使用
|
||||
|
||||
### 模块分类
|
||||
|
||||
从功能上,模块可以分为 3 类:
|
||||
从功能上,模块可以分为 2 类:
|
||||
|
||||
1. **只读模块**:全局变量、用户引导。
|
||||
2. **系统模块**:聊天记录(无输入,直接从数据库取)、用户问题(流程入口)。
|
||||
3. **功能模块**:知识库搜索、AI 对话等剩余模块。(这些模块都有输入和输出,可以自由组合)。
|
||||
1. **系统模块**:用户引导(配置一些对话框信息)、用户问题(流程入口)。
|
||||
2. **功能模块**:知识库搜索、AI 对话等剩余模块。(这些模块都有输入和输出,可以自由组合)。
|
||||
|
||||
### 模块的组成
|
||||
|
||||
每个模块会包含 3 个核心部分:固定参数、外部输入(左边有个圆圈)和输出(右边有个圆圈)。
|
||||
|
||||
+ 对于只读模块,只需要根据提示填写即可,不参与流程运行。
|
||||
+ 对于系统模块,通常只有固定参数和输出,主要需要关注输出到哪个位置。
|
||||
+ 对于功能模块,通常这 3 部分都是重要的,以下图的 AI 对话为例:
|
||||
|
||||

|
||||
|
||||
- 对话模型、温度、回复上限、系统提示词和限定词为固定参数,同时系统提示词和限定词也可以作为外部输入,意味着如果你有输入流向了系统提示词,那么原本填写的内容就会被**覆盖**。
|
||||
@@ -56,6 +51,7 @@ FastGPT 从 V4 版本开始采用新的交互方式来构建 AI 应用。使用
|
||||
|
||||
1. 仅关心**已连接的**外部输入,即左边的圆圈被连接了。
|
||||
2. 当连接内容都有值时触发。
|
||||
3. **可以多个输出连接到一个输入,后续的值会覆盖前面的值。**
|
||||
|
||||
#### 示例 1:
|
||||
|
||||
@@ -86,4 +82,17 @@ FastGPT 从 V4 版本开始采用新的交互方式来构建 AI 应用。使用
|
||||
|
||||
1. 建议从左往右阅读。
|
||||
2. 从 **用户问题** 模块开始。用户问题模块,代表的是用户发送了一段文本,触发任务开始。
|
||||
3. 关注【AI 对话】和【指定回复】模块,这两个模块是输出答案的地方。
|
||||
3. 关注【AI 对话】和【指定回复】模块,这两个模块是输出答案的地方。
|
||||
|
||||
## FAQ
|
||||
|
||||
### 想合并多个输出结果怎么实现?
|
||||
|
||||
1. 文本加工,可以对字符串进行合并。
|
||||
2. 知识库搜索合并,可以合并多个知识库搜索结果
|
||||
3. 其他结果,无法直接合并,可以考虑传入到`HTTP`模块中进行合并,使用`[Laf](https://laf.run/)`可以快速实现一个无服务器HTTP接口。
|
||||
|
||||
### 模块为什么有2个用户问题
|
||||
|
||||
左侧的`用户问题`是指该模块所需的输入。右侧的`用户问题`是为了方便后续的连线,输出的值和传入的用户问题一样。
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ HTTP 模块会向对应的地址发送一个 `POST/GET` 请求,携带部分`
|
||||
|
||||
### 嵌套对象使用
|
||||
|
||||
**入参**
|
||||
#### 入参
|
||||
|
||||
假设我们设计了`3个`输入。
|
||||
|
||||
@@ -58,7 +58,7 @@ HTTP 模块会向对应的地址发送一个 `POST/GET` 请求,携带部分`
|
||||
}
|
||||
```
|
||||
|
||||
**出参**
|
||||
#### 出参
|
||||
|
||||
假设接口的输出结构为:
|
||||
|
||||
@@ -66,18 +66,46 @@ HTTP 模块会向对应的地址发送一个 `POST/GET` 请求,携带部分`
|
||||
{
|
||||
"message": "测试",
|
||||
"data":{
|
||||
"name": "name",
|
||||
"age": 10
|
||||
"user": {
|
||||
"name": "xxx",
|
||||
"age": 12
|
||||
},
|
||||
"list": [
|
||||
{
|
||||
"name": "xxx",
|
||||
"age": 50
|
||||
},
|
||||
[{ "test": 22 }]
|
||||
],
|
||||
"psw": "xxx"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
那么,自定出参的`key`可以设置为:
|
||||
最终得到的解析为:
|
||||
|
||||
- message (string)
|
||||
- data.name (string)
|
||||
- data.age (number)
|
||||
```json
|
||||
{
|
||||
"user": { "name": "xxx", "age": 12 },
|
||||
"user.name": "xxx",
|
||||
"user.age": 12,
|
||||
"list": [ { "name": "xxx", "age": 50 }, [{ "test": 22 }] ],
|
||||
"list[0]": { "name": "xxx", "age": 50 },
|
||||
"list[0].name": "xxx",
|
||||
"list[0].age": 50,
|
||||
"list[1]": [ { "test": 22 } ],
|
||||
"list[1][0]": { "test": 22 },
|
||||
"list[1][0].test": 22,
|
||||
"psw": "xxx"
|
||||
}
|
||||
```
|
||||
|
||||
你可以使用`json`里对应的`key`来获取值。
|
||||
|
||||
|
||||
### 格式化输出
|
||||
|
||||
FastGPT v4.6.8 后,加入了出参格式化功能,主要以`json`格式化成`字符串`为主。如果你的输出类型选择了`字符串`,则会将`HTTP`对应`key`的值,转成`json`字符串进行输出。因此,未来你可以直接从`HTTP`接口输出内容至`文本加工`中,然后拼接适当的提示词,最终输入给`AI对话`。
|
||||
|
||||
## POST 示例
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -27,10 +27,7 @@ services:
|
||||
- 27017:27017
|
||||
networks:
|
||||
- fastgpt
|
||||
environment:
|
||||
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
|
||||
- MONGO_INITDB_ROOT_USERNAME=username
|
||||
- MONGO_INITDB_ROOT_PASSWORD=password
|
||||
command: --replSet rs0
|
||||
volumes:
|
||||
- ./mongo/data:/data/db
|
||||
fastgpt:
|
||||
@@ -55,63 +52,11 @@ services:
|
||||
- TOKEN_KEY=any
|
||||
- ROOT_KEY=root_key
|
||||
- FILE_TOKEN_KEY=filetoken
|
||||
# mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin
|
||||
- MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
|
||||
# mongo 配置,不需要改. 用户名admin,密码password,是执行 db.createUser 时的账号和密码。
|
||||
- MONGODB_URI=mongodb://admin:password@mongo:27017/fastgpt?authSource=admin
|
||||
# pg配置. 不需要改
|
||||
- PG_URL=postgresql://username:password@pg:5432/postgres
|
||||
volumes:
|
||||
- ./config.json:/app/data/config.json
|
||||
networks:
|
||||
fastgpt:
|
||||
# host 版本, 不推荐。
|
||||
# version: '3.3'
|
||||
# services:
|
||||
# pg:
|
||||
# image: ankane/pgvector:v0.5.0 # dockerhub
|
||||
# # image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.5.0 # 阿里云
|
||||
# container_name: pg
|
||||
# restart: always
|
||||
# ports: # 生产环境建议不要暴露
|
||||
# - 5432:5432
|
||||
# environment:
|
||||
# # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
|
||||
# - POSTGRES_USER=username
|
||||
# - POSTGRES_PASSWORD=password
|
||||
# - POSTGRES_DB=postgres
|
||||
# volumes:
|
||||
# - ./pg/data:/var/lib/postgresql/data
|
||||
# mongo:
|
||||
# image: mongo:5.0.18
|
||||
# # image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
|
||||
# container_name: mongo
|
||||
# restart: always
|
||||
# ports: # 生产环境建议不要暴露
|
||||
# - 27017:27017
|
||||
# environment:
|
||||
# # 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
|
||||
# - MONGO_INITDB_ROOT_USERNAME=username
|
||||
# - MONGO_INITDB_ROOT_PASSWORD=password
|
||||
# volumes:
|
||||
# - ./mongo/data:/data/db
|
||||
# - ./mongo/logs:/var/log/mongodb
|
||||
# fastgpt:
|
||||
# # image: ghcr.io/labring/fastgpt:latest # github
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
|
||||
# network_mode: host
|
||||
# restart: always
|
||||
# container_name: fastgpt
|
||||
# environment:
|
||||
# # root 密码,用户名为: root
|
||||
# - DEFAULT_ROOT_PSW=1234
|
||||
# # 中转地址,如果是用官方号,不需要管
|
||||
# - OPENAI_BASE_URL=https://api.openai.com/v1
|
||||
# - CHAT_API_KEY=sk-xxxx
|
||||
# - DB_MAX_LINK=5 # database max link
|
||||
# # token加密凭证(随便填,作为登录凭证)
|
||||
# - TOKEN_KEY=any
|
||||
# # root key, 最高权限,可以内部接口互相调用
|
||||
# - ROOT_KEY=root_key
|
||||
# # mongo 配置,不需要改
|
||||
# - MONGODB_URI=mongodb://username:password@0.0.0.0:27017/fastgpt?authSource=admin
|
||||
# # pg配置. 不需要改
|
||||
# - PG_URL=postgresql://username:password@0.0.0.0:5432/postgres
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { replaceSensitiveLink } from '../string/tools';
|
||||
|
||||
export const getErrText = (err: any, def = '') => {
|
||||
const msg: string = typeof err === 'string' ? err : err?.message || def || '';
|
||||
msg && console.log('error =>', msg);
|
||||
return msg;
|
||||
return replaceSensitiveLink(msg);
|
||||
};
|
||||
|
||||
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
|
||||
};
|
||||
};
|
||||
18
packages/global/common/math/date.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
// 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 = (startDate = new Date()) => {
|
||||
const year = startDate.getFullYear();
|
||||
const month = startDate.getMonth();
|
||||
const endDay = new Date(year, month + 1, 0, 0, 0, 0);
|
||||
return calculateDaysBetweenDates(startDate, endDay);
|
||||
};
|
||||
|
||||
export const calculateDaysBetweenDates = (date1: Date, date2: Date) => {
|
||||
const oneDay = 24 * 60 * 60 * 1000;
|
||||
const firstDate = new Date(date1).getTime();
|
||||
const secondDate = new Date(date2).getTime();
|
||||
|
||||
const differenceInTime = Math.abs(secondDate - firstDate);
|
||||
const differenceInDays = Math.floor(differenceInTime / oneDay);
|
||||
|
||||
return differenceInDays;
|
||||
};
|
||||
@@ -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,13 @@ export function replaceVariable(text: string, obj: Record<string, string | numbe
|
||||
}
|
||||
return text || '';
|
||||
}
|
||||
|
||||
/* replace sensitive link */
|
||||
export const replaceSensitiveLink = (text: string) => {
|
||||
const urlRegex = /(?<=https?:\/\/)[^\s]+/g;
|
||||
return text.replace(urlRegex, 'xxx');
|
||||
};
|
||||
|
||||
export const getNanoid = (size = 12) => {
|
||||
return customAlphabet('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', size)();
|
||||
};
|
||||
|
||||
21
packages/global/common/system/types/index.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
import { StandSubPlanLevelMapType, SubPlanType } from '../../../support/wallet/sub/type';
|
||||
import type {
|
||||
ChatModelItemType,
|
||||
FunctionModelItemType,
|
||||
@@ -7,16 +8,14 @@ import type {
|
||||
WhisperModelType,
|
||||
ReRankModelItemType
|
||||
} from '../../../core/ai/model.d';
|
||||
import { SubTypeEnum } from '../../../support/wallet/sub/constants';
|
||||
|
||||
/* fastgpt main */
|
||||
export type FastGPTConfigFileType = {
|
||||
feConfigs: FastGPTFeConfigsType;
|
||||
systemEnv: SystemEnvType;
|
||||
chatModels: ChatModelItemType[];
|
||||
qaModels: LLMModelItemType[];
|
||||
cqModels: FunctionModelItemType[];
|
||||
extractModels: FunctionModelItemType[];
|
||||
qgModels: LLMModelItemType[];
|
||||
subPlans?: SubPlanType;
|
||||
llmModels: ChatModelItemType[];
|
||||
vectorModels: VectorModelItemType[];
|
||||
reRankModels: ReRankModelItemType[];
|
||||
audioSpeechModels: AudioSpeechModelType[];
|
||||
@@ -51,17 +50,19 @@ export type FastGPTFeConfigsType = {
|
||||
favicon?: string;
|
||||
customApiDomain?: string;
|
||||
customSharePageDomain?: string;
|
||||
|
||||
uploadFileMaxSize?: number;
|
||||
};
|
||||
|
||||
export type SystemEnvType = {
|
||||
pluginBaseUrl?: string;
|
||||
openapiPrefix?: string;
|
||||
vectorMaxProcess: number;
|
||||
qaMaxProcess: number;
|
||||
pgHNSWEfSearch: number;
|
||||
};
|
||||
|
||||
declare global {
|
||||
var feConfigs: FastGPTFeConfigsType;
|
||||
var systemEnv: SystemEnvType;
|
||||
}
|
||||
// declare global {
|
||||
// var feConfigs: FastGPTFeConfigsType;
|
||||
// var systemEnv: SystemEnvType;
|
||||
// var systemInitd: boolean;
|
||||
// }
|
||||
|
||||
22
packages/global/core/ai/model.d.ts
vendored
@@ -3,20 +3,24 @@ export type LLMModelItemType = {
|
||||
name: string;
|
||||
maxContext: number;
|
||||
maxResponse: number;
|
||||
inputPrice: number;
|
||||
outputPrice: number;
|
||||
};
|
||||
export type ChatModelItemType = LLMModelItemType & {
|
||||
quoteMaxToken: number;
|
||||
maxTemperature: number;
|
||||
|
||||
inputPrice: number;
|
||||
outputPrice: number;
|
||||
|
||||
censor?: boolean;
|
||||
vision?: boolean;
|
||||
defaultSystemChatPrompt?: string;
|
||||
};
|
||||
datasetProcess?: boolean;
|
||||
|
||||
export type FunctionModelItemType = LLMModelItemType & {
|
||||
functionCall: boolean;
|
||||
toolChoice: boolean;
|
||||
functionPrompt: string;
|
||||
|
||||
customCQPrompt: string;
|
||||
customExtractPrompt: string;
|
||||
|
||||
defaultSystemChatPrompt?: string;
|
||||
defaultConfig?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type VectorModelItemType = {
|
||||
@@ -27,6 +31,8 @@ export type VectorModelItemType = {
|
||||
outputPrice: number;
|
||||
maxToken: number;
|
||||
weight: number;
|
||||
hidden?: boolean;
|
||||
defaultConfig?: Record<string, any>;
|
||||
};
|
||||
|
||||
export type ReRankModelItemType = {
|
||||
|
||||
@@ -3,11 +3,22 @@ import type { LLMModelItemType, VectorModelItemType } from './model.d';
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo-16k',
|
||||
name: 'GPT35-16k',
|
||||
name: 'gpt-3.5-turbo-16k',
|
||||
maxContext: 16000,
|
||||
maxResponse: 16000,
|
||||
quoteMaxToken: 13000,
|
||||
maxTemperature: 1.2,
|
||||
inputPrice: 0,
|
||||
outputPrice: 0
|
||||
outputPrice: 0,
|
||||
censor: false,
|
||||
vision: false,
|
||||
datasetProcess: true,
|
||||
toolChoice: true,
|
||||
functionCall: false,
|
||||
customCQPrompt: '',
|
||||
customExtractPrompt: '',
|
||||
defaultSystemChatPrompt: '',
|
||||
defaultConfig: {}
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
4
packages/global/core/app/api.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import type { ChatModelItemType } from '../ai/model.d';
|
||||
import type { LLMModelItemType } from '../ai/model.d';
|
||||
import { AppTypeEnum } from './constants';
|
||||
import { AppSchema, AppSimpleEditFormType } from './type';
|
||||
|
||||
@@ -22,5 +22,5 @@ export interface AppUpdateParams {
|
||||
export type FormatForm2ModulesProps = {
|
||||
formData: AppSimpleEditFormType;
|
||||
chatModelMaxToken: number;
|
||||
chatModelList: ChatModelItemType[];
|
||||
llmModelList: LLMModelItemType[];
|
||||
};
|
||||
|
||||
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 {
|
||||
@@ -91,7 +91,7 @@ export const appModules2Form = ({
|
||||
);
|
||||
defaultAppForm.dataset.limit = findInputValueByKey(
|
||||
module.inputs,
|
||||
ModuleInputKeyEnum.datasetLimit
|
||||
ModuleInputKeyEnum.datasetMaxTokens
|
||||
);
|
||||
defaultAppForm.dataset.searchMode =
|
||||
findInputValueByKey(module.inputs, ModuleInputKeyEnum.datasetSearchMode) ||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
95
packages/global/core/dataset/search/utils.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { countPromptTokens } from '../../../common/string/tiktoken';
|
||||
import { SearchScoreTypeEnum } from '../constants';
|
||||
import { SearchDataResponseItemType } from '../type';
|
||||
|
||||
/* dataset search result concat */
|
||||
export const datasetSearchResultConcat = (
|
||||
arr: { k: number; list: SearchDataResponseItemType[] }[]
|
||||
): SearchDataResponseItemType[] => {
|
||||
arr = arr.filter((item) => item.list.length > 0);
|
||||
|
||||
if (arr.length === 0) return [];
|
||||
if (arr.length === 1) return arr[0].list;
|
||||
|
||||
const map = new Map<string, SearchDataResponseItemType & { rrfScore: number }>();
|
||||
|
||||
// rrf
|
||||
arr.forEach((item) => {
|
||||
const k = item.k;
|
||||
|
||||
item.list.forEach((data, index) => {
|
||||
const rank = index + 1;
|
||||
const score = 1 / (k + rank);
|
||||
|
||||
const record = map.get(data.id);
|
||||
if (record) {
|
||||
// 合并两个score,有相同type的score,取最大值
|
||||
const concatScore = [...record.score];
|
||||
for (const dataItem of data.score) {
|
||||
const sameScore = concatScore.find((item) => item.type === dataItem.type);
|
||||
if (sameScore) {
|
||||
sameScore.value = Math.max(sameScore.value, dataItem.value);
|
||||
} else {
|
||||
concatScore.push(dataItem);
|
||||
}
|
||||
}
|
||||
|
||||
map.set(data.id, {
|
||||
...record,
|
||||
score: concatScore,
|
||||
rrfScore: record.rrfScore + score
|
||||
});
|
||||
} else {
|
||||
map.set(data.id, {
|
||||
...data,
|
||||
rrfScore: score
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// sort
|
||||
const mapArray = Array.from(map.values());
|
||||
const results = mapArray.sort((a, b) => b.rrfScore - a.rrfScore);
|
||||
|
||||
return results.map((item, index) => {
|
||||
// if SearchScoreTypeEnum.rrf exist, reset score
|
||||
const rrfScore = item.score.find((item) => item.type === SearchScoreTypeEnum.rrf);
|
||||
if (rrfScore) {
|
||||
rrfScore.value = item.rrfScore;
|
||||
rrfScore.index = index;
|
||||
} else {
|
||||
item.score.push({
|
||||
type: SearchScoreTypeEnum.rrf,
|
||||
value: item.rrfScore,
|
||||
index
|
||||
});
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
delete item.rrfScore;
|
||||
return item;
|
||||
});
|
||||
};
|
||||
|
||||
export const filterSearchResultsByMaxChars = (
|
||||
list: SearchDataResponseItemType[],
|
||||
maxTokens: number
|
||||
) => {
|
||||
const results: SearchDataResponseItemType[] = [];
|
||||
let totalTokens = 0;
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const item = list[i];
|
||||
totalTokens += countPromptTokens(item.q + item.a);
|
||||
if (totalTokens > maxTokens + 500) {
|
||||
break;
|
||||
}
|
||||
results.push(item);
|
||||
if (totalTokens > maxTokens) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return results.length === 0 ? list.slice(0, 1) : results;
|
||||
};
|
||||
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,21 +25,17 @@ 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';
|
||||
}
|
||||
|
||||
/* get dataset data default index */
|
||||
export function getDefaultIndex(props?: { q?: string; a?: string; dataId?: string }) {
|
||||
const { q = '', a, dataId } = props || {};
|
||||
const qaStr = `${q}\n${a}`.trim();
|
||||
@@ -55,3 +46,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;
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ export enum ModuleInputKeyEnum {
|
||||
// dataset
|
||||
datasetSelectList = 'datasets',
|
||||
datasetSimilarity = 'similarity',
|
||||
datasetLimit = 'limit',
|
||||
datasetMaxTokens = 'limit',
|
||||
datasetSearchMode = 'searchMode',
|
||||
datasetSearchUsingReRank = 'usingReRank',
|
||||
datasetParamsModal = 'datasetParamsModal',
|
||||
@@ -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';
|
||||
|
||||
@@ -45,7 +45,10 @@ export enum FlowNodeTypeEnum {
|
||||
questionInput = 'questionInput',
|
||||
historyNode = 'historyNode',
|
||||
chatNode = 'chatNode',
|
||||
|
||||
datasetSearchNode = 'datasetSearchNode',
|
||||
datasetConcatNode = 'datasetConcatNode',
|
||||
|
||||
answerNode = 'answerNode',
|
||||
classifyQuestion = 'classifyQuestion',
|
||||
contentExtract = 'contentExtract',
|
||||
@@ -54,10 +57,9 @@ export enum FlowNodeTypeEnum {
|
||||
pluginModule = 'pluginModule',
|
||||
pluginInput = 'pluginInput',
|
||||
pluginOutput = 'pluginOutput',
|
||||
cfr = 'cfr',
|
||||
cfr = 'cfr'
|
||||
|
||||
// abandon
|
||||
variable = 'variable'
|
||||
}
|
||||
|
||||
export const EDGE_TYPE = 'default';
|
||||
|
||||
2
packages/global/core/module/node/type.d.ts
vendored
@@ -106,6 +106,6 @@ export type AIChatModuleProps = {
|
||||
export type DatasetModuleProps = {
|
||||
[ModuleInputKeyEnum.datasetSelectList]: SelectedDatasetType;
|
||||
[ModuleInputKeyEnum.datasetSimilarity]: number;
|
||||
[ModuleInputKeyEnum.datasetLimit]: number;
|
||||
[ModuleInputKeyEnum.datasetMaxTokens]: number;
|
||||
[ModuleInputKeyEnum.datasetStartReRank]: boolean;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@ export const Input_Template_Switch: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.switch,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: 'core.module.input.label.switch',
|
||||
description: 'core.module.input.description.Trigger',
|
||||
valueType: ModuleIOValueTypeEnum.any,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
@@ -27,8 +28,8 @@ export const Input_Template_History: FlowNodeInputItemType = {
|
||||
|
||||
export const Input_Template_UserChatInput: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.userChatInput,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: 'core.module.input.label.user question',
|
||||
type: FlowNodeInputTypeEnum.custom,
|
||||
label: '',
|
||||
required: true,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: true,
|
||||
@@ -56,3 +57,13 @@ export const Input_Template_DynamicInput: FlowNodeInputItemType = {
|
||||
showTargetInPlugin: true,
|
||||
hideInApp: true
|
||||
};
|
||||
|
||||
export const Input_Template_Dataset_Quote: FlowNodeInputItemType = {
|
||||
key: ModuleInputKeyEnum.aiChatDatasetQuote,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '知识库引用',
|
||||
description: 'core.module.Dataset quote.Input description',
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
};
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../../type';
|
||||
import {
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../../constants';
|
||||
|
||||
export const HistoryModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.historyNode,
|
||||
templateType: ModuleTemplateTypeEnum.systemInput,
|
||||
flowType: FlowNodeTypeEnum.historyNode,
|
||||
avatar: '/imgs/module/history.png',
|
||||
name: '聊天记录(弃用)',
|
||||
intro: '聊天记录,该模块已被弃用',
|
||||
inputs: [
|
||||
{
|
||||
key: ModuleInputKeyEnum.historyMaxAmount,
|
||||
type: FlowNodeInputTypeEnum.numberInput,
|
||||
label: '最长记录数',
|
||||
description:
|
||||
'该记录数不代表模型可接收这么多的历史记录,具体可接收多少历史记录,取决于模型的能力,通常建议不要超过20条。',
|
||||
value: 6,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
min: 0,
|
||||
max: 100,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.history,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
label: '聊天记录',
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
key: ModuleInputKeyEnum.history,
|
||||
label: '聊天记录',
|
||||
valueType: ModuleIOValueTypeEnum.chatHistory,
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
targets: []
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import {
|
||||
Input_Template_Dataset_Quote,
|
||||
Input_Template_History,
|
||||
Input_Template_Switch,
|
||||
Input_Template_UserChatInput
|
||||
@@ -23,15 +24,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 +42,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 +75,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatQuoteTemplate,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用内容模板',
|
||||
label: '',
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -93,7 +83,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatQuotePrompt,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用内容提示词',
|
||||
label: '',
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
@@ -110,7 +100,7 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiSystemPrompt,
|
||||
type: FlowNodeInputTypeEnum.textarea,
|
||||
label: '系统提示词',
|
||||
label: 'core.ai.Prompt',
|
||||
max: 300,
|
||||
valueType: ModuleIOValueTypeEnum.string,
|
||||
description: chatNodeSystemPromptTip,
|
||||
@@ -119,31 +109,23 @@ export const AiChatModule: FlowModuleTemplateType = {
|
||||
showTargetInPlugin: true
|
||||
},
|
||||
Input_Template_History,
|
||||
{
|
||||
key: ModuleInputKeyEnum.aiChatDatasetQuote,
|
||||
type: FlowNodeInputTypeEnum.target,
|
||||
label: '引用内容',
|
||||
description: "对象数组格式,结构:\n [{q:'问题',a:'回答'}]",
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
showTargetInApp: true,
|
||||
showTargetInPlugin: true
|
||||
},
|
||||
Input_Template_UserChatInput
|
||||
Input_Template_UserChatInput,
|
||||
Input_Template_Dataset_Quote
|
||||
],
|
||||
outputs: [
|
||||
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
|
||||
|
||||
54
packages/global/core/module/template/system/datasetConcat.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
FlowNodeInputTypeEnum,
|
||||
FlowNodeOutputTypeEnum,
|
||||
FlowNodeTypeEnum
|
||||
} from '../../node/constant';
|
||||
import { FlowModuleTemplateType } from '../../type.d';
|
||||
import {
|
||||
ModuleIOValueTypeEnum,
|
||||
ModuleInputKeyEnum,
|
||||
ModuleOutputKeyEnum,
|
||||
ModuleTemplateTypeEnum
|
||||
} from '../../constants';
|
||||
import { Input_Template_Dataset_Quote, Input_Template_Switch } from '../input';
|
||||
import { Output_Template_Finish } from '../output';
|
||||
import { getNanoid } from '../../../../common/string/tools';
|
||||
|
||||
export const getOneQuoteInputTemplate = (key = getNanoid()) => ({
|
||||
...Input_Template_Dataset_Quote,
|
||||
key,
|
||||
type: FlowNodeInputTypeEnum.hidden
|
||||
});
|
||||
|
||||
export const DatasetConcatModule: FlowModuleTemplateType = {
|
||||
id: FlowNodeTypeEnum.datasetConcatNode,
|
||||
flowType: FlowNodeTypeEnum.datasetConcatNode,
|
||||
templateType: ModuleTemplateTypeEnum.tools,
|
||||
avatar: '/imgs/module/concat.svg',
|
||||
name: '知识库搜索引用合并',
|
||||
intro: 'core.module.template.Dataset search result concat intro',
|
||||
showStatus: false,
|
||||
inputs: [
|
||||
Input_Template_Switch,
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetMaxTokens,
|
||||
type: FlowNodeInputTypeEnum.custom,
|
||||
label: '最大 Tokens',
|
||||
value: 1500,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
showTargetInApp: false,
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
getOneQuoteInputTemplate('defaultQuote')
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
key: ModuleOutputKeyEnum.datasetQuoteQA,
|
||||
label: 'core.module.Dataset quote.label',
|
||||
type: FlowNodeOutputTypeEnum.source,
|
||||
valueType: ModuleIOValueTypeEnum.datasetQuote,
|
||||
targets: []
|
||||
},
|
||||
Output_Template_Finish
|
||||
]
|
||||
};
|
||||
@@ -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,
|
||||
@@ -52,10 +52,9 @@ export const DatasetSearchModule: FlowModuleTemplateType = {
|
||||
showTargetInPlugin: false
|
||||
},
|
||||
{
|
||||
key: ModuleInputKeyEnum.datasetLimit,
|
||||
key: ModuleInputKeyEnum.datasetMaxTokens,
|
||||
type: FlowNodeInputTypeEnum.hidden,
|
||||
label: '引用上限',
|
||||
description: '单次搜索最大的 Tokens 数量,中文约1字=1.7Tokens,英文约1字=1Tokens',
|
||||
label: '',
|
||||
value: 1500,
|
||||
valueType: ModuleIOValueTypeEnum.number,
|
||||
showTargetInApp: false,
|
||||
@@ -93,23 +92,21 @@ 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.Dataset quote.label',
|
||||
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,
|
||||
|
||||