Compare commits
101 Commits
v4.8.5
...
v4.8.9-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7141189102 | ||
|
|
3ba9c21828 | ||
|
|
7b388b287a | ||
|
|
e9ba00d38f | ||
|
|
a109c59cc6 | ||
|
|
91bc573571 | ||
|
|
2712ef21ff | ||
|
|
593af8f7dc | ||
|
|
96ebec9809 | ||
|
|
f35ba8e5a7 | ||
|
|
e36d9d794f | ||
|
|
10dcdb5491 | ||
|
|
025d405fe2 | ||
|
|
fe71efbbd2 | ||
|
|
56f6e69bc7 | ||
|
|
998e7833e8 | ||
|
|
110bf9391f | ||
|
|
48f2c95bb9 | ||
|
|
9f37e56173 | ||
|
|
af1cff6230 | ||
|
|
3760726354 | ||
|
|
6ddf0b23fc | ||
|
|
f680bdf54d | ||
|
|
834d36981f | ||
|
|
2fdca621e6 | ||
|
|
8c7f4a3a30 | ||
|
|
41da52d6ed | ||
|
|
446d9cb1b9 | ||
|
|
48a5853550 | ||
|
|
c129874d59 | ||
|
|
cc6fa4207a | ||
|
|
e27abe1f6b | ||
|
|
5cecef5836 | ||
|
|
ee89d0d7a4 | ||
|
|
6eeb1b4da1 | ||
|
|
b6c9bb4a65 | ||
|
|
20aad33850 | ||
|
|
02b51317b4 | ||
|
|
ba933c7450 | ||
|
|
856d7ce48f | ||
|
|
23f22cda18 | ||
|
|
0a9a7691b4 | ||
|
|
8d25a1d3ec | ||
|
|
2d1e53c3b5 | ||
|
|
71d0093768 | ||
|
|
cd554f573e | ||
|
|
2d016b7462 | ||
|
|
65515e7952 | ||
|
|
5906daff9f | ||
|
|
55cefccad1 | ||
|
|
87dac54f1e | ||
|
|
45b8d7e8de | ||
|
|
a478621730 | ||
|
|
a233ab9584 | ||
|
|
8d2a192515 | ||
|
|
dcaf972767 | ||
|
|
f9d43ac009 | ||
|
|
abcf48d5ec | ||
|
|
bf5145e632 | ||
|
|
f37cdabb15 | ||
|
|
e99c91aaa6 | ||
|
|
a4787bce5c | ||
|
|
f24e41f5ec | ||
|
|
85de3c1d64 | ||
|
|
c6f682310c | ||
|
|
991398b8d2 | ||
|
|
f452554663 | ||
|
|
57ff38e16f | ||
|
|
f7b55b501f | ||
|
|
cf7145ab54 | ||
|
|
1eedb9caba | ||
|
|
6390d64417 | ||
|
|
3d80eb288b | ||
|
|
5cb196535f | ||
|
|
982325d066 | ||
|
|
36f8755d09 | ||
|
|
fc96bb99cc | ||
|
|
1e4ffc2481 | ||
|
|
ee7496467b | ||
|
|
b5c98a4f63 | ||
|
|
090c880860 | ||
|
|
dd2a9bdee5 | ||
|
|
8d60ef505f | ||
|
|
b14514c105 | ||
|
|
11ffaaf2c5 | ||
|
|
e2ae571d15 | ||
|
|
f548e24e7d | ||
|
|
5605f1a892 | ||
|
|
88d10451c9 | ||
|
|
8a7bd689ae | ||
|
|
a9cdece341 | ||
|
|
babf03c218 | ||
|
|
9e169a48e3 | ||
|
|
e223390231 | ||
|
|
3257744c76 | ||
|
|
e1e112eaff | ||
|
|
5c37d29451 | ||
|
|
3a16f1a21c | ||
|
|
fa7b73f942 | ||
|
|
f8610d750d | ||
|
|
96a03e9927 |
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,5 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 微信交流群
|
||||
url: https://oss.laf.run/htr4n1-images/fastgpt-qr-code.jpg
|
||||
- name: 飞书话题群
|
||||
url: https://oss.laf.run/otnvvf-imgs/1719505774252.jpg
|
||||
about: FastGPT 全是问题群
|
||||
|
||||
3
.github/workflows/docs-deploy-kubeconfig.yml
vendored
@@ -16,6 +16,9 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Change baseURL
|
||||
run: sed -i 's|^baseURL =.*|baseURL = "https://doc.fastgpt.cn"|g' ./docSite/hugo.toml
|
||||
|
||||
- name: Get current date and time
|
||||
id: datetime
|
||||
run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
5
.github/workflows/helm-release.yaml
vendored
@@ -24,11 +24,6 @@ jobs:
|
||||
export APP_VERSION=${{ steps.vars.outputs.tag }}
|
||||
export HELM_VERSION=${{ steps.vars.outputs.tag }}
|
||||
export HELM_REPO=ghcr.io/${{ github.repository_owner }}
|
||||
if [[ ! "$line" =~ ^v ]]
|
||||
then
|
||||
unset APP_VERSION
|
||||
unset HELM_VERSION
|
||||
fi
|
||||
helm dependency update files/helm/fastgpt
|
||||
helm package files/helm/fastgpt --version ${HELM_VERSION}-helm --app-version ${APP_VERSION} -d bin
|
||||
helm push bin/fastgpt-${HELM_VERSION}-helm.tgz oci://${HELM_REPO}
|
||||
|
||||
2
.github/workflows/preview-image.yml
vendored
@@ -7,7 +7,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-fastgpt-images:
|
||||
preview-fastgpt-images:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
1
.npmrc
@@ -1,2 +1,3 @@
|
||||
public-hoist-pattern[]=*tiktoken*
|
||||
public-hoist-pattern[]=*@zilliz/milvus2-sdk-node*
|
||||
registry=https://registry.npmjs.org/
|
||||
@@ -3,4 +3,6 @@ dist
|
||||
**/.DS_Store
|
||||
node_modules
|
||||
docSite/
|
||||
*.md
|
||||
*.md
|
||||
|
||||
cl100l_base.ts
|
||||
5
.vscode/extensions.json
vendored
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"inlang.vs-code-extension"
|
||||
]
|
||||
}
|
||||
6
.vscode/i18n-ally-custom-framework.yml
vendored
@@ -26,13 +26,14 @@ usageMatchRegex:
|
||||
- "[^\\w\\d]workflowT\\(['\"`]({key})['\"`]"
|
||||
- "[^\\w\\d]userT\\(['\"`]({key})['\"`]"
|
||||
- "[^\\w\\d]chatT\\(['\"`]({key})['\"`]"
|
||||
- "[^\\w\\d]i18nT\\(['\"`]({key})['\"`]"
|
||||
|
||||
# A RegEx to set a custom scope range. This scope will be used as a prefix when detecting keys
|
||||
# and works like how the i18next framework identifies the namespace scope from the
|
||||
# useTranslation() hook.
|
||||
# You should unescape RegEx strings in order to fit in the YAML file
|
||||
# To help with this, you can use https://www.freeformatter.com/json-escape.html
|
||||
scopeRangeRegex: "useTranslation\\(\\s*\\[?\\s*['\"`](.*?)['\"`]"
|
||||
scopeRangeRegex: "([^:]+):"
|
||||
|
||||
# An array of strings containing refactor templates.
|
||||
# The "$1" will be replaced by the keypath specified.
|
||||
@@ -41,6 +42,5 @@ scopeRangeRegex: "useTranslation\\(\\s*\\[?\\s*['\"`](.*?)['\"`]"
|
||||
# refactorTemplates:
|
||||
# - i18n.get("$1")
|
||||
|
||||
|
||||
# If set to true, only enables this custom framework (will disable all built-in frameworks)
|
||||
monopoly: true
|
||||
monopoly: false
|
||||
|
||||
17
.vscode/settings.json
vendored
@@ -2,16 +2,27 @@
|
||||
"editor.formatOnSave": true,
|
||||
"editor.mouseWheelZoom": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"prettier.prettierPath": "../node_modules/prettier",
|
||||
"prettier.prettierPath": "node_modules/prettier",
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"i18n-ally.localesPaths": [
|
||||
"packages/web/i18n",
|
||||
],
|
||||
"i18n-ally.enabledParsers": ["json", "yaml", "js", "ts"],
|
||||
"i18n-ally.enabledParsers": [
|
||||
"json",
|
||||
"yaml",
|
||||
"js",
|
||||
"ts"
|
||||
],
|
||||
"i18n-ally.keystyle": "nested",
|
||||
"i18n-ally.sortKeys": true,
|
||||
"i18n-ally.keepFulfilled": false,
|
||||
"i18n-ally.sourceLanguage": "zh", // 根据此语言文件翻译其他语言文件的变量和内容
|
||||
"i18n-ally.displayLanguage": "zh", // 显示语言
|
||||
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key"
|
||||
"i18n-ally.namespace": true,
|
||||
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
|
||||
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key",
|
||||
"i18n-ally.translate.engines": ["deepl", "google"],
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
||||
|
||||
由于需要部署数据库,部署完后需要等待 2~4 分钟才能正常访问。默认用了最低配置,首次访问时会有些慢。相关使用教程可查看:[Sealos 部署 FastGPT](https://doc.fastgpt.in/docs/development/sealos/)
|
||||
|
||||
* [快开始本地开发](https://doc.fastgpt.in/docs/development/intro/)
|
||||
* [快速开始本地开发](https://doc.fastgpt.in/docs/development/intro/)
|
||||
* [部署 FastGPT](https://doc.fastgpt.in/docs/development/sealos)
|
||||
* [系统配置文件说明](https://doc.fastgpt.in/docs/development/configuration/)
|
||||
* [多模型配置](https://doc.fastgpt.in/docs/development/one-api/)
|
||||
@@ -120,9 +120,9 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
||||
|
||||
## 🏘️ 社区交流群
|
||||
|
||||
wx 扫一下加入:
|
||||
扫码加入飞书话题群 (新开,逐渐弃用微信群):
|
||||
|
||||

|
||||

|
||||
|
||||
<a href="#readme">
|
||||
<img src="https://img.shields.io/badge/-返回顶部-7d09f1.svg" alt="#" align="right">
|
||||
|
||||
BIN
bin/fastgpt-v1.0.0-helm.tgz
Normal file
72
dev.md
@@ -23,6 +23,77 @@ pnpm dev
|
||||
make dev name=app
|
||||
```
|
||||
|
||||
Note: If the Node version is >= 20, you need to pass the `--no-node-snapshot` parameter to Node when running `pnpm i`
|
||||
|
||||
```sh
|
||||
NODE_OPTIONS=--no-node-snapshot pnpm i
|
||||
```
|
||||
|
||||
## I18N
|
||||
|
||||
### Install i18n-ally Plugin
|
||||
|
||||
1. Open the Extensions Marketplace in VSCode, search for and install the `i18n Ally` plugin.
|
||||
|
||||
### Code Optimization Examples
|
||||
|
||||
#### Fetch Specific Namespace Translations in `getServerSideProps`
|
||||
|
||||
```typescript
|
||||
// pages/yourPage.tsx
|
||||
export async function getServerSideProps(context: any) {
|
||||
return {
|
||||
props: {
|
||||
currentTab: context?.query?.currentTab || TabEnum.info,
|
||||
...(await serverSideTranslations(context.locale, ['publish', 'user']))
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### Use useTranslation Hook in Page
|
||||
|
||||
```typescript
|
||||
// pages/yourPage.tsx
|
||||
import { useTranslation } from 'next-i18next';
|
||||
|
||||
const YourComponent = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
mr={2}
|
||||
onClick={() => setShowSelected(false)}
|
||||
>
|
||||
{t('common:close')}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default YourComponent;
|
||||
```
|
||||
|
||||
#### Handle Static File Translations
|
||||
|
||||
```typescript
|
||||
// utils/i18n.ts
|
||||
import { i18nT } from '@fastgpt/web/i18n/utils';
|
||||
|
||||
const staticContent = {
|
||||
id: 'simpleChat',
|
||||
avatar: 'core/workflow/template/aiChat',
|
||||
name: i18nT('app:template.simple_robot'),
|
||||
};
|
||||
|
||||
export default staticContent;
|
||||
```
|
||||
|
||||
### Standardize Translation Format
|
||||
|
||||
- Use the t(namespace:key) format to ensure consistent naming.
|
||||
- Translation keys should use lowercase letters and underscores, e.g., common.close.
|
||||
|
||||
## Build
|
||||
|
||||
@@ -37,4 +108,3 @@ docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/f
|
||||
# Make cmd: Build image with proxy
|
||||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 proxy=taobao
|
||||
```
|
||||
|
||||
|
||||
BIN
docSite/assets/imgs/ai-translate-1.png
Normal file
|
After Width: | Height: | Size: 222 KiB |
BIN
docSite/assets/imgs/ai-translate-2.png
Normal file
|
After Width: | Height: | Size: 204 KiB |
BIN
docSite/assets/imgs/ai-translate-3.png
Normal file
|
After Width: | Height: | Size: 220 KiB |
BIN
docSite/assets/imgs/collection-tags-1.png
Normal file
|
After Width: | Height: | Size: 294 KiB |
BIN
docSite/assets/imgs/collection-tags-2.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
docSite/assets/imgs/collection-tags-3.png
Normal file
|
After Width: | Height: | Size: 126 KiB |
BIN
docSite/assets/imgs/combine-subtitle.png
Normal file
|
After Width: | Height: | Size: 207 KiB |
BIN
docSite/assets/imgs/cut-text.png
Normal file
|
After Width: | Height: | Size: 161 KiB |
BIN
docSite/assets/imgs/extract-subtitle.png
Normal file
|
After Width: | Height: | Size: 197 KiB |
BIN
docSite/assets/imgs/format-original-text.png
Normal file
|
After Width: | Height: | Size: 164 KiB |
BIN
docSite/assets/imgs/gpt-translate-example.png
Normal file
|
After Width: | Height: | Size: 300 KiB |
BIN
docSite/assets/imgs/loop-execution.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
@@ -19,13 +19,15 @@ FastGPT 商业版是基于 FastGPT 开源版的增强版本,增加了一些独
|
||||
| 应用管理与高级编排 | ✅ | ✅ | ✅ |
|
||||
| 文档知识库 | ✅ | ✅ | ✅ |
|
||||
| 外部使用 | ✅ | ✅ | ✅ |
|
||||
| 最大应用数量 | 500 | 无限制 | 由付费套餐决定 |
|
||||
| 最大知识库数量(单个知识库内容无限制) | 30 | 无限制 | 由付费套餐决定 |
|
||||
| 自定义版权信息 | ❌ | ✅ | 设计中 |
|
||||
| 多租户与支付 | ❌ | ✅ | ✅ |
|
||||
| 团队空间 | ❌ | ✅ | ✅ |
|
||||
| 应用发布安全配置 | ❌ | ✅ | ✅ |
|
||||
| 内容审核 | ❌ | ✅ | ✅ |
|
||||
| web站点同步 | ❌ | ✅ | ✅ |
|
||||
| 管理后台 | ❌ | ✅ | ✅ |
|
||||
| 管理后台 | ❌ | ✅ | 不需要 |
|
||||
| 增强训练模式 | ❌ | ✅ | ✅ |
|
||||
| 图片知识库 | ❌ | 设计中 | 设计中 |
|
||||
| 自动规划召回 | ❌ | 设计中 | 设计中 |
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "FastGPT 对话问题引导"
|
||||
icon: "code"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 350
|
||||
weight: 108
|
||||
---
|
||||
|
||||

|
||||
|
||||
50
docSite/content/zh-cn/docs/course/collection_tags.md
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
title: "知识库集合标签"
|
||||
description: "FastGPT 知识库集合标签使用说明"
|
||||
icon: "developer_guide"
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 108
|
||||
---
|
||||
|
||||
知识库集合标签是 FastGPT 商业版特有功能。它允许你对知识库中的数据集合添加标签进行分类,更高效地管理知识库数据。
|
||||
|
||||
而进一步可以在问答中,搜索知识库时添加集合过滤,实现更精确的搜索。
|
||||
|
||||
| | | |
|
||||
| --------------------- | --------------------- | --------------------- |
|
||||
|  |  |  |
|
||||
|
||||
## 标签基础操作说明
|
||||
|
||||
在知识库详情页面,可以对标签进行管理,可执行的操作有
|
||||
|
||||
- 创建标签
|
||||
- 修改标签名
|
||||
- 删除标签
|
||||
- 将一个标签赋给多个数据集合
|
||||
- 给一个数据集合添加多个标签
|
||||
|
||||
也可以利用标签对数据集合进行筛选
|
||||
|
||||
## 知识库搜索-集合过滤说明
|
||||
|
||||
利用标签可以在知识库搜索时,通过填写「集合过滤」这一栏来实现更精确的搜索,具体的填写示例如下
|
||||
|
||||
```json
|
||||
{
|
||||
"tags": {
|
||||
"$and": ["标签 1","标签 2"],
|
||||
"$or": ["有 $and 标签时,and 生效,or 不生效"]
|
||||
},
|
||||
"createTime": {
|
||||
"$gte": "YYYY-MM-DD HH:mm 格式即可,集合的创建时间大于该时间",
|
||||
"$lte": "YYYY-MM-DD HH:mm 格式即可,集合的创建时间小于该时间,可和 $gte 共同使用"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
在填写时有两个注意的点,
|
||||
|
||||
- 标签值可以为 `string` 类型的标签名,也可以为 `null`,而 `null` 代表着未设置标签的数据集合
|
||||
- 标签过滤有 `$and` 和 `$or` 两种条件类型,在同时设置了 `$and` 和 `$or` 的情况下,只有 `$and` 会生效
|
||||
@@ -124,53 +124,36 @@ curl --location --request POST 'https://<oneapi_url>/v1/chat/completions' \
|
||||
|
||||
## 将本地模型接入 FastGPT
|
||||
|
||||
修改 FastGPT 的 `config.json` 配置文件,其中 chatModels(对话模型)用于聊天对话,cqModels(问题分类模型)用来对问题进行分类,extractModels(内容提取模型)则用来进行工具选择。我们分别在 chatModels、cqModels 和 extractModels 中加入 qwen-chat 模型:
|
||||
修改 FastGPT 的 `config.json` 配置文件的 llmModels 部分加入 qwen-chat 模型:
|
||||
|
||||
```json
|
||||
{
|
||||
"chatModels": [
|
||||
...
|
||||
{
|
||||
"model": "qwen-chat",
|
||||
"name": "Qwen",
|
||||
"maxContext": 2048,
|
||||
"maxResponse": 2048,
|
||||
"quoteMaxToken": 2000,
|
||||
"maxTemperature": 1,
|
||||
"vision": false,
|
||||
"defaultSystemChatPrompt": ""
|
||||
}
|
||||
...
|
||||
...
|
||||
"llmModels": [
|
||||
{
|
||||
"model": "qwen-chat", // 模型名(对应OneAPI中渠道的模型名)
|
||||
"name": "Qwen", // 模型别名
|
||||
"avatar": "/imgs/model/Qwen.svg", // 模型的logo
|
||||
"maxContext": 125000, // 最大上下文
|
||||
"maxResponse": 4000, // 最大回复
|
||||
"quoteMaxToken": 120000, // 最大引用内容
|
||||
"maxTemperature": 1.2, // 最大温度
|
||||
"charsPointsPrice": 0, // n积分/1k token(商业版)
|
||||
"censor": false, // 是否开启敏感校验(商业版)
|
||||
"vision": true, // 是否支持图片输入
|
||||
"datasetProcess": true, // 是否设置为知识库处理模型(QA),务必保证至少有一个为true,否则知识库会报错
|
||||
"usedInClassify": true, // 是否用于问题分类(务必保证至少有一个为true)
|
||||
"usedInExtractFields": true, // 是否用于内容提取(务必保证至少有一个为true)
|
||||
"usedInToolCall": true, // 是否用于工具调用(务必保证至少有一个为true)
|
||||
"usedInQueryExtension": true, // 是否用于问题优化(务必保证至少有一个为true)
|
||||
"toolChoice": true, // 是否支持工具选择(分类,内容提取,工具调用会用到。目前只有gpt支持)
|
||||
"functionCall": false, // 是否支持函数调用(分类,内容提取,工具调用会用到。会优先使用 toolChoice,如果为false,则使用 functionCall,如果仍为 false,则使用提示词模式)
|
||||
"customCQPrompt": "", // 自定义文本分类提示词(不支持工具和函数调用的模型
|
||||
"customExtractPrompt": "", // 自定义内容提取提示词
|
||||
"defaultSystemChatPrompt": "", // 对话默认携带的系统提示词
|
||||
"defaultConfig": {} // 请求API时,挟带一些默认配置(比如 GLM4 的 top_p)
|
||||
}
|
||||
],
|
||||
"cqModels": [
|
||||
...
|
||||
{
|
||||
"model": "qwen-chat",
|
||||
"name": "Qwen",
|
||||
"maxContext": 2048,
|
||||
"maxResponse": 2048,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
...
|
||||
],
|
||||
"extractModels": [
|
||||
...
|
||||
{
|
||||
"model": "qwen-chat",
|
||||
"name": "Qwen",
|
||||
"maxContext": 2048,
|
||||
"maxResponse": 2048,
|
||||
"inputPrice": 0,
|
||||
"outputPrice": 0,
|
||||
"toolChoice": true,
|
||||
"functionPrompt": ""
|
||||
}
|
||||
...
|
||||
]
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
然后重启 FastGPT 就可以在应用配置中选择 Qwen 模型进行对话:
|
||||
|
||||
@@ -11,7 +11,6 @@ weight: 707
|
||||
|
||||

|
||||
|
||||
|
||||
{{% alert icon="🤖" context="success" %}}
|
||||
|
||||
- MongoDB:用于存储除了向量外的各类数据
|
||||
@@ -105,20 +104,18 @@ brew install orbstack
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
|
||||
## 开始部署
|
||||
|
||||
### 1. 下载 docker-compose.yml
|
||||
|
||||
|
||||
非 Linux 环境或无法访问外网环境,可手动创建一个目录,并下载配置文件和对应版本的`docker-compose.yml`
|
||||
非 Linux 环境或无法访问外网环境,可手动创建一个目录,并下载配置文件和对应版本的`docker-compose.yml`,在这个文件夹中依据下载的配置文件运行docker,若作为本地开发使用推荐`docker-compose-pgvector`版本,并且自行拉取并运行`sandbox`和`fastgpt`,并在docker配置文件中注释掉`sandbox`和`fastgpt`的部分
|
||||
|
||||
- [config.json](https://github.com/labring/FastGPT/blob/main/projects/app/data/config.json)
|
||||
- [docker-compose.yml](https://github.com/labring/FastGPT/blob/main/files/docker) (注意,不同向量库版本的文件不一样)
|
||||
|
||||
{{% alert icon="🤖" context="success" %}}
|
||||
|
||||
所有 `docker-compose.yml` 配置文件中 `MongoDB` 为 5.x,需要用到AUX指令集,部分 CPU 不支持,需手动更改其镜像版本为 4.4.24**(需要自己在docker hub下载,阿里云镜像没做备份)
|
||||
所有 `docker-compose.yml` 配置文件中 `MongoDB` 为 5.x,需要用到AVX指令集,部分 CPU 不支持,需手动更改其镜像版本为 4.4.24**(需要自己在docker hub下载,阿里云镜像没做备份)
|
||||
|
||||
{{% /alert %}}
|
||||
|
||||
@@ -271,7 +268,6 @@ rs.status()
|
||||
|
||||
默认是写了OneAPi的连接地址和密钥,可以通过修改`docker-compose.yml`中,fastgpt容器的环境变量实现。
|
||||
|
||||
|
||||
`OPENAI_BASE_URL`(API 接口的地址,需要加/v1)
|
||||
`CHAT_API_KEY`(API 接口的凭证)。
|
||||
|
||||
@@ -315,8 +311,7 @@ docker-compose up -d
|
||||
1. `docker exec -it fastgpt sh` 进入 FastGPT 容器。
|
||||
2. 直接输入`env`命令查看所有环境变量。
|
||||
|
||||
|
||||
### 为什么无法连接`本地模型`镜像。
|
||||
### 为什么无法连接`本地模型`镜像
|
||||
|
||||
`docker-compose.yml`中使用了桥接的模式建立了`fastgpt`网络,如想通过0.0.0.0或镜像名访问其它镜像,需将其它镜像也加入到网络中。
|
||||
|
||||
@@ -368,9 +363,9 @@ mongo连接失败,查看mongo的运行状态**对应日志**。
|
||||
|
||||
由于服务初始化错误,系统重启导致。
|
||||
|
||||
* 90%是由于配置文件写不对,导致 JSON 解析报错
|
||||
* 剩下的基本是因为向量数据库连不上
|
||||
- 90%是由于配置文件写不对,导致 JSON 解析报错
|
||||
- 剩下的基本是因为向量数据库连不上
|
||||
|
||||
### 如何修改密码
|
||||
|
||||
修改`docker-compose.yml`文件中`DEFAULT_ROOT_PSW`并重启即可,密码会自动更新。
|
||||
修改`docker-compose.yml`文件中`DEFAULT_ROOT_PSW`并重启即可,密码会自动更新。
|
||||
|
||||
@@ -7,8 +7,7 @@ toc: true
|
||||
weight: 705
|
||||
---
|
||||
|
||||
本文档介绍了如何设置开发环境以构建和测试 [FastGPT](https://fastgpt.in)。
|
||||
|
||||
本文档介绍了如何设置开发环境以构建和测试 [FastGPT](https://fastgpt.in),。
|
||||
|
||||
## 前置依赖项
|
||||
|
||||
@@ -16,13 +15,14 @@ weight: 705
|
||||
|
||||
- [Git](http://git-scm.com/)
|
||||
- [Docker](https://www.docker.com/)(构建镜像)
|
||||
- [Node.js v18.17 / v20.x](http://nodejs.org)
|
||||
- [Node.js v18.17 / v20.x](http://nodejs.org)(版本尽量一样,可以使用nvm管理node版本)
|
||||
- [pnpm](https://pnpm.io/) 版本 8.6.0 (目前官方的开发环境)
|
||||
- make命令: 根据不同平台,百度安装 (官方是GNU Make 4.3)
|
||||
|
||||
## 开始本地开发
|
||||
|
||||
{{% alert context="success" %}}
|
||||
|
||||
1. 用户默认的时区为 `Asia/Shanghai`,非 linux 环境时候,获取系统时间会异常,本地开发时候,可以将用户的时区调整成 UTC(+0)。
|
||||
2. 建议先服务器装好**数据库**,再进行本地开发。
|
||||
{{% /alert %}}
|
||||
@@ -47,9 +47,10 @@ git clone git@github.com:<github_username>/FastGPT.git
|
||||
|
||||
### 3. 安装数据库
|
||||
|
||||
第一次开发,需要先部署数据库,建议本地开发可以随便找一台 2C2G 的轻量小数据库实践。数据库部署教程:[Docker 快速部署](/docs/development/docker/)。部署完了,可以本地访问其数据库。
|
||||
|
||||
第一次开发,需要先部署数据库,建议本地开发可以随便找一台 2C2G 的轻量小数据库实践,或者新建文件夹并配置相关文件用以运行docker。数据库部署教程:[Docker 快速部署](/docs/development/docker/)。部署完了,可以本地访问其数据库。
|
||||
{{% alert context="warning" %}}
|
||||
Mongo 数据库需要注意,需要注意在连接地址中增加 `directConnection=true` 参数,才能连接上副本集的数据库。
|
||||
{{% /alert %}}
|
||||
|
||||
### 4. 初始配置
|
||||
|
||||
@@ -57,7 +58,7 @@ Mongo 数据库需要注意,需要注意在连接地址中增加 `directConnec
|
||||
|
||||
**1. 环境变量**
|
||||
|
||||
复制`.env.template`文件,在同级目录下生成一个`.env.local` 文件,修改`.env.local` 里内容才是有效的变量。变量说明见 .env.template
|
||||
复制`.env.template`文件,在同级目录下生成一个`.env.local` 文件,修改`.env.local` 里内容才是有效的变量。变量说明见 .env.template,主要需要修改`API_KEY`和数据库的地址与端口以及数据库账号的用户名和密码,具体配置需要和docker配置文件相同,其中用户名和密码如需修改需要修改docker配置文件、数据库和`.env.local`文件,不能只改一处。
|
||||
|
||||
**2. config 配置文件**
|
||||
|
||||
@@ -73,7 +74,7 @@ Mongo 数据库需要注意,需要注意在连接地址中增加 `directConnec
|
||||
|
||||
### 5. 运行
|
||||
|
||||
可参考项目根目录下的 `dev.md`
|
||||
可参考项目根目录下的 `dev.md`,第一次编译运行可能会有点慢,需要点耐心哦
|
||||
|
||||
```bash
|
||||
# 给自动化脚本代码执行权限(非 linux 系统, 可以手动执行里面的 postinstall.sh 文件内容)
|
||||
@@ -114,7 +115,6 @@ make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8
|
||||
|
||||
如果遇到问题,比如合并冲突或不知道如何打开拉取请求,请查看 GitHub 的[拉取请求教程](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests),了解如何解决合并冲突和其他问题。一旦您的 PR 被合并,您将自豪地被列为[贡献者表](https://github.com/labring/FastGPT/graphs/contributors)中的一员。
|
||||
|
||||
|
||||
## QA
|
||||
|
||||
### 本地数据库无法连接
|
||||
@@ -130,6 +130,7 @@ make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8
|
||||
FastGPT 在`pnpm i`后会执行`postinstall`脚本,用于自动生成`ChakraUI`的`Type`。如果没有权限,可以先执行`chmod -R +x ./scripts/`,再执行`pnpm i`。
|
||||
|
||||
仍不可行的话,可以手动执行`./scripts/postinstall.sh`里的内容。
|
||||
*如果是Windows下的话,可以使用git bash给`postinstall`脚本添加执行权限并执行sh脚本*
|
||||
|
||||
### TypeError: Cannot read properties of null (reading 'useMemo' )
|
||||
|
||||
@@ -141,6 +142,9 @@ FastGPT 在`pnpm i`后会执行`postinstall`脚本,用于自动生成`ChakraUI
|
||||
4. `cd projects/app`
|
||||
5. `pnpm dev`
|
||||
|
||||
### Error response from daemon: error while creating mount source path 'XXX': mkdir XXX: file exists
|
||||
|
||||
这个错误可能是之前停止容器时有文件残留导致的,首先需要确认相关镜像都全部关闭,然后手动删除相关文件或者重启docker即可
|
||||
|
||||
## 加入社区
|
||||
|
||||
@@ -155,6 +159,7 @@ FastGPT 在`pnpm i`后会执行`postinstall`脚本,用于自动生成`ChakraUI
|
||||
FastGPT 使用了 nextjs 的 page route 作为框架。为了区分好前后端代码,在目录分配上会分成 global, service, web 3个自目录,分别对应着 `前后端共用`、`后端专用`、`前端专用`的代码。
|
||||
|
||||
### monorepo
|
||||
|
||||
FastGPT 采用 pnpm workspace 方式构建 monorepo 项目,主要分为两个部分:
|
||||
|
||||
- projects/app - FastGPT 主项目
|
||||
@@ -173,6 +178,7 @@ support - 支撑功能(用户体系,计费,鉴权等)
|
||||
common - 基础功能(日志管理,文件读写等)
|
||||
|
||||
{{% details title="代码结构说明" closed="true" %}}
|
||||
|
||||
```
|
||||
.
|
||||
├── .github // github 相关配置
|
||||
@@ -200,4 +206,5 @@ common - 基础功能(日志管理,文件读写等)
|
||||
├── README_ja.md
|
||||
├── dev.md
|
||||
```
|
||||
|
||||
{{% /details %}}
|
||||
|
||||
@@ -7,18 +7,22 @@ toc: true
|
||||
weight: 852
|
||||
---
|
||||
|
||||
## 发起对话
|
||||
|
||||
{{% alert icon="🤖 " context="success" %}}
|
||||
该接口的 API Key 需使用`应用特定的 key`,否则会报错。
|
||||
|
||||
有些包调用时,`BaseUrl`需要添加`v1`路径,有些不需要,如果出现404情况,可补充`v1`重试。
|
||||
{{% /alert %}}
|
||||
|
||||
## 发起对话(简易应用和工作流)
|
||||
|
||||
**对话接口兼容`GPT`的接口!如果你的项目使用的是标准的`GPT`官方接口,可以直接通过修改`BaseUrl`和 `Authorization`来访问 FastGpt 应用。**
|
||||
对话接口兼容`GPT`的接口!如果你的项目使用的是标准的`GPT`官方接口,可以直接通过修改`BaseUrl`和 `Authorization`来访问 FastGpt 应用,不过需要注意下面几个规则:
|
||||
|
||||
## 请求
|
||||
{{% alert icon="🤖 " context="success" %}}
|
||||
* 传入的`model`,`temperature`等参数字段均无效,这些字段由编排决定。
|
||||
* 不会返回实际消耗`Token`值,如果需要,可以设置`detail=true`,并手动计算 `responseData` 里的`tokens`值。
|
||||
{{% /alert %}}
|
||||
|
||||
### 请求
|
||||
|
||||
{{< tabs tabTotal="2" >}}
|
||||
{{< tab tabName="请求示例" >}}
|
||||
@@ -67,7 +71,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/v1/chat/completions'
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
## 响应
|
||||
### 响应
|
||||
|
||||
{{< tabs tabTotal="5" >}}
|
||||
{{< tab tabName="detail=false,stream=false 响应" >}}
|
||||
@@ -245,7 +249,7 @@ data: [{"moduleName":"知识库搜索","moduleType":"datasetSearchNode","running
|
||||
{{< /markdownify >}}
|
||||
{{< /tab >}}
|
||||
|
||||
{{< tab tabName="detail=true,stream=true 时,event值" >}}
|
||||
{{< tab tabName="event值" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
event取值:
|
||||
@@ -265,6 +269,192 @@ event取值:
|
||||
{{< /tabs >}}
|
||||
|
||||
|
||||
|
||||
## 请求插件
|
||||
|
||||
插件的接口与对话接口一致,仅请求参数略有区别,有以下规定:
|
||||
|
||||
* 调用插件类型的应用时,接口默认为`detail`模式。
|
||||
* 无需传入 `chatId`,因为插件只能运行一轮。
|
||||
* 无需传入`messages`。
|
||||
* 通过传递`variables`来代表插件的输入。
|
||||
* 通过获取`pluginData`来获取插件输出。
|
||||
|
||||
### 请求示例
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'http://localhost:3000/api/v1/chat/completions' \
|
||||
--header 'Authorization: Bearer test-xxxxx' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"stream": false,
|
||||
"chatId": "test",
|
||||
"variables": {
|
||||
"query":"你好" # 我的插件输入有一个参数,变量名叫 query
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### 响应示例
|
||||
|
||||
{{< tabs tabTotal="3" >}}
|
||||
|
||||
{{< tab tabName="detail=true,stream=false 响应" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
* 插件的输出可以通过查找`responseData`中, `moduleType=pluginOutput`的元素,其`pluginOutput`是插件的输出。
|
||||
* 流输出,仍可以通过`choices`进行获取。
|
||||
|
||||
```json
|
||||
{
|
||||
"responseData": [
|
||||
{
|
||||
"nodeId": "fdDgXQ6SYn8v",
|
||||
"moduleName": "AI 对话",
|
||||
"moduleType": "chatNode",
|
||||
"totalPoints": 0.685,
|
||||
"model": "FastAI-3.5",
|
||||
"tokens": 685,
|
||||
"query": "你好",
|
||||
"maxToken": 2000,
|
||||
"historyPreview": [
|
||||
{
|
||||
"obj": "Human",
|
||||
"value": "你好"
|
||||
},
|
||||
{
|
||||
"obj": "AI",
|
||||
"value": "你好!有什么可以帮助你的吗?欢迎向我提问。"
|
||||
}
|
||||
],
|
||||
"contextTotalLen": 14,
|
||||
"runningTime": 1.73
|
||||
},
|
||||
{
|
||||
"nodeId": "pluginOutput",
|
||||
"moduleName": "自定义插件输出",
|
||||
"moduleType": "pluginOutput",
|
||||
"totalPoints": 0,
|
||||
"pluginOutput": {
|
||||
"result": "你好!有什么可以帮助你的吗?欢迎向我提问。"
|
||||
},
|
||||
"runningTime": 0
|
||||
}
|
||||
],
|
||||
"newVariables": {
|
||||
"query": "你好"
|
||||
},
|
||||
"id": "safsafsa",
|
||||
"model": "",
|
||||
"usage": {
|
||||
"prompt_tokens": 1,
|
||||
"completion_tokens": 1,
|
||||
"total_tokens": 1
|
||||
},
|
||||
"choices": [
|
||||
{
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "你好!有什么可以帮助你的吗?欢迎向我提问。"
|
||||
},
|
||||
"finish_reason": "stop",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
{{< /markdownify >}}
|
||||
{{< /tab >}}
|
||||
|
||||
|
||||
{{< tab tabName="detail=true,stream=true 响应" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
* 插件的输出可以通过获取`event=flowResponses`中的字符串,并将其反序列化后得到一个数组。同样的,查找 `moduleType=pluginOutput`的元素,其`pluginOutput`是插件的输出。
|
||||
* 流输出,仍和对话接口一样获取。
|
||||
|
||||
```bash
|
||||
event: flowNodeStatus
|
||||
data: {"status":"running","name":"AI 对话"}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":""},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"你"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"好"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"!"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"有"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"什"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"么"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"可以"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"帮"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"助"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"你"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"的"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"吗"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":"?"},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{"role":"assistant","content":""},"index":0,"finish_reason":null}]}
|
||||
|
||||
event: answer
|
||||
data: {"id":"","object":"","created":0,"model":"","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
|
||||
|
||||
event: answer
|
||||
data: [DONE]
|
||||
|
||||
event: flowResponses
|
||||
data: [{"nodeId":"fdDgXQ6SYn8v","moduleName":"AI 对话","moduleType":"chatNode","totalPoints":0.033,"model":"FastAI-3.5","tokens":33,"query":"你好","maxToken":2000,"historyPreview":[{"obj":"Human","value":"你好"},{"obj":"AI","value":"你好!有什么可以帮助你的吗?"}],"contextTotalLen":2,"runningTime":1.42},{"nodeId":"pluginOutput","moduleName":"自定义插件输出","moduleType":"pluginOutput","totalPoints":0,"pluginOutput":{"result":"你好!有什么可以帮助你的吗?"},"runningTime":0}]
|
||||
```
|
||||
|
||||
{{< /markdownify >}}
|
||||
{{< /tab >}}
|
||||
|
||||
{{< tab tabName="输出获取" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
event取值:
|
||||
|
||||
- answer: 返回给客户端的文本(最终会算作回答)
|
||||
- fastAnswer: 指定回复返回给客户端的文本(最终会算作回答)
|
||||
- toolCall: 执行工具
|
||||
- toolParams: 工具参数
|
||||
- toolResponse: 工具返回
|
||||
- flowNodeStatus: 运行到的节点状态
|
||||
- flowResponses: 节点完整响应
|
||||
- updateVariables: 更新变量
|
||||
- error: 报错
|
||||
|
||||
{{< /markdownify >}}
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
## 使用案例
|
||||
|
||||
- [接入 NextWeb/ChatGPT web 等应用](/docs/use-cases/openapi)
|
||||
|
||||
@@ -13,7 +13,7 @@ weight: 853
|
||||
|
||||
|
||||
|
||||
## 创建训练订单(4.6.9地址发生改动)
|
||||
## 创建训练订单
|
||||
|
||||
{{< tabs tabTotal="2" >}}
|
||||
{{< tab tabName="请求示例" >}}
|
||||
@@ -26,6 +26,7 @@ curl --location --request POST 'https://api.fastgpt.in/api/support/wallet/usage/
|
||||
--header 'Authorization: Bearer {{apikey}}' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"datasetId": "知识库 ID",
|
||||
"name": "可选,自定义订单名称,例如:文档训练-fastgpt.docx"
|
||||
}'
|
||||
```
|
||||
@@ -127,8 +128,12 @@ curl --location --request POST 'http://localhost:3000/api/core/dataset/create' \
|
||||
{{< markdownify >}}
|
||||
|
||||
```bash
|
||||
curl --location --request GET 'http://localhost:3000/api/core/dataset/list?parentId=' \
|
||||
--header 'Authorization: Bearer {{authorization}}' \
|
||||
curl --location --request POST 'http://localhost:3000/api/core/dataset/list?parentId=' \
|
||||
--header 'Authorization: Bearer xxxx' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"parentId":""
|
||||
}'
|
||||
```
|
||||
|
||||
{{< /markdownify >}}
|
||||
@@ -138,7 +143,7 @@ curl --location --request GET 'http://localhost:3000/api/core/dataset/list?paren
|
||||
{{< markdownify >}}
|
||||
|
||||
{{% alert icon=" " context="success" %}}
|
||||
- parentId - 父级ID,不传或为空,代表获取根目录下的知识库
|
||||
- parentId - 父级ID,传空字符串或者null,代表获取根目录下的知识库
|
||||
{{% /alert %}}
|
||||
|
||||
{{< /markdownify >}}
|
||||
@@ -526,6 +531,8 @@ data 为集合的 ID。
|
||||
{{< tab tabName="请求示例" >}}
|
||||
{{< markdownify >}}
|
||||
|
||||
使用代码上传时,请注意中文 filename 需要进行 encode 处理,否则容易乱码。
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'http://localhost:3000/api/core/dataset/collection/create/localFile' \
|
||||
--header 'Authorization: Bearer {{authorization}}' \
|
||||
@@ -1168,7 +1175,7 @@ curl --location --request PUT 'http://localhost:3000/api/core/dataset/data/updat
|
||||
--header 'Authorization: Bearer {{authorization}}' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"id":"65abd4b29d1448617cba61db",
|
||||
"dataId":"65abd4b29d1448617cba61db",
|
||||
"q":"测试111",
|
||||
"a":"sss",
|
||||
"indexes":[
|
||||
@@ -1191,7 +1198,7 @@ curl --location --request PUT 'http://localhost:3000/api/core/dataset/data/updat
|
||||
{{< markdownify >}}
|
||||
|
||||
{{% alert icon=" " context="success" %}}
|
||||
- id: 数据的id
|
||||
- dataId: 数据的id
|
||||
- q: 主要数据(选填)
|
||||
- a: 辅助数据(选填)
|
||||
- indexes: 自定义索引(选填),类型参考`为集合批量添加添加数据`。如果创建时候有自定义索引,
|
||||
|
||||
@@ -77,7 +77,7 @@ docker-compose up -d
|
||||
|
||||
商业版用户需要执行一个初始化,格式化团队信息。
|
||||
|
||||
发起 1 个 HTTP 请求 ({{rootkey}} 替换成环境变量里的 `rootkey`,{{host}} 替换成自己域名)
|
||||
发起 1 个 HTTP 请求 ({{rootkey}} 替换成环境变量里的 `rootkey`,{{host}} 替换成商业版域名)
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{{host}}/api/init/v468' \
|
||||
|
||||
@@ -10,7 +10,7 @@ weight: 822
|
||||
## Sealos 升级说明
|
||||
|
||||
1. 在应用管理中新建一个应用,镜像为:registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.1
|
||||
2. 无需外网访问地址
|
||||
2. 无需外网访问地址,端口号为3000
|
||||
3. 部署完后,复制应用的内网地址
|
||||
4. 点击变更`FastGPT - 修改环境变量,增加下面的环境变量即可
|
||||
|
||||
@@ -31,4 +31,4 @@ SANDBOX_URL=内网地址
|
||||
1. 新增 - js代码运行节点(更完整的type提醒,后续继续完善)
|
||||
2. 新增 - 内容提取节点支持数据类型选择
|
||||
3. 修复 - 新增的站点同步无法使用
|
||||
4. 修复 - 定时任务无法输入内容
|
||||
4. 修复 - 定时任务无法输入内容
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
title: 'V4.8.4'
|
||||
title: 'V4.8.4(需要初始化)'
|
||||
description: 'FastGPT V4.8.4 更新说明'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
@@ -35,4 +35,4 @@ curl --location --request POST 'https://{{host}}/api/admin/init/484' \
|
||||
6. 修复 - 定时执行初始化错误。
|
||||
7. 修复 - 应用调用传参异常。
|
||||
8. 修复 - ctrl + cv 复杂节点时,nodeId错误。
|
||||
9. 调整组件库全局theme。
|
||||
9. 调整组件库全局theme。
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
title: 'V4.8.5(进行中)'
|
||||
title: 'V4.8.5(需要初始化)'
|
||||
description: 'FastGPT V4.8.5 更新说明'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
@@ -13,8 +13,8 @@ weight: 819
|
||||
|
||||
### 2. 修改镜像
|
||||
|
||||
- fastgpt 镜像 tag 修改成 v4.8.5-alpha
|
||||
- 商业版镜像 tag 修改成 v4.8.5 -alpha
|
||||
- fastgpt 镜像 tag 修改成 v4.8.5
|
||||
- 商业版镜像 tag 修改成 v4.8.5
|
||||
|
||||
### 3. 执行初始化
|
||||
|
||||
@@ -54,9 +54,8 @@ curl --location --request POST 'https://{{host}}/api/admin/init/485' \
|
||||
8. 优化 - 文件夹读取,支持单个文件夹超出 100 个文件
|
||||
9. 优化 - 问答拆分/手动录入,当有`a`字段时,自动将`q`作为补充索引。
|
||||
10. 优化 - 对话框页面代码
|
||||
11. 修复 - SSR渲染
|
||||
12. 优化 - 工作流新节点自动增加序号名
|
||||
13. 修复 - 定时任务无法实际关闭
|
||||
14. 修复 - 输入引导特殊字符导致正则报错
|
||||
15. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃
|
||||
16. 修复 - 自定义输入选择知识库引用时页面崩溃
|
||||
11. 优化 - 工作流新节点自动增加序号名
|
||||
12. 修复 - 定时任务无法实际关闭
|
||||
13. 修复 - 输入引导特殊字符导致正则报错
|
||||
14. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃
|
||||
15. 修复 - 自定义输入选择知识库引用时页面崩溃
|
||||
|
||||
51
docSite/content/zh-cn/docs/development/upgrading/486.md
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: 'V4.8.6(需要初始化)'
|
||||
description: 'FastGPT V4.8.6 更新说明'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 818
|
||||
---
|
||||
|
||||
## 升级指南
|
||||
|
||||
### 1. 做好数据库备份
|
||||
|
||||
### 2. 修改镜像
|
||||
|
||||
- fastgpt 镜像 tag 修改成 v4.8.6
|
||||
- fastgpt-sandbox 镜像 tag 修改成 v4.8.6
|
||||
- 商业版镜像 tag 修改成 v4.8.6
|
||||
|
||||
### 3. 执行初始化
|
||||
|
||||
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 域名**。
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{{host}}/api/admin/initv486' \
|
||||
--header 'rootkey: {{rootkey}}' \
|
||||
--header 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
会初始化应用的继承权限
|
||||
|
||||
-------
|
||||
|
||||
## V4.8.6 更新说明
|
||||
|
||||
1. 新增 - 应用权限继承
|
||||
2. 新增 - 知识库支持单个集合禁用功能
|
||||
3. 新增 - 系统插件模式变更,新增链接读取和数学计算器插件,正式版会更新如何自定义系统插件
|
||||
4. 新增 - 代码沙盒运行参数
|
||||
5. 新增 - AI对话时隐藏头部的功能,主要是适配移动端
|
||||
6. 优化 - 文件读取,Mongo 默认使用从节点,减轻主节点压力
|
||||
7. 优化 - 提示词模板
|
||||
8. 优化 - Mongo model 重复加载
|
||||
9. 修复 - 创建链接集合未返回 id
|
||||
10. 修复 - 文档接口说明
|
||||
11. 修复 - api system 提示合并
|
||||
12. 修复 - 团队插件目录内的内容无法加载
|
||||
13. 修复 - 知识库集合目录面包屑无法加载
|
||||
14. 修复 - Markdown 导出对话异常
|
||||
15. 修复 - 提示模板结束标签错误
|
||||
16. 修复 - 文档描述
|
||||
29
docSite/content/zh-cn/docs/development/upgrading/487.md
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
title: 'V4.8.7'
|
||||
description: 'FastGPT V4.8.7 更新说明'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 817
|
||||
---
|
||||
|
||||
## 升级指南
|
||||
|
||||
### 1. 做好数据库备份
|
||||
|
||||
### 2. 修改镜像
|
||||
|
||||
- fastgpt 镜像 tag 修改成 v4.8.7
|
||||
- 商业版镜像 tag 修改成 v4.8.7
|
||||
|
||||
-------
|
||||
|
||||
## V4.8.7 更新说明
|
||||
|
||||
1. 新增 - 插件支持独立运行,发布和日志查看
|
||||
2. 新增 - 应用搜索
|
||||
3. 优化 - 对话框代码
|
||||
4. 优化 - 升级 Dockerfile node 和 pnpm 版本
|
||||
5. 优化 - local 域名部署,也可以正常使用 vision 模式
|
||||
6. 修复 - 简易模式无法变更全局变量
|
||||
7. 修复 - gpt4o 无法同时使用工具和图片
|
||||
51
docSite/content/zh-cn/docs/development/upgrading/488.md
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: 'V4.8.8(需要初始化)'
|
||||
description: 'FastGPT V4.8.8 更新说明'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 816
|
||||
---
|
||||
|
||||
## 升级指南
|
||||
|
||||
### 1. 做好数据库备份
|
||||
|
||||
### 2. 修改镜像
|
||||
|
||||
- fastgpt 镜像 tag 修改成 v4.8.8-fix2
|
||||
- 商业版镜像 tag 修改成 v4.8.8
|
||||
|
||||
### 3. 执行初始化
|
||||
|
||||
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 域名**。
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{{host}}/api/admin/initv488' \
|
||||
--header 'rootkey: {{rootkey}}' \
|
||||
--header 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
会初始化知识库的继承权限
|
||||
|
||||
-------
|
||||
|
||||
## V4.8.8 更新说明
|
||||
|
||||
[点击查看完整更新](https://github.com/labring/FastGPT/releases/tag/v4.8.8)
|
||||
|
||||
1. 新增 - 重构系统插件的结构。允许向开源社区 PR 系统插件,具体可见: [如何向 FastGPT 社区提交系统插件](https://fael3z0zfze.feishu.cn/wiki/ERZnw9R26iRRG0kXZRec6WL9nwh)。
|
||||
2. 新增 - DuckDuckGo 系统插件。
|
||||
3. 新增 - 飞书 webhook 系统插件。
|
||||
4. 新增 - 修改变量填写方式。提示词输入框以以及工作流中所有 Textarea 输入框,支持输入 / 唤起变量选择,可直接选择所有上游输出值,无需动态引入。
|
||||
5. 商业版新增 - 知识库权限继承。
|
||||
6. 优化 - 移动端快速切换应用交互。
|
||||
7. 优化 - 节点图标。
|
||||
8. 优化 - 对话框引用增加额外复制案件,便于复制。增加引用内容折叠。
|
||||
9. 优化 - OpenAI sdk 升级,并自定义了 whisper 模型接口(未仔细查看 sdk 实现,但 sdk 中 whisper 接口,似乎无法适配一般 fastapi 接口)
|
||||
10. 修复 - Permission 表声明问题。
|
||||
11. 修复 - 并行执行节点,运行时间未正确记录。
|
||||
12. 修复 - 运行详情未正确展示嵌套节点信息。
|
||||
13. 修复 - 简易模式,首次进入,无法正确获取知识库配置。
|
||||
14. 修复 - Log debug level 配置无效。
|
||||
15. 修复 - 插件独立运行时,会将插件输入的值进行变量替换,可能导致后续节点变量异常。
|
||||
51
docSite/content/zh-cn/docs/development/upgrading/489.md
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: 'V4.8.9(进行中)'
|
||||
description: 'FastGPT V4.8.9 更新说明'
|
||||
icon: 'upgrade'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 816
|
||||
---
|
||||
|
||||
## 升级指南
|
||||
|
||||
### 1. 做好数据库备份
|
||||
|
||||
### 2. 修改镜像
|
||||
|
||||
|
||||
### 3. 执行初始化
|
||||
|
||||
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 商业版域名**。
|
||||
|
||||
```bash
|
||||
curl --location --request POST 'https://{{host}}/api/admin/init/489' \
|
||||
--header 'rootkey: {{rootkey}}' \
|
||||
--header 'Content-Type: application/json'
|
||||
```
|
||||
|
||||
会初始化多租户的通知方式
|
||||
|
||||
-------
|
||||
|
||||
## V4.8.9 更新说明
|
||||
|
||||
1. 新增 - 文件上传配置,不再依赖视觉模型决定是否可上传图片,而是通过系统配置决定。
|
||||
2. 新增 - AI 对话节点和工具调用支持选择“是否开启图片识别”,开启后会自动获取对话框上传的图片和“用户问题”中的图片链接。
|
||||
3. 新增 - 文档解析节点。
|
||||
4. 商业版新增 - 团队通知账号绑定,用于接收重要信息。
|
||||
5. 商业版新增 - 知识库集合标签功能,可以对知识库进行标签管理。
|
||||
6. 商业版新增 - 知识库搜索节点支持标签过滤和创建时间过滤。
|
||||
7. 商业版新增 - 转移 App owner 权限。
|
||||
8. 新增 - 删除所有对话引导内容。
|
||||
9. 新增 - QA 拆分支持自定义 chunk 大小,并优化 gpt4o-mini 拆分时,chunk 太大导致生成内容很少的问题。
|
||||
10. 优化 - 对话框信息懒加载,减少网络传输。
|
||||
11. 优化 - 清除选文件缓存,支持重复选择同一个文件。
|
||||
12. 修复 - 知识库上传文件,网络不稳定或文件较多情况下,进度无法到 100%。
|
||||
13. 修复 - 删除应用后回到聊天选择最后一次对话的应用为删除的应用时提示无该应用问题。
|
||||
14. 修复 - 插件动态变量配置默认值时,无法正常显示默认值。
|
||||
15. 修复 - 工具调用温度和最大回复值未生效。
|
||||
16. 修复 - 函数调用模式,assistant role 中,GPT 模型必须传入 content 参数。(不影响大部分模型,目前基本都改用用 ToolChoice 模式,FC 模式已弃用)。
|
||||
17. 修复 - 知识库文件上传进度更新可能异常。
|
||||
18. 修复 - 知识库 rebuilding 时候,页面总是刷新到第一页。
|
||||
19. 修复 - 知识库 list openapi 鉴权问题。
|
||||
@@ -4,7 +4,7 @@ description: '使用 HTTP 模块绘制图片'
|
||||
icon: 'image'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 404
|
||||
weight: 408
|
||||
---
|
||||
|
||||
| | |
|
||||
|
||||
@@ -4,7 +4,7 @@ description: '利用工具调用模块,发送一个飞书webhook通知'
|
||||
icon: 'image'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 404
|
||||
weight: 409
|
||||
---
|
||||
|
||||
该文章展示如何发送一个简单的飞书webhook通知,以此类推,发送其他类型的通知也可以这么操作。
|
||||
@@ -78,7 +78,7 @@ weight: 404
|
||||
},
|
||||
{
|
||||
"nodeId": "u6IAOEssxoZT",
|
||||
"name": "工具调用(实验)",
|
||||
"name": "工具调用",
|
||||
"intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。",
|
||||
"avatar": "/imgs/workflow/tool.svg",
|
||||
"flowNodeType": "tools",
|
||||
@@ -201,7 +201,7 @@ weight: 404
|
||||
"x": 1623.9214305901633,
|
||||
"y": 22.777089001645862
|
||||
},
|
||||
"version": "481",
|
||||
"version": "486",
|
||||
"inputs": [
|
||||
{
|
||||
"key": "system_addInputParam",
|
||||
|
||||
@@ -4,7 +4,7 @@ description: '利用指定回复,创建固定的开头和结尾'
|
||||
icon: 'healing'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 401
|
||||
weight: 405
|
||||
---
|
||||
|
||||

|
||||
|
||||
@@ -4,7 +4,7 @@ description: '将 FastGPT 接入谷歌搜索'
|
||||
icon: 'search'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 402
|
||||
weight: 406
|
||||
---
|
||||
|
||||
| | |
|
||||
@@ -192,7 +192,7 @@ export default async function (ctx: FunctionContext) {
|
||||
},
|
||||
{
|
||||
"nodeId": "NOgbnBzUwDgT",
|
||||
"name": "工具调用(实验)",
|
||||
"name": "工具调用",
|
||||
"intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。",
|
||||
"avatar": "/imgs/workflow/tool.svg",
|
||||
"flowNodeType": "tools",
|
||||
|
||||
@@ -4,7 +4,7 @@ description: '展示高级编排操作数据库的能力'
|
||||
icon: 'database'
|
||||
draft: false
|
||||
toc: true
|
||||
weight: 403
|
||||
weight: 407
|
||||
---
|
||||
|
||||
| | |
|
||||
@@ -436,7 +436,7 @@ HTTP模块中,需要设置 3 个工具参数:
|
||||
},
|
||||
{
|
||||
"nodeId": "fYxwWym8flYL",
|
||||
"name": "工具调用(实验)",
|
||||
"name": "工具调用",
|
||||
"intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。",
|
||||
"avatar": "/imgs/workflow/tool.svg",
|
||||
"flowNodeType": "tools",
|
||||
|
||||
@@ -5,6 +5,7 @@ enableEmoji = true
|
||||
enableGitInfo = false # N.B. .GitInfo does not currently function with git submodule content directories
|
||||
|
||||
defaultContentLanguage = 'zh-cn'
|
||||
defaultContentLanguageInSubdir = false
|
||||
[languages]
|
||||
[languages.zh-cn]
|
||||
title = "FastGPT"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
{{ end }}
|
||||
|
||||
<!-- change -->
|
||||
{{ $repoURL = $repoURL | append "docSite/content" .Site.LanguagePrefix $filePath }}
|
||||
{{ $repoURL = $repoURL | append "docSite/content" .Site.Language.Lang $filePath }}
|
||||
{{ $repoURL = delimit $repoURL "/" }}
|
||||
{{ $editPageURL := replaceRE "(https?://)|(/)+" "$1$2" $repoURL }}
|
||||
|
||||
|
||||
@@ -114,15 +114,15 @@ services:
|
||||
# fastgpt
|
||||
sandbox:
|
||||
container_name: sandbox
|
||||
image: ghcr.io/labring/fastgpt-sandbox:v4.8.4 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.4 # 阿里云
|
||||
image: ghcr.io/labring/fastgpt-sandbox:latest # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:latest # 阿里云
|
||||
networks:
|
||||
- fastgpt
|
||||
restart: always
|
||||
fastgpt:
|
||||
container_name: fastgpt
|
||||
image: ghcr.io/labring/fastgpt:v4.8.4 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.4 # 阿里云
|
||||
image: ghcr.io/labring/fastgpt:v4.8.8-fix2 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.8-fix2 # 阿里云
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
@@ -156,6 +156,7 @@ services:
|
||||
- SANDBOX_URL=http://sandbox:3000
|
||||
# 日志等级: debug, info, warn, error
|
||||
- LOG_LEVEL=info
|
||||
- STORE_LOG_LEVEL=warn
|
||||
volumes:
|
||||
- ./config.json:/app/data/config.json
|
||||
|
||||
@@ -178,7 +179,7 @@ services:
|
||||
- ./mysql:/var/lib/mysql
|
||||
oneapi:
|
||||
container_name: oneapi
|
||||
image: ghcr.io/songquanpeng/one-api:latest
|
||||
image: ghcr.io/songquanpeng/one-api:v0.6.7
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6 # 阿里云
|
||||
ports:
|
||||
- 3001:3000
|
||||
|
||||
@@ -72,15 +72,15 @@ services:
|
||||
# fastgpt
|
||||
sandbox:
|
||||
container_name: sandbox
|
||||
image: ghcr.io/labring/fastgpt-sandbox:v4.8.4 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.4 # 阿里云
|
||||
image: ghcr.io/labring/fastgpt-sandbox:latest # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:latest # 阿里云
|
||||
networks:
|
||||
- fastgpt
|
||||
restart: always
|
||||
fastgpt:
|
||||
container_name: fastgpt
|
||||
image: ghcr.io/labring/fastgpt:v4.8.4 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.4 # 阿里云
|
||||
image: ghcr.io/labring/fastgpt:v4.8.8-fix2 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.8-fix2 # 阿里云
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
@@ -113,13 +113,14 @@ services:
|
||||
- SANDBOX_URL=http://sandbox:3000
|
||||
# 日志等级: debug, info, warn, error
|
||||
- LOG_LEVEL=info
|
||||
- STORE_LOG_LEVEL=warn
|
||||
volumes:
|
||||
- ./config.json:/app/data/config.json
|
||||
|
||||
# oneapi
|
||||
mysql:
|
||||
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mysql:8.0.36 # 阿里云
|
||||
# image: mysql:8.0.36
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mysql:8.0.36 # 阿里云
|
||||
image: mysql:8.0.36
|
||||
container_name: mysql
|
||||
restart: always
|
||||
ports:
|
||||
@@ -135,7 +136,7 @@ services:
|
||||
- ./mysql:/var/lib/mysql
|
||||
oneapi:
|
||||
container_name: oneapi
|
||||
image: ghcr.io/songquanpeng/one-api:latest
|
||||
image: ghcr.io/songquanpeng/one-api:v0.6.7
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6 # 阿里云
|
||||
ports:
|
||||
- 3001:3000
|
||||
|
||||
@@ -53,15 +53,15 @@ services:
|
||||
wait $$!
|
||||
sandbox:
|
||||
container_name: sandbox
|
||||
image: ghcr.io/labring/fastgpt-sandbox:v4.8.4 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.4 # 阿里云
|
||||
image: ghcr.io/labring/fastgpt-sandbox:latest # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:latest # 阿里云
|
||||
networks:
|
||||
- fastgpt
|
||||
restart: always
|
||||
fastgpt:
|
||||
container_name: fastgpt
|
||||
image: ghcr.io/labring/fastgpt:v4.8.4 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.4 # 阿里云
|
||||
image: ghcr.io/labring/fastgpt:v4.8.8-fix2 # git
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.8-fix2 # 阿里云
|
||||
ports:
|
||||
- 3000:3000
|
||||
networks:
|
||||
@@ -94,6 +94,7 @@ services:
|
||||
- SANDBOX_URL=http://sandbox:3000
|
||||
# 日志等级: debug, info, warn, error
|
||||
- LOG_LEVEL=info
|
||||
- STORE_LOG_LEVEL=warn
|
||||
volumes:
|
||||
- ./config.json:/app/data/config.json
|
||||
|
||||
@@ -116,7 +117,7 @@ services:
|
||||
- ./mysql:/var/lib/mysql
|
||||
oneapi:
|
||||
container_name: oneapi
|
||||
image: ghcr.io/songquanpeng/one-api:latest
|
||||
image: ghcr.io/songquanpeng/one-api:v0.6.7
|
||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6 # 阿里云
|
||||
ports:
|
||||
- 3001:3000
|
||||
|
||||
15
package.json
@@ -9,16 +9,17 @@
|
||||
"gen:theme-typings": "chakra-cli tokens packages/web/styles/theme.ts --out node_modules/.pnpm/node_modules/@chakra-ui/styled-system/dist/theming.types.d.ts",
|
||||
"postinstall": "sh ./scripts/postinstall.sh",
|
||||
"initIcon": "node ./scripts/icon/init.js",
|
||||
"previewIcon": "node ./scripts/icon/index.js"
|
||||
"previewIcon": "node ./scripts/icon/index.js",
|
||||
"checkI18n": "node ./scripts/i18n/delete-unused-keys.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chakra-ui/cli": "^2.4.1",
|
||||
"husky": "^8.0.3",
|
||||
"i18next": "23.10.0",
|
||||
"lint-staged": "^13.3.0",
|
||||
"next-i18next": "15.2.0",
|
||||
"i18next": "23.11.5",
|
||||
"next-i18next": "15.3.0",
|
||||
"react-i18next": "14.1.2",
|
||||
"prettier": "3.2.4",
|
||||
"react-i18next": "13.5.0",
|
||||
"zhlint": "^0.7.4"
|
||||
},
|
||||
"lint-staged": {
|
||||
@@ -26,7 +27,7 @@
|
||||
"./docSite/**/**/*.md": "npm run format-doc"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.0.0",
|
||||
"pnpm": ">=8.6.0"
|
||||
"node": ">=18.16.0",
|
||||
"pnpm": ">=9.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,28 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 502000 */
|
||||
export enum AppErrEnum {
|
||||
unExist = 'appUnExist',
|
||||
unAuthApp = 'unAuthApp'
|
||||
unAuthApp = 'unAuthApp',
|
||||
invalidOwner = 'invalidOwner',
|
||||
invalidAppType = 'invalidAppType'
|
||||
}
|
||||
const appErrList = [
|
||||
{
|
||||
statusText: AppErrEnum.unExist,
|
||||
message: '应用不存在'
|
||||
message: i18nT('common:code_error.app_error.not_exist')
|
||||
},
|
||||
{
|
||||
statusText: AppErrEnum.unAuthApp,
|
||||
message: '无权操作该应用'
|
||||
message: i18nT('common:code_error.app_error.un_auth_app')
|
||||
},
|
||||
{
|
||||
statusText: AppErrEnum.invalidOwner,
|
||||
message: i18nT('common:code_error.app_error.invalid_owner')
|
||||
},
|
||||
{
|
||||
statusText: AppErrEnum.invalidAppType,
|
||||
message: i18nT('common:code_error.app_error.invalid_app_type')
|
||||
}
|
||||
];
|
||||
export default appErrList.reduce((acc, cur, index) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 504000 */
|
||||
export enum ChatErrEnum {
|
||||
unAuthChat = 'unAuthChat'
|
||||
@@ -7,7 +7,7 @@ export enum ChatErrEnum {
|
||||
const errList = [
|
||||
{
|
||||
statusText: ChatErrEnum.unAuthChat,
|
||||
message: '无权操作该对话记录'
|
||||
message: i18nT('common:code_error.chat_error.un_auth')
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
|
||||
@@ -5,7 +5,8 @@ const startCode = 507000;
|
||||
export enum CommonErrEnum {
|
||||
fileNotFound = 'fileNotFound',
|
||||
unAuthFile = 'unAuthFile',
|
||||
missingParams = 'missingParams'
|
||||
missingParams = 'missingParams',
|
||||
inheritPermissionError = 'inheritPermissionError'
|
||||
}
|
||||
const datasetErr = [
|
||||
{
|
||||
@@ -19,6 +20,10 @@ const datasetErr = [
|
||||
{
|
||||
statusText: CommonErrEnum.missingParams,
|
||||
message: 'error.missingParams'
|
||||
},
|
||||
{
|
||||
statusText: CommonErrEnum.inheritPermissionError,
|
||||
message: 'error.inheritPermissionError'
|
||||
}
|
||||
];
|
||||
export default datasetErr.reduce((acc, cur, index) => {
|
||||
|
||||
@@ -8,8 +8,8 @@ export enum DatasetErrEnum {
|
||||
unAuthDatasetCollection = 'unAuthDatasetCollection',
|
||||
unAuthDatasetData = 'unAuthDatasetData',
|
||||
unAuthDatasetFile = 'unAuthDatasetFile',
|
||||
|
||||
unLinkCollection = 'unLinkCollection'
|
||||
unLinkCollection = 'unLinkCollection',
|
||||
invalidVectorModelOrQAModel = 'invalidVectorModelOrQAModel'
|
||||
}
|
||||
const datasetErr = [
|
||||
{
|
||||
@@ -39,6 +39,10 @@ const datasetErr = [
|
||||
{
|
||||
statusText: DatasetErrEnum.unLinkCollection,
|
||||
message: 'core.dataset.error.unLinkCollection'
|
||||
},
|
||||
{
|
||||
statusText: DatasetErrEnum.invalidVectorModelOrQAModel,
|
||||
message: 'core.dataset.error.invalidVectorModelOrQAModel'
|
||||
}
|
||||
];
|
||||
export default datasetErr.reduce((acc, cur, index) => {
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 506000 */
|
||||
export enum OpenApiErrEnum {
|
||||
unExist = 'openapiUnExist',
|
||||
unAuth = 'openapiUnAuth'
|
||||
unAuth = 'openapiUnAuth',
|
||||
exceedLimit = 'openapiExceedLimit'
|
||||
}
|
||||
|
||||
const errList = [
|
||||
{
|
||||
statusText: OpenApiErrEnum.unExist,
|
||||
message: 'Api Key 不存在'
|
||||
message: i18nT('common:code_error.openapi_error.api_key_not_exist')
|
||||
},
|
||||
{
|
||||
statusText: OpenApiErrEnum.unAuth,
|
||||
message: '无权操作该 Api Key'
|
||||
message: i18nT('common:code_error.openapi_error.un_auth')
|
||||
},
|
||||
{
|
||||
statusText: OpenApiErrEnum.exceedLimit,
|
||||
message: i18nT('common:code_error.openapi_error.exceed_limit')
|
||||
}
|
||||
];
|
||||
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 505000 */
|
||||
export enum OutLinkErrEnum {
|
||||
unExist = 'outlinkUnExist',
|
||||
unAuthLink = 'unAuthLink',
|
||||
linkUnInvalid = 'linkUnInvalid',
|
||||
|
||||
unAuthUser = 'unAuthUser'
|
||||
}
|
||||
|
||||
const errList = [
|
||||
{
|
||||
statusText: OutLinkErrEnum.unExist,
|
||||
message: '分享链接不存在'
|
||||
message: i18nT('common:code_error.outlink_error.link_not_exist')
|
||||
},
|
||||
{
|
||||
statusText: OutLinkErrEnum.unAuthLink,
|
||||
message: '分享链接无效'
|
||||
message: i18nT('common:code_error.outlink_error.invalid_link')
|
||||
},
|
||||
{
|
||||
code: 501,
|
||||
statusText: OutLinkErrEnum.linkUnInvalid,
|
||||
message: '分享链接无效'
|
||||
message: i18nT('common:code_error.outlink_error.invalid_link') // 使用相同的错误消息
|
||||
},
|
||||
{
|
||||
statusText: OutLinkErrEnum.unAuthUser,
|
||||
message: '身份校验失败'
|
||||
message: i18nT('common:code_error.outlink_error.un_auth_user')
|
||||
}
|
||||
];
|
||||
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 508000 */
|
||||
export enum PluginErrEnum {
|
||||
unExist = 'pluginUnExist',
|
||||
unAuth = 'pluginUnAuth'
|
||||
}
|
||||
|
||||
const errList = [
|
||||
{
|
||||
statusText: PluginErrEnum.unExist,
|
||||
message: '插件不存在'
|
||||
message: i18nT('common:code_error.plugin_error.not_exist')
|
||||
},
|
||||
{
|
||||
statusText: PluginErrEnum.unAuth,
|
||||
message: '无权操作该插件'
|
||||
message: i18nT('common:code_error.plugin_error.un_auth')
|
||||
}
|
||||
];
|
||||
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* dataset: 509000 */
|
||||
export enum SystemErrEnum {
|
||||
communityVersionNumLimit = 'communityVersionNumLimit'
|
||||
}
|
||||
|
||||
const systemErr = [
|
||||
{
|
||||
statusText: SystemErrEnum.communityVersionNumLimit,
|
||||
message: '超出开源版数量限制,请升级商业版: https://fastgpt.in'
|
||||
message: i18nT('common:code_error.system_error.community_version_num_limit')
|
||||
}
|
||||
];
|
||||
|
||||
export default systemErr.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* team: 500000 */
|
||||
export enum TeamErrEnum {
|
||||
teamOverSize = 'teamOverSize',
|
||||
@@ -12,17 +12,43 @@ export enum TeamErrEnum {
|
||||
websiteSyncNotEnough = 'websiteSyncNotEnough',
|
||||
reRankNotEnough = 'reRankNotEnough'
|
||||
}
|
||||
|
||||
const teamErr = [
|
||||
{ statusText: TeamErrEnum.teamOverSize, message: 'error.team.overSize' },
|
||||
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' },
|
||||
{ statusText: TeamErrEnum.aiPointsNotEnough, message: '' },
|
||||
{ statusText: TeamErrEnum.datasetSizeNotEnough, message: '知识库容量不足,请先扩容~' },
|
||||
{ statusText: TeamErrEnum.datasetAmountNotEnough, message: '知识库数量已达上限~' },
|
||||
{ statusText: TeamErrEnum.appAmountNotEnough, message: '应用数量已达上限~' },
|
||||
{ statusText: TeamErrEnum.pluginAmountNotEnough, message: '插件数量已达上限~' },
|
||||
{ statusText: TeamErrEnum.websiteSyncNotEnough, message: '无权使用Web站点同步~' },
|
||||
{ statusText: TeamErrEnum.reRankNotEnough, message: '无权使用检索重排~' }
|
||||
{
|
||||
statusText: TeamErrEnum.teamOverSize,
|
||||
message: i18nT('common:code_error.team_error.over_size')
|
||||
},
|
||||
{ statusText: TeamErrEnum.unAuthTeam, message: i18nT('common:code_error.team_error.un_auth') },
|
||||
{
|
||||
statusText: TeamErrEnum.aiPointsNotEnough,
|
||||
message: i18nT('common:code_error.team_error.ai_points_not_enough')
|
||||
}, // 需要定义或留空
|
||||
{
|
||||
statusText: TeamErrEnum.datasetSizeNotEnough,
|
||||
message: i18nT('common:code_error.team_error.dataset_size_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.datasetAmountNotEnough,
|
||||
message: i18nT('common:code_error.team_error.dataset_amount_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.appAmountNotEnough,
|
||||
message: i18nT('common:code_error.team_error.app_amount_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.pluginAmountNotEnough,
|
||||
message: i18nT('common:code_error.team_error.plugin_amount_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.websiteSyncNotEnough,
|
||||
message: i18nT('common:code_error.team_error.website_sync_not_enough')
|
||||
},
|
||||
{
|
||||
statusText: TeamErrEnum.reRankNotEnough,
|
||||
message: i18nT('common:code_error.team_error.re_rank_not_enough')
|
||||
}
|
||||
];
|
||||
|
||||
export default teamErr.reduce((acc, cur, index) => {
|
||||
return {
|
||||
...acc,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ErrType } from '../errorCode';
|
||||
|
||||
import { i18nT } from '../../../../web/i18n/utils';
|
||||
/* team: 503000 */
|
||||
export enum UserErrEnum {
|
||||
unAuthUser = 'unAuthUser',
|
||||
@@ -8,10 +8,22 @@ export enum UserErrEnum {
|
||||
balanceNotEnough = 'balanceNotEnough'
|
||||
}
|
||||
const errList = [
|
||||
{ statusText: UserErrEnum.unAuthUser, message: '找不到该用户' },
|
||||
{ statusText: UserErrEnum.binVisitor, message: '您的身份校验未通过' },
|
||||
{ statusText: UserErrEnum.binVisitor, message: '您当前身份为游客,无权操作' },
|
||||
{ statusText: UserErrEnum.balanceNotEnough, message: '账号余额不足~' }
|
||||
{
|
||||
statusText: UserErrEnum.unAuthUser,
|
||||
message: i18nT('common:code_error.user_error.un_auth_user')
|
||||
},
|
||||
{
|
||||
statusText: UserErrEnum.binVisitor,
|
||||
message: i18nT('common:code_error.user_error.bin_visitor')
|
||||
}, // 身份校验未通过
|
||||
{
|
||||
statusText: UserErrEnum.binVisitor,
|
||||
message: i18nT('common:code_error.user_error.bin_visitor_guest')
|
||||
}, // 游客身份
|
||||
{
|
||||
statusText: UserErrEnum.balanceNotEnough,
|
||||
message: i18nT('common:code_error.user_error.balance_not_enough')
|
||||
}
|
||||
];
|
||||
export default errList.reduce((acc, cur, index) => {
|
||||
return {
|
||||
|
||||
@@ -8,24 +8,25 @@ import teamErr from './code/team';
|
||||
import userErr from './code/user';
|
||||
import commonErr from './code/common';
|
||||
import SystemErrEnum from './code/system';
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
|
||||
export const ERROR_CODE: { [key: number]: string } = {
|
||||
400: '请求失败',
|
||||
401: '无权访问',
|
||||
403: '紧张访问',
|
||||
404: '请求不存在',
|
||||
405: '请求方法错误',
|
||||
406: '请求的格式错误',
|
||||
410: '资源已删除',
|
||||
422: '验证错误',
|
||||
500: '服务器发生错误',
|
||||
502: '网关错误',
|
||||
503: '服务器暂时过载或维护',
|
||||
504: '网关超时'
|
||||
400: i18nT('common:code_error.error_code.400'),
|
||||
401: i18nT('common:code_error.error_code.401'),
|
||||
403: i18nT('common:code_error.error_code.403'),
|
||||
404: i18nT('common:code_error.error_code.404'),
|
||||
405: i18nT('common:code_error.error_code.405'),
|
||||
406: i18nT('common:code_error.error_code.406'),
|
||||
410: i18nT('common:code_error.error_code.410'),
|
||||
422: i18nT('common:code_error.error_code.422'),
|
||||
500: i18nT('common:code_error.error_code.500'),
|
||||
502: i18nT('common:code_error.error_code.502'),
|
||||
503: i18nT('common:code_error.error_code.503'),
|
||||
504: i18nT('common:code_error.error_code.504')
|
||||
};
|
||||
|
||||
export const TOKEN_ERROR_CODE: Record<number, string> = {
|
||||
403: '登录状态无效,请重新登录'
|
||||
403: i18nT('common:code_error.token_error_code.403')
|
||||
};
|
||||
|
||||
export const proxyError: Record<string, boolean> = {
|
||||
@@ -63,32 +64,31 @@ export const ERROR_RESPONSE: Record<
|
||||
[ERROR_ENUM.unAuthorization]: {
|
||||
code: 403,
|
||||
statusText: ERROR_ENUM.unAuthorization,
|
||||
message: '凭证错误',
|
||||
message: i18nT('common:code_error.error_message.403'),
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.insufficientQuota]: {
|
||||
code: 510,
|
||||
statusText: ERROR_ENUM.insufficientQuota,
|
||||
message: '账号余额不足',
|
||||
message: i18nT('common:code_error.error_message.510'),
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.unAuthModel]: {
|
||||
code: 511,
|
||||
statusText: ERROR_ENUM.unAuthModel,
|
||||
message: '无权操作该模型',
|
||||
message: i18nT('common:code_error.error_message.511'),
|
||||
data: null
|
||||
},
|
||||
|
||||
[ERROR_ENUM.unAuthFile]: {
|
||||
code: 513,
|
||||
statusText: ERROR_ENUM.unAuthFile,
|
||||
message: '无权阅读该文件',
|
||||
message: i18nT('common:code_error.error_message.513'),
|
||||
data: null
|
||||
},
|
||||
[ERROR_ENUM.unAuthApiKey]: {
|
||||
code: 514,
|
||||
statusText: ERROR_ENUM.unAuthApiKey,
|
||||
message: 'Api Key 不合法',
|
||||
message: i18nT('common:code_error.error_message.514'),
|
||||
data: null
|
||||
},
|
||||
...appErr,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { replaceSensitiveText } from '../string/tools';
|
||||
|
||||
export const getErrText = (err: any, def = '') => {
|
||||
export const getErrText = (err: any, def = ''): any => {
|
||||
const msg: string =
|
||||
typeof err === 'string'
|
||||
? err
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
|
||||
/* mongo fs bucket */
|
||||
export enum BucketNameEnum {
|
||||
dataset = 'dataset'
|
||||
dataset = 'dataset',
|
||||
chat = 'chat'
|
||||
}
|
||||
export const bucketNameMap = {
|
||||
[BucketNameEnum.dataset]: {
|
||||
label: 'file.bucket.dataset'
|
||||
label: i18nT('file:bucket_file'),
|
||||
previewExpireMinutes: 30 // 30 minutes
|
||||
},
|
||||
[BucketNameEnum.chat]: {
|
||||
label: i18nT('file:bucket_chat'),
|
||||
previewExpireMinutes: 7 * 24 * 60 // 7 days
|
||||
}
|
||||
};
|
||||
|
||||
export const ReadFileBaseUrl = '/api/common/file/read';
|
||||
|
||||
export const documentFileType = '.txt, .docx, .csv, .xlsx, .pdf, .md, .html, .pptx';
|
||||
|
||||
1
packages/global/common/file/image/type.d.ts
vendored
@@ -9,6 +9,7 @@ export type MongoImageSchemaType = {
|
||||
type: `${MongoImageTypeEnum}`;
|
||||
|
||||
metadata?: {
|
||||
mime?: string; // image mime type.
|
||||
relatedId?: string; // This id is associated with a set of images
|
||||
};
|
||||
};
|
||||
|
||||
5
packages/global/common/frequenctLimit/type.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export type AuthFrequencyLimitProps = {
|
||||
eventId: string;
|
||||
maxAmount: number;
|
||||
expiredTime: Date;
|
||||
};
|
||||
@@ -144,7 +144,7 @@ const commonSplit = (props: SplitProps): SplitResponse => {
|
||||
];
|
||||
}
|
||||
|
||||
const isCustomSteep = checkIsCustomStep(step);
|
||||
const isCustomStep = checkIsCustomStep(step);
|
||||
const isMarkdownSplit = checkIsMarkdownSplit(step);
|
||||
const independentChunk = checkIndependentChunk(step);
|
||||
|
||||
@@ -154,7 +154,7 @@ const commonSplit = (props: SplitProps): SplitResponse => {
|
||||
.replace(
|
||||
reg,
|
||||
(() => {
|
||||
if (isCustomSteep) return splitMarker;
|
||||
if (isCustomStep) return splitMarker;
|
||||
if (independentChunk) return `${splitMarker}$1`;
|
||||
return `$1${splitMarker}`;
|
||||
})()
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import dayjs from 'dayjs';
|
||||
import cronParser from 'cron-parser';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import timezone from 'dayjs/plugin/timezone';
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
export const formatTime2YMDHMW = (time?: Date) => dayjs(time).format('YYYY-MM-DD HH:mm:ss dddd');
|
||||
export const formatTime2YMDHM = (time?: Date) =>
|
||||
time ? dayjs(time).format('YYYY-MM-DD HH:mm') : '';
|
||||
export const formatTime2YMD = (time?: Date) => (time ? dayjs(time).format('YYYY-MM-DD') : '');
|
||||
|
||||
@@ -91,3 +91,10 @@ export const sliceJsonStr = (str: string) => {
|
||||
|
||||
return jsonStr;
|
||||
};
|
||||
|
||||
export const sliceStrStartEnd = (str: string, start: number, end: number) => {
|
||||
const overSize = str.length > start + end;
|
||||
const startContent = str.slice(0, start);
|
||||
const endContent = overSize ? str.slice(-end) : '';
|
||||
return startContent + (overSize ? ` ...... ` : '') + endContent;
|
||||
};
|
||||
|
||||
@@ -32,9 +32,12 @@ export type FastGPTFeConfigsType = {
|
||||
show_promotion?: boolean;
|
||||
show_team_chat?: boolean;
|
||||
concatMd?: string;
|
||||
|
||||
docUrl?: string;
|
||||
chatbotUrl?: string;
|
||||
openAPIDocUrl?: string;
|
||||
systemPluginCourseUrl?: string;
|
||||
|
||||
systemTitle?: string;
|
||||
systemDescription?: string;
|
||||
googleClientVerKey?: string;
|
||||
@@ -70,9 +73,3 @@ export type SystemEnvType = {
|
||||
oneapiUrl?: string;
|
||||
chatApiKey?: string;
|
||||
};
|
||||
|
||||
// declare global {
|
||||
// var feConfigs: FastGPTFeConfigsType;
|
||||
// var systemEnv: SystemEnvType;
|
||||
// var systemInitd: boolean;
|
||||
// }
|
||||
|
||||
9
packages/global/common/type/utils.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> &
|
||||
{
|
||||
[K in Keys]-?: Required<Pick<T, K>> & Partial<Omit<T, K>>;
|
||||
}[Keys];
|
||||
|
||||
export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> &
|
||||
{
|
||||
[K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
|
||||
}[Keys];
|
||||
@@ -2,8 +2,8 @@ import type { LLMModelItemType, VectorModelItemType } from './model.d';
|
||||
|
||||
export const defaultQAModels: LLMModelItemType[] = [
|
||||
{
|
||||
model: 'gpt-3.5-turbo',
|
||||
name: 'gpt-3.5-turbo',
|
||||
model: 'gpt-4o-mini',
|
||||
name: 'gpt-4o-mini',
|
||||
maxContext: 16000,
|
||||
maxResponse: 16000,
|
||||
quoteMaxToken: 13000,
|
||||
|
||||
@@ -100,7 +100,7 @@ export const Prompt_QuotePromptList: PromptTemplateItem[] = [
|
||||
|
||||
<QA>
|
||||
{{quote}}
|
||||
</QA>}
|
||||
</QA>
|
||||
|
||||
思考流程:
|
||||
1. 判断问题是否与 <QA></QA> 标记中的内容有关。
|
||||
@@ -109,8 +109,20 @@ export const Prompt_QuotePromptList: PromptTemplateItem[] = [
|
||||
4. 如果有相同的问题,直接输出对应答案。
|
||||
5. 如果只有相近的问题,请把相近的问题和答案一起输出。
|
||||
|
||||
最后,避免提及你是从 QA 获取的知识,只需要回复答案。
|
||||
回答要求:
|
||||
- 如果没有相关的问答对,你需要澄清。
|
||||
- 回答的内容应尽可能与 <QA></QA> 标记中的内容一致。
|
||||
- 避免提及你是从 QA 获取的知识,只需要回复答案。
|
||||
- 使用 Markdown 语法优化回答格式。
|
||||
- 使用与问题相同的语言回答。
|
||||
|
||||
问题:"""{{question}}"""`
|
||||
}
|
||||
];
|
||||
|
||||
// Document quote prompt
|
||||
export const Prompt_DocumentQuote = `将 <Quote></Quote> 中的内容作为你的知识:
|
||||
<Quote>
|
||||
{{quote}}
|
||||
</Quote>
|
||||
`;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export const Prompt_AgentQA = {
|
||||
description: `<Context></Context> 标记中是一段文本,学习和分析它,并整理学习成果:
|
||||
- 提出问题并给出每个问题的答案。
|
||||
- 答案需详细完整,尽可能保留原文描述。
|
||||
- 答案需详细完整,尽可能保留原文描述,可以适当扩展答案描述。
|
||||
- 答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 Markdown 元素。
|
||||
- 最多提出 30 个问题。
|
||||
- 最多提出 50 个问题。
|
||||
`,
|
||||
fixedText: `请按以下格式整理学习成果:
|
||||
<Context>
|
||||
@@ -20,7 +20,7 @@ A2:
|
||||
|
||||
<Context>
|
||||
{{text}}
|
||||
<Context/>
|
||||
</Context>
|
||||
`
|
||||
};
|
||||
|
||||
|
||||
40
packages/global/core/ai/type.d.ts
vendored
@@ -2,23 +2,46 @@ import openai from 'openai';
|
||||
import type {
|
||||
ChatCompletionMessageToolCall,
|
||||
ChatCompletionChunk,
|
||||
ChatCompletionMessageParam,
|
||||
ChatCompletionMessageParam as SdkChatCompletionMessageParam,
|
||||
ChatCompletionToolMessageParam,
|
||||
ChatCompletionAssistantMessageParam
|
||||
ChatCompletionAssistantMessageParam,
|
||||
ChatCompletionContentPart as SdkChatCompletionContentPart,
|
||||
ChatCompletionUserMessageParam as SdkChatCompletionUserMessageParam
|
||||
} from 'openai/resources';
|
||||
import { ChatMessageTypeEnum } from './constants';
|
||||
|
||||
export * from 'openai/resources';
|
||||
|
||||
export type ChatCompletionMessageParam = ChatCompletionMessageParam & {
|
||||
// Extension of ChatCompletionMessageParam, Add file url type
|
||||
export type ChatCompletionContentPartFile = {
|
||||
type: 'file_url';
|
||||
name: string;
|
||||
url: string;
|
||||
};
|
||||
// Rewrite ChatCompletionContentPart, Add file type
|
||||
export type ChatCompletionContentPart =
|
||||
| SdkChatCompletionContentPart
|
||||
| ChatCompletionContentPartFile;
|
||||
type CustomChatCompletionUserMessageParam = {
|
||||
content: string | Array<ChatCompletionContentPart>;
|
||||
role: 'user';
|
||||
name?: string;
|
||||
};
|
||||
|
||||
export type ChatCompletionMessageParam = (
|
||||
| Exclude<SdkChatCompletionMessageParam, SdkChatCompletionUserMessageParam>
|
||||
| CustomChatCompletionUserMessageParam
|
||||
) & {
|
||||
dataId?: string;
|
||||
};
|
||||
export type SdkChatCompletionMessageParam = SdkChatCompletionMessageParam;
|
||||
|
||||
/* ToolChoice and functionCall extension */
|
||||
export type ChatCompletionToolMessageParam = ChatCompletionToolMessageParam & { name: string };
|
||||
export type ChatCompletionAssistantToolParam = {
|
||||
role: 'assistant';
|
||||
tool_calls: ChatCompletionMessageToolCall[];
|
||||
};
|
||||
|
||||
export type ChatCompletionMessageToolCall = ChatCompletionMessageToolCall & {
|
||||
toolName?: string;
|
||||
toolAvatar?: string;
|
||||
@@ -28,13 +51,16 @@ export type ChatCompletionMessageFunctionCall = ChatCompletionAssistantMessagePa
|
||||
toolName?: string;
|
||||
toolAvatar?: string;
|
||||
};
|
||||
|
||||
// Stream response
|
||||
export type StreamChatType = Stream<ChatCompletionChunk>;
|
||||
|
||||
export default openai;
|
||||
export * from 'openai';
|
||||
|
||||
// Other
|
||||
export type PromptTemplateItem = {
|
||||
title: string;
|
||||
desc: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
export default openai;
|
||||
export * from 'openai';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AppTTSConfigType, AppWhisperConfigType } from './type';
|
||||
import { AppTTSConfigType, AppFileSelectConfigType, AppWhisperConfigType } from './type';
|
||||
|
||||
export enum AppTypeEnum {
|
||||
folder = 'folder',
|
||||
@@ -8,6 +8,8 @@ export enum AppTypeEnum {
|
||||
httpPlugin = 'httpPlugin'
|
||||
}
|
||||
|
||||
export const AppFolderTypeList = [AppTypeEnum.folder, AppTypeEnum.httpPlugin];
|
||||
|
||||
export const defaultTTSConfig: AppTTSConfigType = { type: 'web' };
|
||||
|
||||
export const defaultWhisperConfig: AppWhisperConfigType = {
|
||||
@@ -21,3 +23,9 @@ export const defaultChatInputGuideConfig = {
|
||||
textList: [],
|
||||
customUrl: ''
|
||||
};
|
||||
|
||||
export const defaultAppSelectFileConfig: AppFileSelectConfigType = {
|
||||
canSelectFile: false,
|
||||
canSelectImg: false,
|
||||
maxFiles: 10
|
||||
};
|
||||
|
||||
@@ -4,12 +4,12 @@ import yaml from 'js-yaml';
|
||||
import { OpenAPIV3 } from 'openapi-types';
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from '../../workflow/type/io';
|
||||
import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum } from '../../workflow/node/constant';
|
||||
import { NodeInputKeyEnum, WorkflowIOValueTypeEnum } from '../../workflow/constants';
|
||||
import { WorkflowIOValueTypeEnum } from '../../workflow/constants';
|
||||
import { PluginInputModule } from '../../workflow/template/system/pluginInput';
|
||||
import { PluginOutputModule } from '../../workflow/template/system/pluginOutput';
|
||||
import { HttpModule468 } from '../../workflow/template/system/http468';
|
||||
import { HttpNode468 } from '../../workflow/template/system/http468';
|
||||
import { HttpParamAndHeaderItemType } from '../../workflow/api';
|
||||
import { StoreNodeItemType } from '../../workflow/type';
|
||||
import { StoreNodeItemType } from '../../workflow/type/node';
|
||||
import { HttpImgUrl } from '../../../common/file/image/constants';
|
||||
import SwaggerParser from '@apidevtools/swagger-parser';
|
||||
import { getHandleId } from '../../workflow/utils';
|
||||
@@ -116,16 +116,7 @@ export const httpApiSchema2Plugins = async ({
|
||||
required: param.required,
|
||||
description: param.description,
|
||||
toolDescription: param.description,
|
||||
canEdit: true,
|
||||
editField: {
|
||||
key: true,
|
||||
name: true,
|
||||
description: true,
|
||||
required: true,
|
||||
dataType: true,
|
||||
inputType: true,
|
||||
isToolInput: true
|
||||
}
|
||||
canEdit: true
|
||||
};
|
||||
}) || []),
|
||||
...(propsKeys?.map((key) => {
|
||||
@@ -138,16 +129,7 @@ export const httpApiSchema2Plugins = async ({
|
||||
required: false,
|
||||
description: prop.description,
|
||||
toolDescription: prop.description,
|
||||
canEdit: true,
|
||||
editField: {
|
||||
key: true,
|
||||
name: true,
|
||||
description: true,
|
||||
required: true,
|
||||
dataType: true,
|
||||
inputType: true,
|
||||
isToolInput: true
|
||||
}
|
||||
canEdit: true
|
||||
};
|
||||
}) || [])
|
||||
];
|
||||
@@ -186,10 +168,6 @@ export const httpApiSchema2Plugins = async ({
|
||||
label: param.name,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.reference],
|
||||
canEdit: true,
|
||||
editField: {
|
||||
key: true,
|
||||
valueType: true
|
||||
},
|
||||
value: [pluginInputId, inputIdMap.get(param.name)]
|
||||
};
|
||||
}) || []),
|
||||
@@ -200,10 +178,6 @@ export const httpApiSchema2Plugins = async ({
|
||||
label: key,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.reference],
|
||||
canEdit: true,
|
||||
editField: {
|
||||
key: true,
|
||||
valueType: true
|
||||
},
|
||||
value: [pluginInputId, inputIdMap.get(key)]
|
||||
};
|
||||
}) || [])
|
||||
@@ -271,7 +245,7 @@ export const httpApiSchema2Plugins = async ({
|
||||
}
|
||||
|
||||
/* Combine complete modules */
|
||||
const modules: StoreNodeItemType[] = [
|
||||
const nodes: StoreNodeItemType[] = [
|
||||
{
|
||||
nodeId: pluginInputId,
|
||||
name: PluginInputModule.name,
|
||||
@@ -280,8 +254,8 @@ export const httpApiSchema2Plugins = async ({
|
||||
flowNodeType: PluginInputModule.flowNodeType,
|
||||
showStatus: PluginInputModule.showStatus,
|
||||
position: {
|
||||
x: 616.4226348688949,
|
||||
y: -165.05298493910115
|
||||
x: 473.55206291900333,
|
||||
y: -145.65080850146154
|
||||
},
|
||||
version: PluginInputModule.version,
|
||||
inputs: pluginInputs,
|
||||
@@ -295,8 +269,8 @@ export const httpApiSchema2Plugins = async ({
|
||||
flowNodeType: PluginOutputModule.flowNodeType,
|
||||
showStatus: PluginOutputModule.showStatus,
|
||||
position: {
|
||||
x: 1607.7142331269126,
|
||||
y: -151.8669210746189
|
||||
x: 1847.5956872650024,
|
||||
y: 5.114324648101558
|
||||
},
|
||||
version: PluginOutputModule.version,
|
||||
inputs: [
|
||||
@@ -308,11 +282,6 @@ export const httpApiSchema2Plugins = async ({
|
||||
required: false,
|
||||
description: '',
|
||||
canEdit: true,
|
||||
editField: {
|
||||
key: true,
|
||||
description: true,
|
||||
valueType: true
|
||||
},
|
||||
value: [httpId, 'httpRawResponse']
|
||||
}
|
||||
],
|
||||
@@ -328,29 +297,18 @@ export const httpApiSchema2Plugins = async ({
|
||||
},
|
||||
{
|
||||
nodeId: httpId,
|
||||
name: HttpModule468.name,
|
||||
intro: HttpModule468.intro,
|
||||
avatar: HttpModule468.avatar,
|
||||
flowNodeType: HttpModule468.flowNodeType,
|
||||
name: HttpNode468.name,
|
||||
intro: HttpNode468.intro,
|
||||
avatar: HttpNode468.avatar,
|
||||
flowNodeType: HttpNode468.flowNodeType,
|
||||
showStatus: true,
|
||||
position: {
|
||||
x: 1042.549746602742,
|
||||
y: -447.77496332641647
|
||||
x: 1188.947986995841,
|
||||
y: -473.52694296182904
|
||||
},
|
||||
version: HttpModule468.version,
|
||||
version: HttpNode468.version,
|
||||
inputs: [
|
||||
{
|
||||
key: NodeInputKeyEnum.addInputParam,
|
||||
renderTypeList: [FlowNodeInputTypeEnum.addInputParam],
|
||||
valueType: WorkflowIOValueTypeEnum.dynamic,
|
||||
label: '',
|
||||
required: false,
|
||||
description: 'core.module.input.description.HTTP Dynamic Input',
|
||||
editField: {
|
||||
key: true,
|
||||
valueType: true
|
||||
}
|
||||
},
|
||||
HttpNode468.inputs[0],
|
||||
...httpInputs,
|
||||
{
|
||||
key: 'system_httpMethod',
|
||||
@@ -397,7 +355,7 @@ export const httpApiSchema2Plugins = async ({
|
||||
required: false
|
||||
}
|
||||
],
|
||||
outputs: HttpModule468.outputs
|
||||
outputs: HttpNode468.outputs
|
||||
}
|
||||
];
|
||||
|
||||
@@ -422,7 +380,7 @@ export const httpApiSchema2Plugins = async ({
|
||||
intro: item.description,
|
||||
parentId,
|
||||
type: AppTypeEnum.plugin,
|
||||
modules,
|
||||
modules: nodes,
|
||||
edges,
|
||||
pluginData: {
|
||||
pluginUniId: item.name
|
||||
|
||||
24
packages/global/core/app/plugin/utils.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { StoreNodeItemType } from '../../workflow/type/node';
|
||||
import { FlowNodeInputItemType } from '../../workflow/type/io';
|
||||
import { FlowNodeTypeEnum } from '../../workflow/node/constant';
|
||||
|
||||
export const getPluginInputsFromStoreNodes = (nodes: StoreNodeItemType[]) => {
|
||||
return nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput)?.inputs || [];
|
||||
};
|
||||
export const getPluginRunContent = ({
|
||||
pluginInputs,
|
||||
variables
|
||||
}: {
|
||||
pluginInputs: FlowNodeInputItemType[];
|
||||
variables: Record<string, any>;
|
||||
}) => {
|
||||
const pluginInputsWithValue = pluginInputs.map((input) => {
|
||||
const { key } = input;
|
||||
const value = variables?.hasOwnProperty(key) ? variables[key] : input.defaultValue;
|
||||
return {
|
||||
...input,
|
||||
value
|
||||
};
|
||||
});
|
||||
return JSON.stringify(pluginInputsWithValue);
|
||||
};
|
||||
23
packages/global/core/app/type.d.ts
vendored
@@ -1,12 +1,12 @@
|
||||
import type { FlowNodeTemplateType, StoreNodeItemType } from '../workflow/type';
|
||||
import type { FlowNodeTemplateType, StoreNodeItemType } from '../workflow/type/node';
|
||||
import { AppTypeEnum } from './constants';
|
||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import { VariableInputEnum } from '../workflow/constants';
|
||||
import { NodeInputKeyEnum, VariableInputEnum } from '../workflow/constants';
|
||||
import { SelectedDatasetType } from '../workflow/api';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d';
|
||||
import { StoreEdgeItemType } from '../workflow/type/edge';
|
||||
import { PermissionValueType } from '../../support/permission/type';
|
||||
import { PermissionSchemaType, PermissionValueType } from '../../support/permission/type';
|
||||
import { AppPermission } from '../../support/permission/app/controller';
|
||||
import { ParentIdType } from '../../common/parentFolder/type';
|
||||
|
||||
@@ -21,6 +21,7 @@ export type AppSchema = {
|
||||
name: string;
|
||||
avatar: string;
|
||||
intro: string;
|
||||
|
||||
updateTime: Date;
|
||||
|
||||
modules: StoreNodeItemType[];
|
||||
@@ -39,8 +40,7 @@ export type AppSchema = {
|
||||
|
||||
inited?: boolean;
|
||||
teamTags: string[];
|
||||
defaultPermission: PermissionValueType;
|
||||
};
|
||||
} & PermissionSchemaType;
|
||||
|
||||
export type AppListItemType = {
|
||||
_id: string;
|
||||
@@ -50,10 +50,9 @@ export type AppListItemType = {
|
||||
intro: string;
|
||||
type: AppTypeEnum;
|
||||
updateTime: Date;
|
||||
defaultPermission: PermissionValueType;
|
||||
permission: AppPermission;
|
||||
pluginData?: AppSchema['pluginData'];
|
||||
};
|
||||
permission: AppPermission;
|
||||
} & PermissionSchemaType;
|
||||
|
||||
export type AppDetailType = AppSchema & {
|
||||
permission: AppPermission;
|
||||
@@ -92,6 +91,7 @@ export type AppChatConfigType = {
|
||||
whisperConfig?: AppWhisperConfigType;
|
||||
scheduledTriggerConfig?: AppScheduledTriggerConfigType;
|
||||
chatInputGuide?: ChatInputGuideConfigType;
|
||||
fileSelectConfig?: AppFileSelectConfigType;
|
||||
};
|
||||
export type SettingAIDataType = {
|
||||
model: string;
|
||||
@@ -99,6 +99,7 @@ export type SettingAIDataType = {
|
||||
maxToken: number;
|
||||
isResponseAnswerText?: boolean;
|
||||
maxHistories?: number;
|
||||
[NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode
|
||||
};
|
||||
|
||||
// variable
|
||||
@@ -135,3 +136,9 @@ export type AppScheduledTriggerConfigType = {
|
||||
timezone: string;
|
||||
defaultPrompt: string;
|
||||
};
|
||||
// File
|
||||
export type AppFileSelectConfigType = {
|
||||
canSelectFile: boolean;
|
||||
canSelectImg: boolean;
|
||||
maxFiles: number;
|
||||
};
|
||||
|
||||
@@ -3,30 +3,32 @@ import { FlowNodeTypeEnum } from '../workflow/node/constant';
|
||||
import { NodeInputKeyEnum, FlowNodeTemplateTypeEnum } from '../workflow/constants';
|
||||
import type { FlowNodeInputItemType } from '../workflow/type/io.d';
|
||||
import { getAppChatConfig } from '../workflow/utils';
|
||||
import { StoreNodeItemType } from '../workflow/type';
|
||||
import { StoreNodeItemType } from '../workflow/type/node';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
|
||||
export const getDefaultAppForm = (): AppSimpleEditFormType => ({
|
||||
aiSettings: {
|
||||
model: 'gpt-3.5-turbo',
|
||||
systemPrompt: '',
|
||||
temperature: 0,
|
||||
isResponseAnswerText: true,
|
||||
maxHistories: 6,
|
||||
maxToken: 4000
|
||||
},
|
||||
dataset: {
|
||||
datasets: [],
|
||||
similarity: 0.4,
|
||||
limit: 1500,
|
||||
searchMode: DatasetSearchModeEnum.embedding,
|
||||
usingReRank: false,
|
||||
datasetSearchUsingExtensionQuery: false,
|
||||
datasetSearchExtensionBg: ''
|
||||
},
|
||||
selectedTools: [],
|
||||
chatConfig: {}
|
||||
});
|
||||
export const getDefaultAppForm = (): AppSimpleEditFormType => {
|
||||
return {
|
||||
aiSettings: {
|
||||
model: 'gpt-4o-mini',
|
||||
systemPrompt: '',
|
||||
temperature: 0,
|
||||
isResponseAnswerText: true,
|
||||
maxHistories: 6,
|
||||
maxToken: 4000
|
||||
},
|
||||
dataset: {
|
||||
datasets: [],
|
||||
similarity: 0.4,
|
||||
limit: 1500,
|
||||
searchMode: DatasetSearchModeEnum.embedding,
|
||||
usingReRank: false,
|
||||
datasetSearchUsingExtensionQuery: true,
|
||||
datasetSearchExtensionBg: ''
|
||||
},
|
||||
selectedTools: [],
|
||||
chatConfig: {}
|
||||
};
|
||||
};
|
||||
|
||||
/* format app nodes to edit form */
|
||||
export const appWorkflow2Form = ({
|
||||
|
||||
1
packages/global/core/app/version.d.ts
vendored
@@ -1,4 +1,3 @@
|
||||
import { StoreNodeItemType } from '../workflow/type';
|
||||
import { StoreEdgeItemType } from '../workflow/type/edge';
|
||||
import { AppChatConfigType, AppSchema } from './type';
|
||||
|
||||
|
||||
@@ -56,15 +56,22 @@ export const chats2GPTMessages = ({
|
||||
text: item.text?.content || ''
|
||||
};
|
||||
}
|
||||
if (item.type === 'file' && item.file?.type === ChatFileTypeEnum.image) {
|
||||
return {
|
||||
type: 'image_url',
|
||||
image_url: {
|
||||
if (item.type === ChatItemValueTypeEnum.file) {
|
||||
if (item.file?.type === ChatFileTypeEnum.image) {
|
||||
return {
|
||||
type: 'image_url',
|
||||
image_url: {
|
||||
url: item.file?.url || ''
|
||||
}
|
||||
};
|
||||
} else if (item.file?.type === ChatFileTypeEnum.file) {
|
||||
return {
|
||||
type: 'file_url',
|
||||
name: item.file?.name || '',
|
||||
url: item.file?.url || ''
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
return;
|
||||
})
|
||||
.filter(Boolean) as ChatCompletionContentPart[];
|
||||
|
||||
@@ -166,16 +173,25 @@ export const GPTMessages2Chats = (
|
||||
} else if (item.type === 'image_url') {
|
||||
value.push({
|
||||
//@ts-ignore
|
||||
type: 'file',
|
||||
type: ChatItemValueTypeEnum.file,
|
||||
file: {
|
||||
type: ChatFileTypeEnum.image,
|
||||
name: '',
|
||||
url: item.image_url.url
|
||||
}
|
||||
});
|
||||
} else if (item.type === 'file_url') {
|
||||
value.push({
|
||||
// @ts-ignore
|
||||
type: ChatItemValueTypeEnum.file,
|
||||
file: {
|
||||
type: ChatFileTypeEnum.file,
|
||||
name: item.name,
|
||||
url: item.url
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// @ts-ignore
|
||||
}
|
||||
} else if (
|
||||
obj === ChatRoleEnum.AI &&
|
||||
|
||||
@@ -56,7 +56,4 @@ export enum ChatStatusEnum {
|
||||
finish = 'finish'
|
||||
}
|
||||
|
||||
export const IMG_BLOCK_KEY = 'img-block';
|
||||
export const FILE_BLOCK_KEY = 'file-block';
|
||||
|
||||
export const MARKDOWN_QUOTE_SIGN = 'QUOTE SIGN';
|
||||
|
||||
20
packages/global/core/chat/type.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { ClassifyQuestionAgentItemType } from '../workflow/type';
|
||||
import { ClassifyQuestionAgentItemType } from '../workflow/template/system/classifyQuestion/type';
|
||||
import { SearchDataResponseItemType } from '../dataset/type';
|
||||
import {
|
||||
ChatFileTypeEnum,
|
||||
@@ -13,8 +13,8 @@ import { DispatchNodeResponseKeyEnum } from '../workflow/runtime/constants';
|
||||
import { AppChatConfigType, AppSchema, VariableItemType } from '../app/type';
|
||||
import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d';
|
||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||
import { ChatBoxInputType } from '../../../../projects/app/src/components/ChatBox/type';
|
||||
import { DispatchNodeResponseType } from '../workflow/runtime/type.d';
|
||||
import { ChatBoxInputType } from '../../../../projects/app/src/components/core/chat/ChatContainer/ChatBox/type';
|
||||
|
||||
export type ChatSchema = {
|
||||
_id: string;
|
||||
@@ -106,16 +106,26 @@ export type AdminFbkType = {
|
||||
};
|
||||
|
||||
/* --------- chat item ---------- */
|
||||
export type ChatItemType = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
|
||||
dataId?: string;
|
||||
export type ResponseTagItemType = {
|
||||
totalRunningTime?: number;
|
||||
totalQuoteList?: SearchDataResponseItemType[];
|
||||
llmModuleAccount?: number;
|
||||
historyPreviewLength?: number;
|
||||
};
|
||||
|
||||
export type ChatItemType = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
|
||||
dataId?: string;
|
||||
} & ResponseTagItemType;
|
||||
|
||||
// Frontend type
|
||||
export type ChatSiteItemType = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
|
||||
dataId: string;
|
||||
status: `${ChatStatusEnum}`;
|
||||
moduleName?: string;
|
||||
ttsBuffer?: Uint8Array;
|
||||
} & ChatBoxInputType;
|
||||
responseData?: ChatHistoryItemResType[];
|
||||
} & ChatBoxInputType &
|
||||
ResponseTagItemType;
|
||||
|
||||
/* --------- team chat --------- */
|
||||
export type ChatAppListSchema = {
|
||||
|
||||
@@ -2,6 +2,18 @@ import { DispatchNodeResponseType } from '../workflow/runtime/type';
|
||||
import { FlowNodeTypeEnum } from '../workflow/node/constant';
|
||||
import { ChatItemValueTypeEnum, ChatRoleEnum } from './constants';
|
||||
import { ChatHistoryItemResType, ChatItemType, UserChatItemValueItemType } from './type.d';
|
||||
import { sliceStrStartEnd } from '../../common/string/tools';
|
||||
|
||||
// Concat 2 -> 1, and sort by role
|
||||
export const concatHistories = (histories1: ChatItemType[], histories2: ChatItemType[]) => {
|
||||
const newHistories = [...histories1, ...histories2];
|
||||
return newHistories.sort((a, b) => {
|
||||
if (a.obj === ChatRoleEnum.System) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
};
|
||||
|
||||
export const getChatTitleFromChatMessage = (message?: ChatItemType, defaultValue = '新对话') => {
|
||||
// @ts-ignore
|
||||
@@ -14,6 +26,7 @@ export const getChatTitleFromChatMessage = (message?: ChatItemType, defaultValue
|
||||
return defaultValue;
|
||||
};
|
||||
|
||||
// Keep the first n and last n characters
|
||||
export const getHistoryPreview = (
|
||||
completeMessages: ChatItemType[]
|
||||
): {
|
||||
@@ -21,30 +34,44 @@ export const getHistoryPreview = (
|
||||
value: string;
|
||||
}[] => {
|
||||
return completeMessages.map((item, i) => {
|
||||
if (item.obj === ChatRoleEnum.System || i >= completeMessages.length - 2) {
|
||||
return {
|
||||
obj: item.obj,
|
||||
value: item.value?.[0]?.text?.content || ''
|
||||
};
|
||||
}
|
||||
const n = item.obj === ChatRoleEnum.System || i >= completeMessages.length - 2 ? 80 : 40;
|
||||
|
||||
const content = item.value
|
||||
.map((item) => {
|
||||
if (item.text?.content) {
|
||||
const content =
|
||||
item.text.content.length > 20
|
||||
? `${item.text.content.slice(0, 20)}...`
|
||||
: item.text.content;
|
||||
return content;
|
||||
}
|
||||
return '';
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join('\n');
|
||||
// Get message text content
|
||||
const rawText = (() => {
|
||||
if (item.obj === ChatRoleEnum.System) {
|
||||
return item.value?.map((item) => item.text?.content).join('') || '';
|
||||
} else if (item.obj === ChatRoleEnum.Human) {
|
||||
return (
|
||||
item.value
|
||||
?.map((item) => {
|
||||
if (item?.text?.content) return item?.text?.content;
|
||||
if (item.file?.type === 'image') return 'Input an image';
|
||||
return '';
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join('\n') || ''
|
||||
);
|
||||
} else if (item.obj === ChatRoleEnum.AI) {
|
||||
return (
|
||||
item.value
|
||||
?.map((item) => {
|
||||
return (
|
||||
item.text?.content || item?.tools?.map((item) => item.toolName).join(',') || ''
|
||||
);
|
||||
})
|
||||
.join('') || ''
|
||||
);
|
||||
}
|
||||
return '';
|
||||
})();
|
||||
|
||||
const startContent = rawText.slice(0, n);
|
||||
const endContent = rawText.length > 2 * n ? rawText.slice(-n) : '';
|
||||
const content = startContent + (rawText.length > n ? ` ...... ` : '') + endContent;
|
||||
|
||||
return {
|
||||
obj: item.obj,
|
||||
value: content
|
||||
value: sliceStrStartEnd(content, 80, 80)
|
||||
};
|
||||
});
|
||||
};
|
||||
@@ -54,11 +81,12 @@ export const filterPublicNodeResponseData = ({
|
||||
}: {
|
||||
flowResponses?: ChatHistoryItemResType[];
|
||||
}) => {
|
||||
const filedList = ['quoteList', 'moduleType'];
|
||||
const filedList = ['quoteList', 'moduleType', 'pluginOutput'];
|
||||
const filterModuleTypeList: any[] = [
|
||||
FlowNodeTypeEnum.pluginModule,
|
||||
FlowNodeTypeEnum.datasetSearchNode,
|
||||
FlowNodeTypeEnum.tools
|
||||
FlowNodeTypeEnum.tools,
|
||||
FlowNodeTypeEnum.pluginOutput
|
||||
];
|
||||
|
||||
return flowResponses
|
||||
@@ -78,14 +106,22 @@ export const filterPublicNodeResponseData = ({
|
||||
});
|
||||
};
|
||||
|
||||
export const removeEmptyUserInput = (input: UserChatItemValueItemType[]) => {
|
||||
return input.filter((item) => {
|
||||
if (item.type === ChatItemValueTypeEnum.text && !item.text?.content?.trim()) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === ChatItemValueTypeEnum.file && !item.file?.url) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
export const removeEmptyUserInput = (input?: UserChatItemValueItemType[]) => {
|
||||
return (
|
||||
input?.filter((item) => {
|
||||
if (item.type === ChatItemValueTypeEnum.text && !item.text?.content?.trim()) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === ChatItemValueTypeEnum.file && !item.file?.url) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}) || []
|
||||
);
|
||||
};
|
||||
|
||||
export const getPluginOutputsFromChatResponses = (responses: ChatHistoryItemResType[]) => {
|
||||
const outputs =
|
||||
responses.find((item) => item.moduleType === FlowNodeTypeEnum.pluginOutput)?.pluginOutput ?? {};
|
||||
return outputs;
|
||||
};
|
||||
|
||||
18
packages/global/core/dataset/api.d.ts
vendored
@@ -10,7 +10,6 @@ export type DatasetUpdateBody = {
|
||||
name?: string;
|
||||
avatar?: string;
|
||||
intro?: string;
|
||||
permission?: DatasetSchemaType['permission']; // TODO: Should be deleted.
|
||||
agentModel?: LLMModelItemType;
|
||||
status?: DatasetSchemaType['status'];
|
||||
|
||||
@@ -75,6 +74,23 @@ export type ExternalFileCreateDatasetCollectionParams = ApiCreateDatasetCollecti
|
||||
filename?: string;
|
||||
};
|
||||
|
||||
/* ================= tag ===================== */
|
||||
export type CreateDatasetCollectionTagParams = {
|
||||
datasetId: string;
|
||||
tag: string;
|
||||
};
|
||||
export type AddTagsToCollectionsParams = {
|
||||
originCollectionIds: string[];
|
||||
collectionIds: string[];
|
||||
datasetId: string;
|
||||
tag: string;
|
||||
};
|
||||
export type UpdateDatasetCollectionTagParams = {
|
||||
datasetId: string;
|
||||
tagId: string;
|
||||
tag: string;
|
||||
};
|
||||
|
||||
/* ================= data ===================== */
|
||||
export type PgSearchRawType = {
|
||||
id: string;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DatasetCollectionTypeEnum, TrainingModeEnum, TrainingTypeMap } from '../constants';
|
||||
import { CollectionWithDatasetType, DatasetCollectionSchemaType } from '../type';
|
||||
|
||||
export const getCollectionSourceData = (
|
||||
@@ -12,3 +13,13 @@ export const getCollectionSourceData = (
|
||||
sourceName: collection?.name || ''
|
||||
};
|
||||
};
|
||||
|
||||
export const checkCollectionIsFolder = (type: DatasetCollectionTypeEnum) => {
|
||||
return type === DatasetCollectionTypeEnum.folder || type === DatasetCollectionTypeEnum.virtual;
|
||||
};
|
||||
|
||||
export const getTrainingTypeLabel = (type?: TrainingModeEnum) => {
|
||||
if (!type) return '';
|
||||
if (!TrainingTypeMap[type]) return '';
|
||||
return TrainingTypeMap[type].label;
|
||||
};
|
||||
|
||||
@@ -8,22 +8,22 @@ export enum DatasetTypeEnum {
|
||||
export const DatasetTypeMap = {
|
||||
[DatasetTypeEnum.folder]: {
|
||||
icon: 'common/folderFill',
|
||||
label: 'Folder Dataset',
|
||||
label: 'folder_dataset',
|
||||
collectionLabel: 'common.Folder'
|
||||
},
|
||||
[DatasetTypeEnum.dataset]: {
|
||||
icon: 'core/dataset/commonDataset',
|
||||
label: 'Common Dataset',
|
||||
label: 'common_dataset',
|
||||
collectionLabel: 'common.File'
|
||||
},
|
||||
[DatasetTypeEnum.websiteDataset]: {
|
||||
icon: 'core/dataset/websiteDataset',
|
||||
label: 'Website Dataset',
|
||||
label: 'website_dataset',
|
||||
collectionLabel: 'common.Website'
|
||||
},
|
||||
[DatasetTypeEnum.externalFile]: {
|
||||
icon: 'core/dataset/externalDataset',
|
||||
label: 'External File',
|
||||
label: 'external_file',
|
||||
collectionLabel: 'common.File'
|
||||
}
|
||||
};
|
||||
|
||||
42
packages/global/core/dataset/type.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { PermissionValueType } from 'support/permission/type';
|
||||
import { PermissionSchemaType } from '../../support/permission/type';
|
||||
import type { LLMModelItemType, VectorModelItemType } from '../../core/ai/model.d';
|
||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||
import { PushDatasetDataChunkProps } from './api';
|
||||
@@ -12,31 +12,28 @@ import {
|
||||
import { DatasetPermission } from '../../support/permission/dataset/controller';
|
||||
import { Permission } from '../../support/permission/controller';
|
||||
|
||||
/* schema */
|
||||
export type DatasetSchemaType = {
|
||||
_id: string;
|
||||
parentId: string;
|
||||
parentId?: string;
|
||||
userId: string;
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
updateTime: Date;
|
||||
|
||||
avatar: string;
|
||||
name: string;
|
||||
vectorModel: string;
|
||||
agentModel: string;
|
||||
intro: string;
|
||||
type: DatasetTypeEnum;
|
||||
type: `${DatasetTypeEnum}`;
|
||||
status: `${DatasetStatusEnum}`;
|
||||
permission: DatasetPermission;
|
||||
|
||||
// metadata
|
||||
websiteConfig?: {
|
||||
url: string;
|
||||
selector: string;
|
||||
};
|
||||
externalReadUrl?: string;
|
||||
defaultPermission: PermissionValueType;
|
||||
};
|
||||
} & PermissionSchemaType;
|
||||
// } & PermissionSchemaType;
|
||||
|
||||
export type DatasetCollectionSchemaType = {
|
||||
_id: string;
|
||||
@@ -48,6 +45,7 @@ export type DatasetCollectionSchemaType = {
|
||||
type: DatasetCollectionTypeEnum;
|
||||
createTime: Date;
|
||||
updateTime: Date;
|
||||
forbid?: boolean;
|
||||
|
||||
trainingType: TrainingModeEnum;
|
||||
chunkSize: number;
|
||||
@@ -71,6 +69,13 @@ export type DatasetCollectionSchemaType = {
|
||||
};
|
||||
};
|
||||
|
||||
export type DatasetCollectionTagsSchemaType = {
|
||||
_id: string;
|
||||
teamId: string;
|
||||
datasetId: string;
|
||||
tag: string;
|
||||
};
|
||||
|
||||
export type DatasetDataIndexItemType = {
|
||||
defaultIndex: boolean;
|
||||
dataId: string; // pg data id
|
||||
@@ -89,6 +94,7 @@ export type DatasetDataSchemaType = {
|
||||
updateTime: Date;
|
||||
q: string; // large chunks or question
|
||||
a: string; // answer or custom content
|
||||
forbid?: boolean;
|
||||
fullTextToken: string;
|
||||
indexes: DatasetDataIndexItemType[];
|
||||
rebuilding?: boolean;
|
||||
@@ -131,19 +137,29 @@ export type DatasetSimpleItemType = {
|
||||
};
|
||||
export type DatasetListItemType = {
|
||||
_id: string;
|
||||
parentId: string;
|
||||
avatar: string;
|
||||
name: string;
|
||||
intro: string;
|
||||
type: DatasetTypeEnum;
|
||||
type: `${DatasetTypeEnum}`;
|
||||
permission: DatasetPermission;
|
||||
vectorModel: VectorModelItemType;
|
||||
defaultPermission: PermissionValueType;
|
||||
};
|
||||
} & PermissionSchemaType;
|
||||
|
||||
export type DatasetItemType = Omit<DatasetSchemaType, 'vectorModel' | 'agentModel'> & {
|
||||
vectorModel: VectorModelItemType;
|
||||
agentModel: LLMModelItemType;
|
||||
permission: DatasetPermission;
|
||||
};
|
||||
|
||||
/* ================= tag ===================== */
|
||||
export type DatasetTagType = {
|
||||
_id: string;
|
||||
tag: string;
|
||||
};
|
||||
|
||||
export type TagUsageType = {
|
||||
tagId: string;
|
||||
collections: string[];
|
||||
};
|
||||
|
||||
/* ================= collection ===================== */
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { StoreNodeItemType } from '../workflow/type';
|
||||
|
||||
export enum PluginTypeEnum {
|
||||
folder = 'folder',
|
||||
custom = 'custom',
|
||||
|
||||
2
packages/global/core/plugin/controller.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import { StoreEdgeItemType } from 'core/workflow/type/edge';
|
||||
import type { StoreNodeItemType } from '../workflow/type';
|
||||
import type { StoreNodeItemType } from '../workflow/type/node';
|
||||
import { PluginTypeEnum } from './constants';
|
||||
import { HttpAuthMethodType } from '../app/httpPlugin/type';
|
||||
|
||||
|
||||
5
packages/global/core/plugin/type.d.ts
vendored
@@ -1,8 +1,9 @@
|
||||
import { StoreEdgeItemType } from 'core/workflow/type/edge';
|
||||
import { ModuleTemplateTypeEnum } from '../workflow/constants';
|
||||
import type { FlowModuleTemplateType, StoreNodeItemType } from '../workflow/type';
|
||||
import type { StoreNodeItemType } from '../workflow/type/node';
|
||||
import { PluginSourceEnum, PluginTypeEnum } from './constants';
|
||||
import { MethodType } from './controller';
|
||||
import { FlowNodeTemplateType } from '../workflow/type/node';
|
||||
|
||||
export type PluginItemSchema = {
|
||||
_id: string;
|
||||
@@ -31,7 +32,7 @@ export type PluginItemSchema = {
|
||||
export type PluginTemplateType = PluginRuntimeType & {
|
||||
author?: string;
|
||||
id: string;
|
||||
source: `${PluginSourceEnum}`;
|
||||
source: PluginSourceEnum;
|
||||
templateType: FlowNodeTemplateType['templateType'];
|
||||
intro: string;
|
||||
version: string;
|
||||
|
||||
2
packages/global/core/workflow/api.d.ts
vendored
@@ -4,7 +4,7 @@ import { NodeInputKeyEnum } from './constants';
|
||||
export type SelectedDatasetType = { datasetId: string }[];
|
||||
|
||||
export type HttpBodyType<T = Record<string, any>> = {
|
||||
[NodeInputKeyEnum.addInputParam]: Record<string, any>;
|
||||
// [NodeInputKeyEnum.addInputParam]: Record<string, any>;
|
||||
} & T;
|
||||
export type HttpQueryType = {
|
||||
appId: string;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
export enum FlowNodeTemplateTypeEnum {
|
||||
systemInput = 'systemInput',
|
||||
ai = 'ai',
|
||||
function = 'function',
|
||||
tools = 'tools',
|
||||
textAnswer = 'textAnswer',
|
||||
functionCall = 'functionCall',
|
||||
externalCall = 'externalCall',
|
||||
|
||||
personalPlugin = 'personalPlugin',
|
||||
search = 'search',
|
||||
multimodal = 'multimodal',
|
||||
communication = 'communication',
|
||||
|
||||
other = 'other'
|
||||
other = 'other',
|
||||
teamApp = 'teamApp'
|
||||
}
|
||||
|
||||
export enum WorkflowIOValueTypeEnum {
|
||||
@@ -73,6 +75,8 @@ export enum NodeInputKeyEnum {
|
||||
aiChatQuoteTemplate = 'quoteTemplate',
|
||||
aiChatQuotePrompt = 'quotePrompt',
|
||||
aiChatDatasetQuote = 'quoteQA',
|
||||
aiChatVision = 'aiChatVision',
|
||||
stringQuoteText = 'stringQuoteText',
|
||||
|
||||
// dataset
|
||||
datasetSelectList = 'datasets',
|
||||
@@ -83,6 +87,10 @@ export enum NodeInputKeyEnum {
|
||||
datasetSearchUsingExtensionQuery = 'datasetSearchUsingExtensionQuery',
|
||||
datasetSearchExtensionModel = 'datasetSearchExtensionModel',
|
||||
datasetSearchExtensionBg = 'datasetSearchExtensionBg',
|
||||
collectionFilterMatch = 'collectionFilterMatch',
|
||||
|
||||
// concat dataset
|
||||
datasetQuoteList = 'system_datasetQuoteList',
|
||||
|
||||
// context extract
|
||||
contextExtractInput = 'content',
|
||||
@@ -112,7 +120,10 @@ export enum NodeInputKeyEnum {
|
||||
|
||||
// code
|
||||
code = 'code',
|
||||
codeType = 'codeType' // js|py
|
||||
codeType = 'codeType', // js|py
|
||||
|
||||
// read files
|
||||
fileUrlList = 'fileUrlList'
|
||||
}
|
||||
|
||||
export enum NodeOutputKeyEnum {
|
||||
@@ -127,6 +138,9 @@ export enum NodeOutputKeyEnum {
|
||||
addOutputParam = 'system_addOutputParam',
|
||||
rawResponse = 'system_rawResponse',
|
||||
|
||||
// start
|
||||
userFiles = 'userFiles',
|
||||
|
||||
// dataset
|
||||
datasetQuoteQA = 'quoteQA',
|
||||
|
||||
@@ -180,8 +194,6 @@ export const variableMap = {
|
||||
}
|
||||
};
|
||||
|
||||
export const DYNAMIC_INPUT_REFERENCE_KEY = 'DYNAMIC_INPUT_REFERENCE_KEY';
|
||||
|
||||
/* run time */
|
||||
export enum RuntimeEdgeStatusEnum {
|
||||
'waiting' = 'waiting',
|
||||
@@ -190,3 +202,4 @@ export enum RuntimeEdgeStatusEnum {
|
||||
}
|
||||
|
||||
export const VARIABLE_NODE_ID = 'VARIABLE_NODE_ID';
|
||||
export const DYNAMIC_INPUT_REFERENCE_KEY = 'DYNAMIC_INPUT_REFERENCE_KEY';
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { WorkflowIOValueTypeEnum } from '../constants';
|
||||
|
||||
export enum FlowNodeInputTypeEnum { // render ui
|
||||
reference = 'reference', // reference to other node output
|
||||
input = 'input', // one line input
|
||||
numberInput = 'numberInput',
|
||||
switch = 'switch', // true/false
|
||||
select = 'select',
|
||||
|
||||
// editor
|
||||
textarea = 'textarea',
|
||||
@@ -22,8 +25,6 @@ export enum FlowNodeInputTypeEnum { // render ui
|
||||
selectDatasetParamsModal = 'selectDatasetParamsModal',
|
||||
settingDatasetQuotePrompt = 'settingDatasetQuotePrompt',
|
||||
|
||||
select = 'select',
|
||||
|
||||
hidden = 'hidden',
|
||||
custom = 'custom'
|
||||
}
|
||||
@@ -114,8 +115,98 @@ export enum FlowNodeTypeEnum {
|
||||
lafModule = 'lafModule',
|
||||
ifElseNode = 'ifElseNode',
|
||||
variableUpdate = 'variableUpdate',
|
||||
code = 'code'
|
||||
code = 'code',
|
||||
textEditor = 'textEditor',
|
||||
customFeedback = 'customFeedback',
|
||||
readFiles = 'readFiles'
|
||||
}
|
||||
|
||||
// node IO value type
|
||||
export const FlowValueTypeMap = {
|
||||
[WorkflowIOValueTypeEnum.string]: {
|
||||
label: 'string',
|
||||
value: WorkflowIOValueTypeEnum.string,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.number]: {
|
||||
label: 'number',
|
||||
value: WorkflowIOValueTypeEnum.number,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.boolean]: {
|
||||
label: 'boolean',
|
||||
value: WorkflowIOValueTypeEnum.boolean,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.object]: {
|
||||
label: 'object',
|
||||
value: WorkflowIOValueTypeEnum.object,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayString]: {
|
||||
label: 'array<string>',
|
||||
value: WorkflowIOValueTypeEnum.arrayString,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayNumber]: {
|
||||
label: 'array<number>',
|
||||
value: WorkflowIOValueTypeEnum.arrayNumber,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayBoolean]: {
|
||||
label: 'array<boolean>',
|
||||
value: WorkflowIOValueTypeEnum.arrayBoolean,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.arrayObject]: {
|
||||
label: 'array<object>',
|
||||
value: WorkflowIOValueTypeEnum.arrayObject,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.any]: {
|
||||
label: 'any',
|
||||
value: WorkflowIOValueTypeEnum.any,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.chatHistory]: {
|
||||
label: '历史记录',
|
||||
value: WorkflowIOValueTypeEnum.chatHistory,
|
||||
description: `{
|
||||
obj: System | Human | AI;
|
||||
value: string;
|
||||
}[]`
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.datasetQuote]: {
|
||||
label: '知识库引用',
|
||||
value: WorkflowIOValueTypeEnum.datasetQuote,
|
||||
description: `{
|
||||
id: string;
|
||||
datasetId: string;
|
||||
collectionId: string;
|
||||
sourceName: string;
|
||||
sourceId?: string;
|
||||
q: string;
|
||||
a: string
|
||||
}[]`
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.selectApp]: {
|
||||
label: '选择应用',
|
||||
value: WorkflowIOValueTypeEnum.selectApp,
|
||||
description: ''
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.selectDataset]: {
|
||||
label: '选择知识库',
|
||||
value: WorkflowIOValueTypeEnum.selectDataset,
|
||||
description: `{
|
||||
datasetId: string;
|
||||
}`
|
||||
},
|
||||
[WorkflowIOValueTypeEnum.dynamic]: {
|
||||
label: '动态输入',
|
||||
value: WorkflowIOValueTypeEnum.dynamic,
|
||||
description: ''
|
||||
}
|
||||
};
|
||||
|
||||
export const EDGE_TYPE = 'default';
|
||||
export const defaultNodeVersion = '481';
|
||||
|
||||
17
packages/global/core/workflow/node/io/utils.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { FlowNodeInputItemType } from '../../type/io';
|
||||
|
||||
export const getInputComponentProps = (input: FlowNodeInputItemType) => {
|
||||
return {
|
||||
referencePlaceholder: input.referencePlaceholder,
|
||||
placeholder: input.placeholder,
|
||||
maxLength: input.maxLength,
|
||||
list: input.list,
|
||||
markList: input.markList,
|
||||
step: input.step,
|
||||
max: input.max,
|
||||
min: input.min,
|
||||
defaultValue: input.defaultValue,
|
||||
llmModelType: input.llmModelType,
|
||||
customInputConfig: input.customInputConfig
|
||||
};
|
||||
};
|
||||
39
packages/global/core/workflow/node/type.d.ts
vendored
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
react flow type
|
||||
*/
|
||||
import { FlowNodeInputTypeEnum, FlowNodeOutputTypeEnum, FlowNodeTypeEnum } from './constant';
|
||||
import { WorkflowIOValueTypeEnum, NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants';
|
||||
import { SelectedDatasetType } from '../api';
|
||||
import { LLMModelTypeEnum } from '../../ai/constants';
|
||||
|
||||
/* --------------- edit field ------------------- */
|
||||
export type EditInputFieldMapType = EditOutputFieldMapType & {
|
||||
inputType?: boolean;
|
||||
};
|
||||
export type EditOutputFieldMapType = {
|
||||
key?: boolean;
|
||||
description?: boolean;
|
||||
valueType?: boolean; // output
|
||||
required?: boolean;
|
||||
defaultValue?: boolean;
|
||||
};
|
||||
export type EditNodeFieldType = {
|
||||
inputType?: FlowNodeInputTypeEnum; // input type
|
||||
valueType?: WorkflowIOValueTypeEnum;
|
||||
required?: boolean;
|
||||
key?: string;
|
||||
label?: string;
|
||||
description?: string;
|
||||
isToolInput?: boolean;
|
||||
|
||||
defaultValue?: string;
|
||||
maxLength?: number;
|
||||
max?: number;
|
||||
min?: number;
|
||||
editField?: EditInputFieldMapType;
|
||||
dynamicParamDefaultValue?: {
|
||||
inputType?: FlowNodeInputTypeEnum; // input type
|
||||
valueType?: WorkflowIOValueTypeEnum;
|
||||
required?: boolean;
|
||||
};
|
||||
};
|
||||
72
packages/global/core/workflow/runtime/type.d.ts
vendored
@@ -1,11 +1,59 @@
|
||||
import { ChatNodeUsageType } from '../../../support/wallet/bill/type';
|
||||
import { ChatItemValueItemType, ToolRunResponseItemType } from '../../chat/type';
|
||||
import {
|
||||
ChatItemType,
|
||||
UserChatItemValueItemType,
|
||||
ChatItemValueItemType,
|
||||
ToolRunResponseItemType
|
||||
} from '../../chat/type';
|
||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from '../type/io.d';
|
||||
import { StoreNodeItemType } from '../type';
|
||||
import { StoreNodeItemType } from '../type/node';
|
||||
import { DispatchNodeResponseKeyEnum } from './constants';
|
||||
import { StoreEdgeItemType } from '../type/edge';
|
||||
import { NodeInputKeyEnum } from '../constants';
|
||||
import { ClassifyQuestionAgentItemType } from '../template/system/classifyQuestion/type';
|
||||
import { NextApiResponse } from 'next';
|
||||
import { UserModelSchema } from '../../../support/user/type';
|
||||
import { AppDetailType, AppSchema } from '../../app/type';
|
||||
import { RuntimeNodeItemType } from '../runtime/type';
|
||||
import { RuntimeEdgeItemType } from './edge';
|
||||
import { ReadFileNodeResponse } from '../template/system/readFiles/type';
|
||||
|
||||
/* workflow props */
|
||||
export type ChatDispatchProps = {
|
||||
res?: NextApiResponse;
|
||||
requestOrigin?: string;
|
||||
mode: 'test' | 'chat' | 'debug';
|
||||
teamId: string;
|
||||
tmbId: string;
|
||||
user: UserModelSchema;
|
||||
app: AppDetailType | AppSchema;
|
||||
chatId?: string;
|
||||
responseChatItemId?: string;
|
||||
histories: ChatItemType[];
|
||||
variables: Record<string, any>; // global variable
|
||||
query: UserChatItemValueItemType[]; // trigger query
|
||||
chatConfig: AppSchema['chatConfig'];
|
||||
stream: boolean;
|
||||
detail: boolean; // response detail
|
||||
maxRunTimes: number;
|
||||
isToolCall?: boolean;
|
||||
};
|
||||
|
||||
export type ModuleDispatchProps<T> = ChatDispatchProps & {
|
||||
node: RuntimeNodeItemType;
|
||||
runtimeNodes: RuntimeNodeItemType[];
|
||||
runtimeEdges: RuntimeEdgeItemType[];
|
||||
params: T;
|
||||
};
|
||||
|
||||
export type SystemVariablesType = {
|
||||
appId: string;
|
||||
chatId?: string;
|
||||
responseChatItemId?: string;
|
||||
histories: ChatItemType[];
|
||||
};
|
||||
|
||||
/* node props */
|
||||
export type RuntimeNodeItemType = {
|
||||
nodeId: StoreNodeItemType['nodeId'];
|
||||
name: StoreNodeItemType['name'];
|
||||
@@ -21,6 +69,17 @@ export type RuntimeNodeItemType = {
|
||||
pluginId?: string;
|
||||
};
|
||||
|
||||
export type PluginRuntimeType = {
|
||||
id: string;
|
||||
teamId?: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
showStatus?: boolean;
|
||||
currentCost?: number;
|
||||
nodes: StoreNodeItemType[];
|
||||
edges: StoreEdgeItemType[];
|
||||
};
|
||||
|
||||
export type RuntimeEdgeItemType = StoreEdgeItemType & {
|
||||
status: 'waiting' | 'active' | 'skipped';
|
||||
};
|
||||
@@ -87,6 +146,13 @@ export type DispatchNodeResponseType = {
|
||||
|
||||
// code
|
||||
codeLog?: string;
|
||||
|
||||
// plugin
|
||||
pluginOutput?: Record<string, any>;
|
||||
|
||||
// read files
|
||||
readFilesResult?: string;
|
||||
readFiles?: ReadFileNodeResponse;
|
||||
};
|
||||
|
||||
export type DispatchNodeResultType<T> = {
|
||||
@@ -107,4 +173,6 @@ export type AIChatNodeProps = {
|
||||
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;
|
||||
[NodeInputKeyEnum.aiChatQuoteTemplate]?: string;
|
||||
[NodeInputKeyEnum.aiChatQuotePrompt]?: string;
|
||||
[NodeInputKeyEnum.aiChatVision]?: boolean;
|
||||
[NodeInputKeyEnum.stringQuoteText]?: string;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChatCompletionRequestMessageRoleEnum } from '../../ai/constants';
|
||||
import { NodeInputKeyEnum, NodeOutputKeyEnum } from '../constants';
|
||||
import { FlowNodeTypeEnum } from '../node/constant';
|
||||
import { StoreNodeItemType } from '../type';
|
||||
import { StoreNodeItemType } from '../type/node';
|
||||
import { StoreEdgeItemType } from '../type/edge';
|
||||
import { RuntimeEdgeItemType, RuntimeNodeItemType } from './type';
|
||||
import { VARIABLE_NODE_ID } from '../constants';
|
||||
@@ -123,6 +123,7 @@ export const checkNodeRunStatus = ({
|
||||
(item) => item.target === node.nodeId
|
||||
);
|
||||
|
||||
// Entry
|
||||
if (workflowEdges.length === 0) {
|
||||
return 'run';
|
||||
}
|
||||
|
||||