Compare commits
68 Commits
v4.8.8-alp
...
4.8.9-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
5
.github/workflows/helm-release.yaml
vendored
@@ -24,11 +24,6 @@ jobs:
|
|||||||
export APP_VERSION=${{ steps.vars.outputs.tag }}
|
export APP_VERSION=${{ steps.vars.outputs.tag }}
|
||||||
export HELM_VERSION=${{ steps.vars.outputs.tag }}
|
export HELM_VERSION=${{ steps.vars.outputs.tag }}
|
||||||
export HELM_REPO=ghcr.io/${{ github.repository_owner }}
|
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 dependency update files/helm/fastgpt
|
||||||
helm package files/helm/fastgpt --version ${HELM_VERSION}-helm --app-version ${APP_VERSION} -d bin
|
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}
|
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:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-fastgpt-images:
|
preview-fastgpt-images:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ dist
|
|||||||
node_modules
|
node_modules
|
||||||
docSite/
|
docSite/
|
||||||
*.md
|
*.md
|
||||||
|
|
||||||
|
cl100l_base.ts
|
||||||
46
.vscode/i18n-ally-custom-framework.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# .vscode/i18n-ally-custom-framework.yml
|
||||||
|
|
||||||
|
# An array of strings which contain Language Ids defined by VS Code
|
||||||
|
# You can check available language ids here: https://code.visualstudio.com/docs/languages/identifiers
|
||||||
|
languageIds:
|
||||||
|
- javascript
|
||||||
|
- typescript
|
||||||
|
- javascriptreact
|
||||||
|
- typescriptreact
|
||||||
|
|
||||||
|
# An array of RegExes to find the key usage. **The key should be captured in the first match group**.
|
||||||
|
# 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
|
||||||
|
usageMatchRegex:
|
||||||
|
# The following example shows how to detect `t("your.i18n.keys")`
|
||||||
|
# the `{key}` will be placed by a proper keypath matching regex,
|
||||||
|
# you can ignore it and use your own matching rules as well
|
||||||
|
- "[^\\w\\d]t\\(['\"`]({key})['\"`]"
|
||||||
|
- "[^\\w\\d]commonT\\(['\"`]({key})['\"`]"
|
||||||
|
# 支持 appT("your.i18n.keys")
|
||||||
|
- "[^\\w\\d]appT\\(['\"`]({key})['\"`]"
|
||||||
|
# 支持 datasetT("your.i18n.keys")
|
||||||
|
- "[^\\w\\d]datasetT\\(['\"`]({key})['\"`]"
|
||||||
|
- "[^\\w\\d]fileT\\(['\"`]({key})['\"`]"
|
||||||
|
- "[^\\w\\d]publishT\\(['\"`]({key})['\"`]"
|
||||||
|
- "[^\\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: "([^:]+):"
|
||||||
|
|
||||||
|
# An array of strings containing refactor templates.
|
||||||
|
# The "$1" will be replaced by the keypath specified.
|
||||||
|
# Optional: uncomment the following two lines to use
|
||||||
|
|
||||||
|
# refactorTemplates:
|
||||||
|
# - i18n.get("$1")
|
||||||
|
|
||||||
|
# If set to true, only enables this custom framework (will disable all built-in frameworks)
|
||||||
|
monopoly: false
|
||||||
6
.vscode/settings.json
vendored
@@ -20,5 +20,9 @@
|
|||||||
"i18n-ally.displayLanguage": "zh", // 显示语言
|
"i18n-ally.displayLanguage": "zh", // 显示语言
|
||||||
"i18n-ally.namespace": true,
|
"i18n-ally.namespace": true,
|
||||||
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
|
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
|
||||||
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key"
|
"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/)
|
由于需要部署数据库,部署完后需要等待 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)
|
* [部署 FastGPT](https://doc.fastgpt.in/docs/development/sealos)
|
||||||
* [系统配置文件说明](https://doc.fastgpt.in/docs/development/configuration/)
|
* [系统配置文件说明](https://doc.fastgpt.in/docs/development/configuration/)
|
||||||
* [多模型配置](https://doc.fastgpt.in/docs/development/one-api/)
|
* [多模型配置](https://doc.fastgpt.in/docs/development/one-api/)
|
||||||
@@ -122,7 +122,7 @@ https://github.com/labring/FastGPT/assets/15308462/7d3a38df-eb0e-4388-9250-2409b
|
|||||||
|
|
||||||
扫码加入飞书话题群 (新开,逐渐弃用微信群):
|
扫码加入飞书话题群 (新开,逐渐弃用微信群):
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<a href="#readme">
|
<a href="#readme">
|
||||||
<img src="https://img.shields.io/badge/-返回顶部-7d09f1.svg" alt="#" align="right">
|
<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
|
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
|
## 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 cmd: Build image with proxy
|
||||||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 proxy=taobao
|
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 |
@@ -4,7 +4,7 @@ description: "FastGPT 对话问题引导"
|
|||||||
icon: "code"
|
icon: "code"
|
||||||
draft: false
|
draft: false
|
||||||
toc: true
|
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
|
||||||
|
|
||||||
修改 FastGPT 的 `config.json` 配置文件,其中 chatModels(对话模型)用于聊天对话,cqModels(问题分类模型)用来对问题进行分类,extractModels(内容提取模型)则用来进行工具选择。我们分别在 chatModels、cqModels 和 extractModels 中加入 qwen-chat 模型:
|
修改 FastGPT 的 `config.json` 配置文件的 llmModels 部分加入 qwen-chat 模型:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
...
|
||||||
"chatModels": [
|
"llmModels": [
|
||||||
...
|
|
||||||
{
|
{
|
||||||
"model": "qwen-chat",
|
"model": "qwen-chat", // 模型名(对应OneAPI中渠道的模型名)
|
||||||
"name": "Qwen",
|
"name": "Qwen", // 模型别名
|
||||||
"maxContext": 2048,
|
"avatar": "/imgs/model/Qwen.svg", // 模型的logo
|
||||||
"maxResponse": 2048,
|
"maxContext": 125000, // 最大上下文
|
||||||
"quoteMaxToken": 2000,
|
"maxResponse": 4000, // 最大回复
|
||||||
"maxTemperature": 1,
|
"quoteMaxToken": 120000, // 最大引用内容
|
||||||
"vision": false,
|
"maxTemperature": 1.2, // 最大温度
|
||||||
"defaultSystemChatPrompt": ""
|
"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 模型进行对话:
|
然后重启 FastGPT 就可以在应用配置中选择 Qwen 模型进行对话:
|
||||||
|
|||||||
@@ -531,6 +531,8 @@ data 为集合的 ID。
|
|||||||
{{< tab tabName="请求示例" >}}
|
{{< tab tabName="请求示例" >}}
|
||||||
{{< markdownify >}}
|
{{< markdownify >}}
|
||||||
|
|
||||||
|
使用代码上传时,请注意中文 filename 需要进行 encode 处理,否则容易乱码。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl --location --request POST 'http://localhost:3000/api/core/dataset/collection/create/localFile' \
|
curl --location --request POST 'http://localhost:3000/api/core/dataset/collection/create/localFile' \
|
||||||
--header 'Authorization: Bearer {{authorization}}' \
|
--header 'Authorization: Bearer {{authorization}}' \
|
||||||
@@ -1173,7 +1175,7 @@ curl --location --request PUT 'http://localhost:3000/api/core/dataset/data/updat
|
|||||||
--header 'Authorization: Bearer {{authorization}}' \
|
--header 'Authorization: Bearer {{authorization}}' \
|
||||||
--header 'Content-Type: application/json' \
|
--header 'Content-Type: application/json' \
|
||||||
--data-raw '{
|
--data-raw '{
|
||||||
"id":"65abd4b29d1448617cba61db",
|
"dataId":"65abd4b29d1448617cba61db",
|
||||||
"q":"测试111",
|
"q":"测试111",
|
||||||
"a":"sss",
|
"a":"sss",
|
||||||
"indexes":[
|
"indexes":[
|
||||||
@@ -1196,7 +1198,7 @@ curl --location --request PUT 'http://localhost:3000/api/core/dataset/data/updat
|
|||||||
{{< markdownify >}}
|
{{< markdownify >}}
|
||||||
|
|
||||||
{{% alert icon=" " context="success" %}}
|
{{% alert icon=" " context="success" %}}
|
||||||
- id: 数据的id
|
- dataId: 数据的id
|
||||||
- q: 主要数据(选填)
|
- q: 主要数据(选填)
|
||||||
- a: 辅助数据(选填)
|
- a: 辅助数据(选填)
|
||||||
- indexes: 自定义索引(选填),类型参考`为集合批量添加添加数据`。如果创建时候有自定义索引,
|
- indexes: 自定义索引(选填),类型参考`为集合批量添加添加数据`。如果创建时候有自定义索引,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ weight: 822
|
|||||||
## Sealos 升级说明
|
## Sealos 升级说明
|
||||||
|
|
||||||
1. 在应用管理中新建一个应用,镜像为:registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.1
|
1. 在应用管理中新建一个应用,镜像为:registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sandbox:v4.8.1
|
||||||
2. 无需外网访问地址
|
2. 无需外网访问地址,端口号为3000
|
||||||
3. 部署完后,复制应用的内网地址
|
3. 部署完后,复制应用的内网地址
|
||||||
4. 点击变更`FastGPT - 修改环境变量,增加下面的环境变量即可
|
4. 点击变更`FastGPT - 修改环境变量,增加下面的环境变量即可
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: 'V4.8.8(进行中)'
|
title: 'V4.8.8(需要初始化)'
|
||||||
description: 'FastGPT V4.8.8 更新说明'
|
description: 'FastGPT V4.8.8 更新说明'
|
||||||
icon: 'upgrade'
|
icon: 'upgrade'
|
||||||
draft: false
|
draft: false
|
||||||
@@ -13,13 +13,39 @@ weight: 816
|
|||||||
|
|
||||||
### 2. 修改镜像
|
### 2. 修改镜像
|
||||||
|
|
||||||
- fastgpt 镜像 tag 修改成 v4.8.8-alpha
|
- fastgpt 镜像 tag 修改成 v4.8.8-fix2
|
||||||
- 商业版镜像 tag 修改成 v4.8.8-alpha
|
- 商业版镜像 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 更新说明
|
## V4.8.8 更新说明
|
||||||
|
|
||||||
1. 新增 - 重构系统插件的结构。允许向开源社区 PR 系统插件,具体可见: [如何向 FastGPT 社区提交系统插件](https://fael3z0zfze.feishu.cn/wiki/ERZnw9R26iRRG0kXZRec6WL9nwh)。欢迎
|
[点击查看完整更新](https://github.com/labring/FastGPT/releases/tag/v4.8.8)
|
||||||
|
|
||||||
|
1. 新增 - 重构系统插件的结构。允许向开源社区 PR 系统插件,具体可见: [如何向 FastGPT 社区提交系统插件](https://fael3z0zfze.feishu.cn/wiki/ERZnw9R26iRRG0kXZRec6WL9nwh)。
|
||||||
2. 新增 - DuckDuckGo 系统插件。
|
2. 新增 - DuckDuckGo 系统插件。
|
||||||
3. 优化 - 节点图标。
|
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'
|
icon: 'image'
|
||||||
draft: false
|
draft: false
|
||||||
toc: true
|
toc: true
|
||||||
weight: 404
|
weight: 408
|
||||||
---
|
---
|
||||||
|
|
||||||
| | |
|
| | |
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ description: '利用工具调用模块,发送一个飞书webhook通知'
|
|||||||
icon: 'image'
|
icon: 'image'
|
||||||
draft: false
|
draft: false
|
||||||
toc: true
|
toc: true
|
||||||
weight: 404
|
weight: 409
|
||||||
---
|
---
|
||||||
|
|
||||||
该文章展示如何发送一个简单的飞书webhook通知,以此类推,发送其他类型的通知也可以这么操作。
|
该文章展示如何发送一个简单的飞书webhook通知,以此类推,发送其他类型的通知也可以这么操作。
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ description: '利用指定回复,创建固定的开头和结尾'
|
|||||||
icon: 'healing'
|
icon: 'healing'
|
||||||
draft: false
|
draft: false
|
||||||
toc: true
|
toc: true
|
||||||
weight: 401
|
weight: 405
|
||||||
---
|
---
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -4,7 +4,7 @@ description: '将 FastGPT 接入谷歌搜索'
|
|||||||
icon: 'search'
|
icon: 'search'
|
||||||
draft: false
|
draft: false
|
||||||
toc: true
|
toc: true
|
||||||
weight: 402
|
weight: 406
|
||||||
---
|
---
|
||||||
|
|
||||||
| | |
|
| | |
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ description: '展示高级编排操作数据库的能力'
|
|||||||
icon: 'database'
|
icon: 'database'
|
||||||
draft: false
|
draft: false
|
||||||
toc: true
|
toc: true
|
||||||
weight: 403
|
weight: 407
|
||||||
---
|
---
|
||||||
|
|
||||||
| | |
|
| | |
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
fastgpt:
|
fastgpt:
|
||||||
container_name: fastgpt
|
container_name: fastgpt
|
||||||
image: ghcr.io/labring/fastgpt:v4.8.7 # git
|
image: ghcr.io/labring/fastgpt:v4.8.8-fix2 # git
|
||||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.7 # 阿里云
|
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.8-fix2 # 阿里云
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
networks:
|
networks:
|
||||||
@@ -179,7 +179,7 @@ services:
|
|||||||
- ./mysql:/var/lib/mysql
|
- ./mysql:/var/lib/mysql
|
||||||
oneapi:
|
oneapi:
|
||||||
container_name: 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 # 阿里云
|
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6 # 阿里云
|
||||||
ports:
|
ports:
|
||||||
- 3001:3000
|
- 3001:3000
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
fastgpt:
|
fastgpt:
|
||||||
container_name: fastgpt
|
container_name: fastgpt
|
||||||
image: ghcr.io/labring/fastgpt:v4.8.7 # git
|
image: ghcr.io/labring/fastgpt:v4.8.8-fix2 # git
|
||||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.7 # 阿里云
|
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.8-fix2 # 阿里云
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
networks:
|
networks:
|
||||||
@@ -136,7 +136,7 @@ services:
|
|||||||
- ./mysql:/var/lib/mysql
|
- ./mysql:/var/lib/mysql
|
||||||
oneapi:
|
oneapi:
|
||||||
container_name: 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 # 阿里云
|
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6 # 阿里云
|
||||||
ports:
|
ports:
|
||||||
- 3001:3000
|
- 3001:3000
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
fastgpt:
|
fastgpt:
|
||||||
container_name: fastgpt
|
container_name: fastgpt
|
||||||
image: ghcr.io/labring/fastgpt:v4.8.7 # git
|
image: ghcr.io/labring/fastgpt:v4.8.8-fix2 # git
|
||||||
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.7 # 阿里云
|
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.8-fix2 # 阿里云
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
networks:
|
networks:
|
||||||
@@ -117,7 +117,7 @@ services:
|
|||||||
- ./mysql:/var/lib/mysql
|
- ./mysql:/var/lib/mysql
|
||||||
oneapi:
|
oneapi:
|
||||||
container_name: 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 # 阿里云
|
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6 # 阿里云
|
||||||
ports:
|
ports:
|
||||||
- 3001:3000
|
- 3001:3000
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"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",
|
"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",
|
"postinstall": "sh ./scripts/postinstall.sh",
|
||||||
"initIcon": "node ./scripts/icon/init.js",
|
"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": {
|
"devDependencies": {
|
||||||
"@chakra-ui/cli": "^2.4.1",
|
"@chakra-ui/cli": "^2.4.1",
|
||||||
|
|||||||
@@ -1,18 +1,28 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* dataset: 502000 */
|
/* dataset: 502000 */
|
||||||
export enum AppErrEnum {
|
export enum AppErrEnum {
|
||||||
unExist = 'appUnExist',
|
unExist = 'appUnExist',
|
||||||
unAuthApp = 'unAuthApp'
|
unAuthApp = 'unAuthApp',
|
||||||
|
invalidOwner = 'invalidOwner',
|
||||||
|
invalidAppType = 'invalidAppType'
|
||||||
}
|
}
|
||||||
const appErrList = [
|
const appErrList = [
|
||||||
{
|
{
|
||||||
statusText: AppErrEnum.unExist,
|
statusText: AppErrEnum.unExist,
|
||||||
message: '应用不存在'
|
message: i18nT('common:code_error.app_error.not_exist')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
statusText: AppErrEnum.unAuthApp,
|
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) => {
|
export default appErrList.reduce((acc, cur, index) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* dataset: 504000 */
|
/* dataset: 504000 */
|
||||||
export enum ChatErrEnum {
|
export enum ChatErrEnum {
|
||||||
unAuthChat = 'unAuthChat'
|
unAuthChat = 'unAuthChat'
|
||||||
@@ -7,7 +7,7 @@ export enum ChatErrEnum {
|
|||||||
const errList = [
|
const errList = [
|
||||||
{
|
{
|
||||||
statusText: ChatErrEnum.unAuthChat,
|
statusText: ChatErrEnum.unAuthChat,
|
||||||
message: '无权操作该对话记录'
|
message: i18nT('common:code_error.chat_error.un_auth')
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
export default errList.reduce((acc, cur, index) => {
|
export default errList.reduce((acc, cur, index) => {
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ export enum DatasetErrEnum {
|
|||||||
unAuthDatasetCollection = 'unAuthDatasetCollection',
|
unAuthDatasetCollection = 'unAuthDatasetCollection',
|
||||||
unAuthDatasetData = 'unAuthDatasetData',
|
unAuthDatasetData = 'unAuthDatasetData',
|
||||||
unAuthDatasetFile = 'unAuthDatasetFile',
|
unAuthDatasetFile = 'unAuthDatasetFile',
|
||||||
|
unLinkCollection = 'unLinkCollection',
|
||||||
unLinkCollection = 'unLinkCollection'
|
invalidVectorModelOrQAModel = 'invalidVectorModelOrQAModel'
|
||||||
}
|
}
|
||||||
const datasetErr = [
|
const datasetErr = [
|
||||||
{
|
{
|
||||||
@@ -39,6 +39,10 @@ const datasetErr = [
|
|||||||
{
|
{
|
||||||
statusText: DatasetErrEnum.unLinkCollection,
|
statusText: DatasetErrEnum.unLinkCollection,
|
||||||
message: 'core.dataset.error.unLinkCollection'
|
message: 'core.dataset.error.unLinkCollection'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
statusText: DatasetErrEnum.invalidVectorModelOrQAModel,
|
||||||
|
message: 'core.dataset.error.invalidVectorModelOrQAModel'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
export default datasetErr.reduce((acc, cur, index) => {
|
export default datasetErr.reduce((acc, cur, index) => {
|
||||||
|
|||||||
@@ -1,20 +1,27 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* dataset: 506000 */
|
/* dataset: 506000 */
|
||||||
export enum OpenApiErrEnum {
|
export enum OpenApiErrEnum {
|
||||||
unExist = 'openapiUnExist',
|
unExist = 'openapiUnExist',
|
||||||
unAuth = 'openapiUnAuth'
|
unAuth = 'openapiUnAuth',
|
||||||
|
exceedLimit = 'openapiExceedLimit'
|
||||||
}
|
}
|
||||||
|
|
||||||
const errList = [
|
const errList = [
|
||||||
{
|
{
|
||||||
statusText: OpenApiErrEnum.unExist,
|
statusText: OpenApiErrEnum.unExist,
|
||||||
message: 'Api Key 不存在'
|
message: i18nT('common:code_error.openapi_error.api_key_not_exist')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
statusText: OpenApiErrEnum.unAuth,
|
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) => {
|
export default errList.reduce((acc, cur, index) => {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
|
|||||||
@@ -1,32 +1,33 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* dataset: 505000 */
|
/* dataset: 505000 */
|
||||||
export enum OutLinkErrEnum {
|
export enum OutLinkErrEnum {
|
||||||
unExist = 'outlinkUnExist',
|
unExist = 'outlinkUnExist',
|
||||||
unAuthLink = 'unAuthLink',
|
unAuthLink = 'unAuthLink',
|
||||||
linkUnInvalid = 'linkUnInvalid',
|
linkUnInvalid = 'linkUnInvalid',
|
||||||
|
|
||||||
unAuthUser = 'unAuthUser'
|
unAuthUser = 'unAuthUser'
|
||||||
}
|
}
|
||||||
|
|
||||||
const errList = [
|
const errList = [
|
||||||
{
|
{
|
||||||
statusText: OutLinkErrEnum.unExist,
|
statusText: OutLinkErrEnum.unExist,
|
||||||
message: '分享链接不存在'
|
message: i18nT('common:code_error.outlink_error.link_not_exist')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
statusText: OutLinkErrEnum.unAuthLink,
|
statusText: OutLinkErrEnum.unAuthLink,
|
||||||
message: '分享链接无效'
|
message: i18nT('common:code_error.outlink_error.invalid_link')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
code: 501,
|
code: 501,
|
||||||
statusText: OutLinkErrEnum.linkUnInvalid,
|
statusText: OutLinkErrEnum.linkUnInvalid,
|
||||||
message: '分享链接无效'
|
message: i18nT('common:code_error.outlink_error.invalid_link') // 使用相同的错误消息
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
statusText: OutLinkErrEnum.unAuthUser,
|
statusText: OutLinkErrEnum.unAuthUser,
|
||||||
message: '身份校验失败'
|
message: i18nT('common:code_error.outlink_error.un_auth_user')
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export default errList.reduce((acc, cur, index) => {
|
export default errList.reduce((acc, cur, index) => {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* dataset: 508000 */
|
/* dataset: 508000 */
|
||||||
export enum PluginErrEnum {
|
export enum PluginErrEnum {
|
||||||
unExist = 'pluginUnExist',
|
unExist = 'pluginUnExist',
|
||||||
unAuth = 'pluginUnAuth'
|
unAuth = 'pluginUnAuth'
|
||||||
}
|
}
|
||||||
|
|
||||||
const errList = [
|
const errList = [
|
||||||
{
|
{
|
||||||
statusText: PluginErrEnum.unExist,
|
statusText: PluginErrEnum.unExist,
|
||||||
message: '插件不存在'
|
message: i18nT('common:code_error.plugin_error.not_exist')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
statusText: PluginErrEnum.unAuth,
|
statusText: PluginErrEnum.unAuth,
|
||||||
message: '无权操作该插件'
|
message: i18nT('common:code_error.plugin_error.un_auth')
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export default errList.reduce((acc, cur, index) => {
|
export default errList.reduce((acc, cur, index) => {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* dataset: 509000 */
|
/* dataset: 509000 */
|
||||||
export enum SystemErrEnum {
|
export enum SystemErrEnum {
|
||||||
communityVersionNumLimit = 'communityVersionNumLimit'
|
communityVersionNumLimit = 'communityVersionNumLimit'
|
||||||
}
|
}
|
||||||
|
|
||||||
const systemErr = [
|
const systemErr = [
|
||||||
{
|
{
|
||||||
statusText: SystemErrEnum.communityVersionNumLimit,
|
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) => {
|
export default systemErr.reduce((acc, cur, index) => {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* team: 500000 */
|
/* team: 500000 */
|
||||||
export enum TeamErrEnum {
|
export enum TeamErrEnum {
|
||||||
teamOverSize = 'teamOverSize',
|
teamOverSize = 'teamOverSize',
|
||||||
@@ -12,17 +12,43 @@ export enum TeamErrEnum {
|
|||||||
websiteSyncNotEnough = 'websiteSyncNotEnough',
|
websiteSyncNotEnough = 'websiteSyncNotEnough',
|
||||||
reRankNotEnough = 'reRankNotEnough'
|
reRankNotEnough = 'reRankNotEnough'
|
||||||
}
|
}
|
||||||
|
|
||||||
const teamErr = [
|
const teamErr = [
|
||||||
{ statusText: TeamErrEnum.teamOverSize, message: 'error.team.overSize' },
|
{
|
||||||
{ statusText: TeamErrEnum.unAuthTeam, message: '无权操作该团队' },
|
statusText: TeamErrEnum.teamOverSize,
|
||||||
{ statusText: TeamErrEnum.aiPointsNotEnough, message: '' },
|
message: i18nT('common:code_error.team_error.over_size')
|
||||||
{ statusText: TeamErrEnum.datasetSizeNotEnough, message: '知识库容量不足,请先扩容~' },
|
},
|
||||||
{ statusText: TeamErrEnum.datasetAmountNotEnough, message: '知识库数量已达上限~' },
|
{ statusText: TeamErrEnum.unAuthTeam, message: i18nT('common:code_error.team_error.un_auth') },
|
||||||
{ statusText: TeamErrEnum.appAmountNotEnough, message: '应用数量已达上限~' },
|
{
|
||||||
{ statusText: TeamErrEnum.pluginAmountNotEnough, message: '插件数量已达上限~' },
|
statusText: TeamErrEnum.aiPointsNotEnough,
|
||||||
{ statusText: TeamErrEnum.websiteSyncNotEnough, message: '无权使用Web站点同步~' },
|
message: i18nT('common:code_error.team_error.ai_points_not_enough')
|
||||||
{ statusText: TeamErrEnum.reRankNotEnough, message: '无权使用检索重排~' }
|
}, // 需要定义或留空
|
||||||
|
{
|
||||||
|
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) => {
|
export default teamErr.reduce((acc, cur, index) => {
|
||||||
return {
|
return {
|
||||||
...acc,
|
...acc,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ErrType } from '../errorCode';
|
import { ErrType } from '../errorCode';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
/* team: 503000 */
|
/* team: 503000 */
|
||||||
export enum UserErrEnum {
|
export enum UserErrEnum {
|
||||||
unAuthUser = 'unAuthUser',
|
unAuthUser = 'unAuthUser',
|
||||||
@@ -8,10 +8,22 @@ export enum UserErrEnum {
|
|||||||
balanceNotEnough = 'balanceNotEnough'
|
balanceNotEnough = 'balanceNotEnough'
|
||||||
}
|
}
|
||||||
const errList = [
|
const errList = [
|
||||||
{ statusText: UserErrEnum.unAuthUser, message: '找不到该用户' },
|
{
|
||||||
{ statusText: UserErrEnum.binVisitor, message: '您的身份校验未通过' },
|
statusText: UserErrEnum.unAuthUser,
|
||||||
{ statusText: UserErrEnum.binVisitor, message: '您当前身份为游客,无权操作' },
|
message: i18nT('common:code_error.user_error.un_auth_user')
|
||||||
{ statusText: UserErrEnum.balanceNotEnough, message: '账号余额不足~' }
|
},
|
||||||
|
{
|
||||||
|
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) => {
|
export default errList.reduce((acc, cur, index) => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -8,24 +8,25 @@ import teamErr from './code/team';
|
|||||||
import userErr from './code/user';
|
import userErr from './code/user';
|
||||||
import commonErr from './code/common';
|
import commonErr from './code/common';
|
||||||
import SystemErrEnum from './code/system';
|
import SystemErrEnum from './code/system';
|
||||||
|
import { i18nT } from '../../../web/i18n/utils';
|
||||||
|
|
||||||
export const ERROR_CODE: { [key: number]: string } = {
|
export const ERROR_CODE: { [key: number]: string } = {
|
||||||
400: '请求失败',
|
400: i18nT('common:code_error.error_code.400'),
|
||||||
401: '无权访问',
|
401: i18nT('common:code_error.error_code.401'),
|
||||||
403: '紧张访问',
|
403: i18nT('common:code_error.error_code.403'),
|
||||||
404: '请求不存在',
|
404: i18nT('common:code_error.error_code.404'),
|
||||||
405: '请求方法错误',
|
405: i18nT('common:code_error.error_code.405'),
|
||||||
406: '请求的格式错误',
|
406: i18nT('common:code_error.error_code.406'),
|
||||||
410: '资源已删除',
|
410: i18nT('common:code_error.error_code.410'),
|
||||||
422: '验证错误',
|
422: i18nT('common:code_error.error_code.422'),
|
||||||
500: '服务器发生错误',
|
500: i18nT('common:code_error.error_code.500'),
|
||||||
502: '网关错误',
|
502: i18nT('common:code_error.error_code.502'),
|
||||||
503: '服务器暂时过载或维护',
|
503: i18nT('common:code_error.error_code.503'),
|
||||||
504: '网关超时'
|
504: i18nT('common:code_error.error_code.504')
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TOKEN_ERROR_CODE: Record<number, string> = {
|
export const TOKEN_ERROR_CODE: Record<number, string> = {
|
||||||
403: '登录状态无效,请重新登录'
|
403: i18nT('common:code_error.token_error_code.403')
|
||||||
};
|
};
|
||||||
|
|
||||||
export const proxyError: Record<string, boolean> = {
|
export const proxyError: Record<string, boolean> = {
|
||||||
@@ -63,32 +64,31 @@ export const ERROR_RESPONSE: Record<
|
|||||||
[ERROR_ENUM.unAuthorization]: {
|
[ERROR_ENUM.unAuthorization]: {
|
||||||
code: 403,
|
code: 403,
|
||||||
statusText: ERROR_ENUM.unAuthorization,
|
statusText: ERROR_ENUM.unAuthorization,
|
||||||
message: '凭证错误',
|
message: i18nT('common:code_error.error_message.403'),
|
||||||
data: null
|
data: null
|
||||||
},
|
},
|
||||||
[ERROR_ENUM.insufficientQuota]: {
|
[ERROR_ENUM.insufficientQuota]: {
|
||||||
code: 510,
|
code: 510,
|
||||||
statusText: ERROR_ENUM.insufficientQuota,
|
statusText: ERROR_ENUM.insufficientQuota,
|
||||||
message: '账号余额不足',
|
message: i18nT('common:code_error.error_message.510'),
|
||||||
data: null
|
data: null
|
||||||
},
|
},
|
||||||
[ERROR_ENUM.unAuthModel]: {
|
[ERROR_ENUM.unAuthModel]: {
|
||||||
code: 511,
|
code: 511,
|
||||||
statusText: ERROR_ENUM.unAuthModel,
|
statusText: ERROR_ENUM.unAuthModel,
|
||||||
message: '无权操作该模型',
|
message: i18nT('common:code_error.error_message.511'),
|
||||||
data: null
|
data: null
|
||||||
},
|
},
|
||||||
|
|
||||||
[ERROR_ENUM.unAuthFile]: {
|
[ERROR_ENUM.unAuthFile]: {
|
||||||
code: 513,
|
code: 513,
|
||||||
statusText: ERROR_ENUM.unAuthFile,
|
statusText: ERROR_ENUM.unAuthFile,
|
||||||
message: '无权阅读该文件',
|
message: i18nT('common:code_error.error_message.513'),
|
||||||
data: null
|
data: null
|
||||||
},
|
},
|
||||||
[ERROR_ENUM.unAuthApiKey]: {
|
[ERROR_ENUM.unAuthApiKey]: {
|
||||||
code: 514,
|
code: 514,
|
||||||
statusText: ERROR_ENUM.unAuthApiKey,
|
statusText: ERROR_ENUM.unAuthApiKey,
|
||||||
message: 'Api Key 不合法',
|
message: i18nT('common:code_error.error_message.514'),
|
||||||
data: null
|
data: null
|
||||||
},
|
},
|
||||||
...appErr,
|
...appErr,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { replaceSensitiveText } from '../string/tools';
|
import { replaceSensitiveText } from '../string/tools';
|
||||||
|
|
||||||
export const getErrText = (err: any, def = '') => {
|
export const getErrText = (err: any, def = ''): any => {
|
||||||
const msg: string =
|
const msg: string =
|
||||||
typeof err === 'string'
|
typeof err === 'string'
|
||||||
? err
|
? err
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
|
import { i18nT } from '../../../web/i18n/utils';
|
||||||
|
|
||||||
/* mongo fs bucket */
|
/* mongo fs bucket */
|
||||||
export enum BucketNameEnum {
|
export enum BucketNameEnum {
|
||||||
dataset = 'dataset'
|
dataset = 'dataset',
|
||||||
|
chat = 'chat'
|
||||||
}
|
}
|
||||||
export const bucketNameMap = {
|
export const bucketNameMap = {
|
||||||
[BucketNameEnum.dataset]: {
|
[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 ReadFileBaseUrl = '/api/common/file/read';
|
||||||
|
|
||||||
|
export const documentFileType = '.txt, .docx, .csv, .xlsx, .pdf, .md, .html, .pptx';
|
||||||
|
|||||||
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 isMarkdownSplit = checkIsMarkdownSplit(step);
|
||||||
const independentChunk = checkIndependentChunk(step);
|
const independentChunk = checkIndependentChunk(step);
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ const commonSplit = (props: SplitProps): SplitResponse => {
|
|||||||
.replace(
|
.replace(
|
||||||
reg,
|
reg,
|
||||||
(() => {
|
(() => {
|
||||||
if (isCustomSteep) return splitMarker;
|
if (isCustomStep) return splitMarker;
|
||||||
if (independentChunk) return `${splitMarker}$1`;
|
if (independentChunk) return `${splitMarker}$1`;
|
||||||
return `$1${splitMarker}`;
|
return `$1${splitMarker}`;
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import cronParser from 'cron-parser';
|
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 formatTime2YMDHMW = (time?: Date) => dayjs(time).format('YYYY-MM-DD HH:mm:ss dddd');
|
||||||
export const formatTime2YMDHM = (time?: Date) =>
|
export const formatTime2YMDHM = (time?: Date) =>
|
||||||
|
|||||||
@@ -91,3 +91,10 @@ export const sliceJsonStr = (str: string) => {
|
|||||||
|
|
||||||
return jsonStr;
|
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;
|
||||||
|
};
|
||||||
|
|||||||
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];
|
||||||
@@ -119,3 +119,10 @@ export const Prompt_QuotePromptList: PromptTemplateItem[] = [
|
|||||||
问题:"""{{question}}"""`
|
问题:"""{{question}}"""`
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Document quote prompt
|
||||||
|
export const Prompt_DocumentQuote = `将 <Quote></Quote> 中的内容作为你的知识:
|
||||||
|
<Quote>
|
||||||
|
{{quote}}
|
||||||
|
</Quote>
|
||||||
|
`;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
export const Prompt_AgentQA = {
|
export const Prompt_AgentQA = {
|
||||||
description: `<Context></Context> 标记中是一段文本,学习和分析它,并整理学习成果:
|
description: `<Context></Context> 标记中是一段文本,学习和分析它,并整理学习成果:
|
||||||
- 提出问题并给出每个问题的答案。
|
- 提出问题并给出每个问题的答案。
|
||||||
- 答案需详细完整,尽可能保留原文描述。
|
- 答案需详细完整,尽可能保留原文描述,可以适当扩展答案描述。
|
||||||
- 答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 Markdown 元素。
|
- 答案可以包含普通文字、链接、代码、表格、公示、媒体链接等 Markdown 元素。
|
||||||
- 最多提出 30 个问题。
|
- 最多提出 50 个问题。
|
||||||
`,
|
`,
|
||||||
fixedText: `请按以下格式整理学习成果:
|
fixedText: `请按以下格式整理学习成果:
|
||||||
<Context>
|
<Context>
|
||||||
|
|||||||
40
packages/global/core/ai/type.d.ts
vendored
@@ -2,23 +2,46 @@ import openai from 'openai';
|
|||||||
import type {
|
import type {
|
||||||
ChatCompletionMessageToolCall,
|
ChatCompletionMessageToolCall,
|
||||||
ChatCompletionChunk,
|
ChatCompletionChunk,
|
||||||
ChatCompletionMessageParam,
|
ChatCompletionMessageParam as SdkChatCompletionMessageParam,
|
||||||
ChatCompletionToolMessageParam,
|
ChatCompletionToolMessageParam,
|
||||||
ChatCompletionAssistantMessageParam
|
ChatCompletionAssistantMessageParam,
|
||||||
|
ChatCompletionContentPart as SdkChatCompletionContentPart,
|
||||||
|
ChatCompletionUserMessageParam as SdkChatCompletionUserMessageParam
|
||||||
} from 'openai/resources';
|
} from 'openai/resources';
|
||||||
import { ChatMessageTypeEnum } from './constants';
|
import { ChatMessageTypeEnum } from './constants';
|
||||||
|
|
||||||
export * from 'openai/resources';
|
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;
|
dataId?: string;
|
||||||
};
|
};
|
||||||
|
export type SdkChatCompletionMessageParam = SdkChatCompletionMessageParam;
|
||||||
|
|
||||||
|
/* ToolChoice and functionCall extension */
|
||||||
export type ChatCompletionToolMessageParam = ChatCompletionToolMessageParam & { name: string };
|
export type ChatCompletionToolMessageParam = ChatCompletionToolMessageParam & { name: string };
|
||||||
export type ChatCompletionAssistantToolParam = {
|
export type ChatCompletionAssistantToolParam = {
|
||||||
role: 'assistant';
|
role: 'assistant';
|
||||||
tool_calls: ChatCompletionMessageToolCall[];
|
tool_calls: ChatCompletionMessageToolCall[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ChatCompletionMessageToolCall = ChatCompletionMessageToolCall & {
|
export type ChatCompletionMessageToolCall = ChatCompletionMessageToolCall & {
|
||||||
toolName?: string;
|
toolName?: string;
|
||||||
toolAvatar?: string;
|
toolAvatar?: string;
|
||||||
@@ -28,13 +51,16 @@ export type ChatCompletionMessageFunctionCall = ChatCompletionAssistantMessagePa
|
|||||||
toolName?: string;
|
toolName?: string;
|
||||||
toolAvatar?: string;
|
toolAvatar?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Stream response
|
||||||
export type StreamChatType = Stream<ChatCompletionChunk>;
|
export type StreamChatType = Stream<ChatCompletionChunk>;
|
||||||
|
|
||||||
|
export default openai;
|
||||||
|
export * from 'openai';
|
||||||
|
|
||||||
|
// Other
|
||||||
export type PromptTemplateItem = {
|
export type PromptTemplateItem = {
|
||||||
title: string;
|
title: string;
|
||||||
desc: string;
|
desc: string;
|
||||||
value: 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 {
|
export enum AppTypeEnum {
|
||||||
folder = 'folder',
|
folder = 'folder',
|
||||||
@@ -23,3 +23,9 @@ export const defaultChatInputGuideConfig = {
|
|||||||
textList: [],
|
textList: [],
|
||||||
customUrl: ''
|
customUrl: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const defaultAppSelectFileConfig: AppFileSelectConfigType = {
|
||||||
|
canSelectFile: false,
|
||||||
|
canSelectImg: false,
|
||||||
|
maxFiles: 10
|
||||||
|
};
|
||||||
|
|||||||
@@ -5,6 +5,20 @@ import { FlowNodeTypeEnum } from '../../workflow/node/constant';
|
|||||||
export const getPluginInputsFromStoreNodes = (nodes: StoreNodeItemType[]) => {
|
export const getPluginInputsFromStoreNodes = (nodes: StoreNodeItemType[]) => {
|
||||||
return nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput)?.inputs || [];
|
return nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput)?.inputs || [];
|
||||||
};
|
};
|
||||||
export const getPluginRunContent = (e: { pluginInputs: FlowNodeInputItemType[] }) => {
|
export const getPluginRunContent = ({
|
||||||
return JSON.stringify(e);
|
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);
|
||||||
};
|
};
|
||||||
|
|||||||
10
packages/global/core/app/type.d.ts
vendored
@@ -1,7 +1,7 @@
|
|||||||
import type { FlowNodeTemplateType, StoreNodeItemType } from '../workflow/type/node';
|
import type { FlowNodeTemplateType, StoreNodeItemType } from '../workflow/type/node';
|
||||||
import { AppTypeEnum } from './constants';
|
import { AppTypeEnum } from './constants';
|
||||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||||
import { VariableInputEnum } from '../workflow/constants';
|
import { NodeInputKeyEnum, VariableInputEnum } from '../workflow/constants';
|
||||||
import { SelectedDatasetType } from '../workflow/api';
|
import { SelectedDatasetType } from '../workflow/api';
|
||||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||||
import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d';
|
import { TeamTagSchema as TeamTagsSchemaType } from '@fastgpt/global/support/user/team/type.d';
|
||||||
@@ -91,6 +91,7 @@ export type AppChatConfigType = {
|
|||||||
whisperConfig?: AppWhisperConfigType;
|
whisperConfig?: AppWhisperConfigType;
|
||||||
scheduledTriggerConfig?: AppScheduledTriggerConfigType;
|
scheduledTriggerConfig?: AppScheduledTriggerConfigType;
|
||||||
chatInputGuide?: ChatInputGuideConfigType;
|
chatInputGuide?: ChatInputGuideConfigType;
|
||||||
|
fileSelectConfig?: AppFileSelectConfigType;
|
||||||
};
|
};
|
||||||
export type SettingAIDataType = {
|
export type SettingAIDataType = {
|
||||||
model: string;
|
model: string;
|
||||||
@@ -98,6 +99,7 @@ export type SettingAIDataType = {
|
|||||||
maxToken: number;
|
maxToken: number;
|
||||||
isResponseAnswerText?: boolean;
|
isResponseAnswerText?: boolean;
|
||||||
maxHistories?: number;
|
maxHistories?: number;
|
||||||
|
[NodeInputKeyEnum.aiChatVision]?: boolean; // Is open vision mode
|
||||||
};
|
};
|
||||||
|
|
||||||
// variable
|
// variable
|
||||||
@@ -134,3 +136,9 @@ export type AppScheduledTriggerConfigType = {
|
|||||||
timezone: string;
|
timezone: string;
|
||||||
defaultPrompt: string;
|
defaultPrompt: string;
|
||||||
};
|
};
|
||||||
|
// File
|
||||||
|
export type AppFileSelectConfigType = {
|
||||||
|
canSelectFile: boolean;
|
||||||
|
canSelectImg: boolean;
|
||||||
|
maxFiles: number;
|
||||||
|
};
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import { getAppChatConfig } from '../workflow/utils';
|
|||||||
import { StoreNodeItemType } from '../workflow/type/node';
|
import { StoreNodeItemType } from '../workflow/type/node';
|
||||||
import { DatasetSearchModeEnum } from '../dataset/constants';
|
import { DatasetSearchModeEnum } from '../dataset/constants';
|
||||||
|
|
||||||
export const getDefaultAppForm = (): AppSimpleEditFormType => ({
|
export const getDefaultAppForm = (): AppSimpleEditFormType => {
|
||||||
|
return {
|
||||||
aiSettings: {
|
aiSettings: {
|
||||||
model: 'gpt-4o-mini',
|
model: 'gpt-4o-mini',
|
||||||
systemPrompt: '',
|
systemPrompt: '',
|
||||||
@@ -21,12 +22,13 @@ export const getDefaultAppForm = (): AppSimpleEditFormType => ({
|
|||||||
limit: 1500,
|
limit: 1500,
|
||||||
searchMode: DatasetSearchModeEnum.embedding,
|
searchMode: DatasetSearchModeEnum.embedding,
|
||||||
usingReRank: false,
|
usingReRank: false,
|
||||||
datasetSearchUsingExtensionQuery: false,
|
datasetSearchUsingExtensionQuery: true,
|
||||||
datasetSearchExtensionBg: ''
|
datasetSearchExtensionBg: ''
|
||||||
},
|
},
|
||||||
selectedTools: [],
|
selectedTools: [],
|
||||||
chatConfig: {}
|
chatConfig: {}
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/* format app nodes to edit form */
|
/* format app nodes to edit form */
|
||||||
export const appWorkflow2Form = ({
|
export const appWorkflow2Form = ({
|
||||||
|
|||||||
@@ -56,16 +56,21 @@ export const chats2GPTMessages = ({
|
|||||||
text: item.text?.content || ''
|
text: item.text?.content || ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (
|
if (item.type === ChatItemValueTypeEnum.file) {
|
||||||
item.type === ChatItemValueTypeEnum.file &&
|
if (item.file?.type === ChatFileTypeEnum.image) {
|
||||||
item.file?.type === ChatFileTypeEnum.image
|
|
||||||
) {
|
|
||||||
return {
|
return {
|
||||||
type: 'image_url',
|
type: 'image_url',
|
||||||
image_url: {
|
image_url: {
|
||||||
url: item.file?.url || ''
|
url: item.file?.url || ''
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
} else if (item.file?.type === ChatFileTypeEnum.file) {
|
||||||
|
return {
|
||||||
|
type: 'file_url',
|
||||||
|
name: item.file?.name || '',
|
||||||
|
url: item.file?.url || ''
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter(Boolean) as ChatCompletionContentPart[];
|
.filter(Boolean) as ChatCompletionContentPart[];
|
||||||
@@ -175,6 +180,16 @@ export const GPTMessages2Chats = (
|
|||||||
url: item.image_url.url
|
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
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
15
packages/global/core/chat/type.d.ts
vendored
@@ -106,17 +106,26 @@ export type AdminFbkType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* --------- chat item ---------- */
|
/* --------- chat item ---------- */
|
||||||
export type ChatItemType = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
|
export type ResponseTagItemType = {
|
||||||
dataId?: string;
|
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) & {
|
export type ChatSiteItemType = (UserChatItemType | SystemChatItemType | AIChatItemType) & {
|
||||||
dataId: string;
|
dataId: string;
|
||||||
status: `${ChatStatusEnum}`;
|
status: `${ChatStatusEnum}`;
|
||||||
moduleName?: string;
|
moduleName?: string;
|
||||||
ttsBuffer?: Uint8Array;
|
ttsBuffer?: Uint8Array;
|
||||||
responseData?: ChatHistoryItemResType[];
|
responseData?: ChatHistoryItemResType[];
|
||||||
} & ChatBoxInputType;
|
} & ChatBoxInputType &
|
||||||
|
ResponseTagItemType;
|
||||||
|
|
||||||
/* --------- team chat --------- */
|
/* --------- team chat --------- */
|
||||||
export type ChatAppListSchema = {
|
export type ChatAppListSchema = {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { DispatchNodeResponseType } from '../workflow/runtime/type';
|
|||||||
import { FlowNodeTypeEnum } from '../workflow/node/constant';
|
import { FlowNodeTypeEnum } from '../workflow/node/constant';
|
||||||
import { ChatItemValueTypeEnum, ChatRoleEnum } from './constants';
|
import { ChatItemValueTypeEnum, ChatRoleEnum } from './constants';
|
||||||
import { ChatHistoryItemResType, ChatItemType, UserChatItemValueItemType } from './type.d';
|
import { ChatHistoryItemResType, ChatItemType, UserChatItemValueItemType } from './type.d';
|
||||||
|
import { sliceStrStartEnd } from '../../common/string/tools';
|
||||||
|
|
||||||
// Concat 2 -> 1, and sort by role
|
// Concat 2 -> 1, and sort by role
|
||||||
export const concatHistories = (histories1: ChatItemType[], histories2: ChatItemType[]) => {
|
export const concatHistories = (histories1: ChatItemType[], histories2: ChatItemType[]) => {
|
||||||
@@ -25,6 +26,7 @@ export const getChatTitleFromChatMessage = (message?: ChatItemType, defaultValue
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Keep the first n and last n characters
|
||||||
export const getHistoryPreview = (
|
export const getHistoryPreview = (
|
||||||
completeMessages: ChatItemType[]
|
completeMessages: ChatItemType[]
|
||||||
): {
|
): {
|
||||||
@@ -32,30 +34,44 @@ export const getHistoryPreview = (
|
|||||||
value: string;
|
value: string;
|
||||||
}[] => {
|
}[] => {
|
||||||
return completeMessages.map((item, i) => {
|
return completeMessages.map((item, i) => {
|
||||||
if (item.obj === ChatRoleEnum.System || i >= completeMessages.length - 2) {
|
const n = item.obj === ChatRoleEnum.System || i >= completeMessages.length - 2 ? 80 : 40;
|
||||||
return {
|
|
||||||
obj: item.obj,
|
|
||||||
value: item.value?.[0]?.text?.content || ''
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = item.value
|
// Get message text content
|
||||||
.map((item) => {
|
const rawText = (() => {
|
||||||
if (item.text?.content) {
|
if (item.obj === ChatRoleEnum.System) {
|
||||||
const content =
|
return item.value?.map((item) => item.text?.content).join('') || '';
|
||||||
item.text.content.length > 20
|
} else if (item.obj === ChatRoleEnum.Human) {
|
||||||
? `${item.text.content.slice(0, 20)}...`
|
return (
|
||||||
: item.text.content;
|
item.value
|
||||||
return content;
|
?.map((item) => {
|
||||||
}
|
if (item?.text?.content) return item?.text?.content;
|
||||||
|
if (item.file?.type === 'image') return 'Input an image';
|
||||||
return '';
|
return '';
|
||||||
})
|
})
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join('\n');
|
.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 {
|
return {
|
||||||
obj: item.obj,
|
obj: item.obj,
|
||||||
value: content
|
value: sliceStrStartEnd(content, 80, 80)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
18
packages/global/core/dataset/api.d.ts
vendored
@@ -10,7 +10,6 @@ export type DatasetUpdateBody = {
|
|||||||
name?: string;
|
name?: string;
|
||||||
avatar?: string;
|
avatar?: string;
|
||||||
intro?: string;
|
intro?: string;
|
||||||
permission?: DatasetSchemaType['permission']; // TODO: Should be deleted.
|
|
||||||
agentModel?: LLMModelItemType;
|
agentModel?: LLMModelItemType;
|
||||||
status?: DatasetSchemaType['status'];
|
status?: DatasetSchemaType['status'];
|
||||||
|
|
||||||
@@ -75,6 +74,23 @@ export type ExternalFileCreateDatasetCollectionParams = ApiCreateDatasetCollecti
|
|||||||
filename?: string;
|
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 ===================== */
|
/* ================= data ===================== */
|
||||||
export type PgSearchRawType = {
|
export type PgSearchRawType = {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -8,22 +8,22 @@ export enum DatasetTypeEnum {
|
|||||||
export const DatasetTypeMap = {
|
export const DatasetTypeMap = {
|
||||||
[DatasetTypeEnum.folder]: {
|
[DatasetTypeEnum.folder]: {
|
||||||
icon: 'common/folderFill',
|
icon: 'common/folderFill',
|
||||||
label: 'Folder Dataset',
|
label: 'folder_dataset',
|
||||||
collectionLabel: 'common.Folder'
|
collectionLabel: 'common.Folder'
|
||||||
},
|
},
|
||||||
[DatasetTypeEnum.dataset]: {
|
[DatasetTypeEnum.dataset]: {
|
||||||
icon: 'core/dataset/commonDataset',
|
icon: 'core/dataset/commonDataset',
|
||||||
label: 'Common Dataset',
|
label: 'common_dataset',
|
||||||
collectionLabel: 'common.File'
|
collectionLabel: 'common.File'
|
||||||
},
|
},
|
||||||
[DatasetTypeEnum.websiteDataset]: {
|
[DatasetTypeEnum.websiteDataset]: {
|
||||||
icon: 'core/dataset/websiteDataset',
|
icon: 'core/dataset/websiteDataset',
|
||||||
label: 'Website Dataset',
|
label: 'website_dataset',
|
||||||
collectionLabel: 'common.Website'
|
collectionLabel: 'common.Website'
|
||||||
},
|
},
|
||||||
[DatasetTypeEnum.externalFile]: {
|
[DatasetTypeEnum.externalFile]: {
|
||||||
icon: 'core/dataset/externalDataset',
|
icon: 'core/dataset/externalDataset',
|
||||||
label: 'External File',
|
label: 'external_file',
|
||||||
collectionLabel: 'common.File'
|
collectionLabel: 'common.File'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
39
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 type { LLMModelItemType, VectorModelItemType } from '../../core/ai/model.d';
|
||||||
import { PermissionTypeEnum } from '../../support/permission/constant';
|
import { PermissionTypeEnum } from '../../support/permission/constant';
|
||||||
import { PushDatasetDataChunkProps } from './api';
|
import { PushDatasetDataChunkProps } from './api';
|
||||||
@@ -12,31 +12,28 @@ import {
|
|||||||
import { DatasetPermission } from '../../support/permission/dataset/controller';
|
import { DatasetPermission } from '../../support/permission/dataset/controller';
|
||||||
import { Permission } from '../../support/permission/controller';
|
import { Permission } from '../../support/permission/controller';
|
||||||
|
|
||||||
/* schema */
|
|
||||||
export type DatasetSchemaType = {
|
export type DatasetSchemaType = {
|
||||||
_id: string;
|
_id: string;
|
||||||
parentId: string;
|
parentId?: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
teamId: string;
|
teamId: string;
|
||||||
tmbId: string;
|
tmbId: string;
|
||||||
updateTime: Date;
|
updateTime: Date;
|
||||||
|
|
||||||
avatar: string;
|
avatar: string;
|
||||||
name: string;
|
name: string;
|
||||||
vectorModel: string;
|
vectorModel: string;
|
||||||
agentModel: string;
|
agentModel: string;
|
||||||
intro: string;
|
intro: string;
|
||||||
type: DatasetTypeEnum;
|
type: `${DatasetTypeEnum}`;
|
||||||
status: `${DatasetStatusEnum}`;
|
status: `${DatasetStatusEnum}`;
|
||||||
// permission: DatasetPermission;
|
|
||||||
|
|
||||||
// metadata
|
|
||||||
websiteConfig?: {
|
websiteConfig?: {
|
||||||
url: string;
|
url: string;
|
||||||
selector: string;
|
selector: string;
|
||||||
};
|
};
|
||||||
externalReadUrl?: string;
|
externalReadUrl?: string;
|
||||||
defaultPermission: PermissionValueType;
|
} & PermissionSchemaType;
|
||||||
};
|
// } & PermissionSchemaType;
|
||||||
|
|
||||||
export type DatasetCollectionSchemaType = {
|
export type DatasetCollectionSchemaType = {
|
||||||
_id: string;
|
_id: string;
|
||||||
@@ -72,6 +69,13 @@ export type DatasetCollectionSchemaType = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DatasetCollectionTagsSchemaType = {
|
||||||
|
_id: string;
|
||||||
|
teamId: string;
|
||||||
|
datasetId: string;
|
||||||
|
tag: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type DatasetDataIndexItemType = {
|
export type DatasetDataIndexItemType = {
|
||||||
defaultIndex: boolean;
|
defaultIndex: boolean;
|
||||||
dataId: string; // pg data id
|
dataId: string; // pg data id
|
||||||
@@ -133,15 +137,13 @@ export type DatasetSimpleItemType = {
|
|||||||
};
|
};
|
||||||
export type DatasetListItemType = {
|
export type DatasetListItemType = {
|
||||||
_id: string;
|
_id: string;
|
||||||
parentId: string;
|
|
||||||
avatar: string;
|
avatar: string;
|
||||||
name: string;
|
name: string;
|
||||||
intro: string;
|
intro: string;
|
||||||
type: DatasetTypeEnum;
|
type: `${DatasetTypeEnum}`;
|
||||||
permission: DatasetPermission;
|
permission: DatasetPermission;
|
||||||
vectorModel: VectorModelItemType;
|
vectorModel: VectorModelItemType;
|
||||||
defaultPermission: PermissionValueType;
|
} & PermissionSchemaType;
|
||||||
};
|
|
||||||
|
|
||||||
export type DatasetItemType = Omit<DatasetSchemaType, 'vectorModel' | 'agentModel'> & {
|
export type DatasetItemType = Omit<DatasetSchemaType, 'vectorModel' | 'agentModel'> & {
|
||||||
vectorModel: VectorModelItemType;
|
vectorModel: VectorModelItemType;
|
||||||
@@ -149,6 +151,17 @@ export type DatasetItemType = Omit<DatasetSchemaType, 'vectorModel' | 'agentMode
|
|||||||
permission: DatasetPermission;
|
permission: DatasetPermission;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ================= tag ===================== */
|
||||||
|
export type DatasetTagType = {
|
||||||
|
_id: string;
|
||||||
|
tag: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TagUsageType = {
|
||||||
|
tagId: string;
|
||||||
|
collections: string[];
|
||||||
|
};
|
||||||
|
|
||||||
/* ================= collection ===================== */
|
/* ================= collection ===================== */
|
||||||
export type DatasetCollectionItemType = CollectionWithDatasetType & {
|
export type DatasetCollectionItemType = CollectionWithDatasetType & {
|
||||||
sourceName: string;
|
sourceName: string;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export enum FlowNodeTemplateTypeEnum {
|
|||||||
|
|
||||||
search = 'search',
|
search = 'search',
|
||||||
multimodal = 'multimodal',
|
multimodal = 'multimodal',
|
||||||
|
communication = 'communication',
|
||||||
|
|
||||||
other = 'other',
|
other = 'other',
|
||||||
teamApp = 'teamApp'
|
teamApp = 'teamApp'
|
||||||
@@ -74,6 +75,8 @@ export enum NodeInputKeyEnum {
|
|||||||
aiChatQuoteTemplate = 'quoteTemplate',
|
aiChatQuoteTemplate = 'quoteTemplate',
|
||||||
aiChatQuotePrompt = 'quotePrompt',
|
aiChatQuotePrompt = 'quotePrompt',
|
||||||
aiChatDatasetQuote = 'quoteQA',
|
aiChatDatasetQuote = 'quoteQA',
|
||||||
|
aiChatVision = 'aiChatVision',
|
||||||
|
stringQuoteText = 'stringQuoteText',
|
||||||
|
|
||||||
// dataset
|
// dataset
|
||||||
datasetSelectList = 'datasets',
|
datasetSelectList = 'datasets',
|
||||||
@@ -84,6 +87,7 @@ export enum NodeInputKeyEnum {
|
|||||||
datasetSearchUsingExtensionQuery = 'datasetSearchUsingExtensionQuery',
|
datasetSearchUsingExtensionQuery = 'datasetSearchUsingExtensionQuery',
|
||||||
datasetSearchExtensionModel = 'datasetSearchExtensionModel',
|
datasetSearchExtensionModel = 'datasetSearchExtensionModel',
|
||||||
datasetSearchExtensionBg = 'datasetSearchExtensionBg',
|
datasetSearchExtensionBg = 'datasetSearchExtensionBg',
|
||||||
|
collectionFilterMatch = 'collectionFilterMatch',
|
||||||
|
|
||||||
// concat dataset
|
// concat dataset
|
||||||
datasetQuoteList = 'system_datasetQuoteList',
|
datasetQuoteList = 'system_datasetQuoteList',
|
||||||
@@ -116,7 +120,10 @@ export enum NodeInputKeyEnum {
|
|||||||
|
|
||||||
// code
|
// code
|
||||||
code = 'code',
|
code = 'code',
|
||||||
codeType = 'codeType' // js|py
|
codeType = 'codeType', // js|py
|
||||||
|
|
||||||
|
// read files
|
||||||
|
fileUrlList = 'fileUrlList'
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NodeOutputKeyEnum {
|
export enum NodeOutputKeyEnum {
|
||||||
@@ -131,6 +138,9 @@ export enum NodeOutputKeyEnum {
|
|||||||
addOutputParam = 'system_addOutputParam',
|
addOutputParam = 'system_addOutputParam',
|
||||||
rawResponse = 'system_rawResponse',
|
rawResponse = 'system_rawResponse',
|
||||||
|
|
||||||
|
// start
|
||||||
|
userFiles = 'userFiles',
|
||||||
|
|
||||||
// dataset
|
// dataset
|
||||||
datasetQuoteQA = 'quoteQA',
|
datasetQuoteQA = 'quoteQA',
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ export enum FlowNodeTypeEnum {
|
|||||||
variableUpdate = 'variableUpdate',
|
variableUpdate = 'variableUpdate',
|
||||||
code = 'code',
|
code = 'code',
|
||||||
textEditor = 'textEditor',
|
textEditor = 'textEditor',
|
||||||
customFeedback = 'customFeedback'
|
customFeedback = 'customFeedback',
|
||||||
|
readFiles = 'readFiles'
|
||||||
}
|
}
|
||||||
|
|
||||||
// node IO value type
|
// node IO value type
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ import { UserModelSchema } from '../../../support/user/type';
|
|||||||
import { AppDetailType, AppSchema } from '../../app/type';
|
import { AppDetailType, AppSchema } from '../../app/type';
|
||||||
import { RuntimeNodeItemType } from '../runtime/type';
|
import { RuntimeNodeItemType } from '../runtime/type';
|
||||||
import { RuntimeEdgeItemType } from './edge';
|
import { RuntimeEdgeItemType } from './edge';
|
||||||
|
import { ReadFileNodeResponse } from '../template/system/readFiles/type';
|
||||||
|
|
||||||
/* workflow props */
|
/* workflow props */
|
||||||
export type ChatDispatchProps = {
|
export type ChatDispatchProps = {
|
||||||
res?: NextApiResponse;
|
res?: NextApiResponse;
|
||||||
|
requestOrigin?: string;
|
||||||
mode: 'test' | 'chat' | 'debug';
|
mode: 'test' | 'chat' | 'debug';
|
||||||
teamId: string;
|
teamId: string;
|
||||||
tmbId: string;
|
tmbId: string;
|
||||||
@@ -30,6 +32,7 @@ export type ChatDispatchProps = {
|
|||||||
histories: ChatItemType[];
|
histories: ChatItemType[];
|
||||||
variables: Record<string, any>; // global variable
|
variables: Record<string, any>; // global variable
|
||||||
query: UserChatItemValueItemType[]; // trigger query
|
query: UserChatItemValueItemType[]; // trigger query
|
||||||
|
chatConfig: AppSchema['chatConfig'];
|
||||||
stream: boolean;
|
stream: boolean;
|
||||||
detail: boolean; // response detail
|
detail: boolean; // response detail
|
||||||
maxRunTimes: number;
|
maxRunTimes: number;
|
||||||
@@ -146,6 +149,10 @@ export type DispatchNodeResponseType = {
|
|||||||
|
|
||||||
// plugin
|
// plugin
|
||||||
pluginOutput?: Record<string, any>;
|
pluginOutput?: Record<string, any>;
|
||||||
|
|
||||||
|
// read files
|
||||||
|
readFilesResult?: string;
|
||||||
|
readFiles?: ReadFileNodeResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DispatchNodeResultType<T> = {
|
export type DispatchNodeResultType<T> = {
|
||||||
@@ -166,4 +173,6 @@ export type AIChatNodeProps = {
|
|||||||
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;
|
[NodeInputKeyEnum.aiChatIsResponseText]: boolean;
|
||||||
[NodeInputKeyEnum.aiChatQuoteTemplate]?: string;
|
[NodeInputKeyEnum.aiChatQuoteTemplate]?: string;
|
||||||
[NodeInputKeyEnum.aiChatQuotePrompt]?: string;
|
[NodeInputKeyEnum.aiChatQuotePrompt]?: string;
|
||||||
|
[NodeInputKeyEnum.aiChatVision]?: boolean;
|
||||||
|
[NodeInputKeyEnum.stringQuoteText]?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { VariableUpdateNode } from './system/variableUpdate';
|
|||||||
import { CodeNode } from './system/sandbox';
|
import { CodeNode } from './system/sandbox';
|
||||||
import { TextEditorNode } from './system/textEditor';
|
import { TextEditorNode } from './system/textEditor';
|
||||||
import { CustomFeedbackNode } from './system/customFeedback';
|
import { CustomFeedbackNode } from './system/customFeedback';
|
||||||
|
import { ReadFilesNodes } from './system/readFiles';
|
||||||
|
|
||||||
const systemNodes: FlowNodeTemplateType[] = [
|
const systemNodes: FlowNodeTemplateType[] = [
|
||||||
AiChatModule,
|
AiChatModule,
|
||||||
@@ -36,6 +37,7 @@ const systemNodes: FlowNodeTemplateType[] = [
|
|||||||
StopToolNode,
|
StopToolNode,
|
||||||
ClassifyQuestionModule,
|
ClassifyQuestionModule,
|
||||||
ContextExtractModule,
|
ContextExtractModule,
|
||||||
|
ReadFilesNodes,
|
||||||
HttpNode468,
|
HttpNode468,
|
||||||
AiQueryExtension,
|
AiQueryExtension,
|
||||||
LafModule,
|
LafModule,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { FlowNodeInputTypeEnum } from '../node/constant';
|
|||||||
import { WorkflowIOValueTypeEnum } from '../constants';
|
import { WorkflowIOValueTypeEnum } from '../constants';
|
||||||
import { chatNodeSystemPromptTip } from './tip';
|
import { chatNodeSystemPromptTip } from './tip';
|
||||||
import { FlowNodeInputItemType } from '../type/io';
|
import { FlowNodeInputItemType } from '../type/io';
|
||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
|
|
||||||
export const Input_Template_History: FlowNodeInputItemType = {
|
export const Input_Template_History: FlowNodeInputItemType = {
|
||||||
key: NodeInputKeyEnum.history,
|
key: NodeInputKeyEnum.history,
|
||||||
@@ -64,3 +65,11 @@ export const Input_Template_Dataset_Quote: FlowNodeInputItemType = {
|
|||||||
description: '',
|
description: '',
|
||||||
valueType: WorkflowIOValueTypeEnum.datasetQuote
|
valueType: WorkflowIOValueTypeEnum.datasetQuote
|
||||||
};
|
};
|
||||||
|
export const Input_Template_Text_Quote: FlowNodeInputItemType = {
|
||||||
|
key: NodeInputKeyEnum.stringQuoteText,
|
||||||
|
renderTypeList: [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.textarea],
|
||||||
|
label: i18nT('app:document_quote'),
|
||||||
|
debugLabel: i18nT('app:document_quote'),
|
||||||
|
description: i18nT('app:document_quote_tip'),
|
||||||
|
valueType: WorkflowIOValueTypeEnum.string
|
||||||
|
};
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ import {
|
|||||||
Input_Template_Dataset_Quote,
|
Input_Template_Dataset_Quote,
|
||||||
Input_Template_History,
|
Input_Template_History,
|
||||||
Input_Template_System_Prompt,
|
Input_Template_System_Prompt,
|
||||||
Input_Template_UserChatInput
|
Input_Template_UserChatInput,
|
||||||
|
Input_Template_Text_Quote
|
||||||
} from '../input';
|
} from '../input';
|
||||||
import { chatNodeSystemPromptTip } from '../tip';
|
import { chatNodeSystemPromptTip } from '../tip';
|
||||||
import { getHandleConfig } from '../utils';
|
import { getHandleConfig } from '../utils';
|
||||||
|
import { i18nT } from '../../../../../web/i18n/utils';
|
||||||
|
|
||||||
export const AiChatModule: FlowNodeTemplateType = {
|
export const AiChatModule: FlowNodeTemplateType = {
|
||||||
id: FlowNodeTypeEnum.chatNode,
|
id: FlowNodeTypeEnum.chatNode,
|
||||||
@@ -27,8 +29,8 @@ export const AiChatModule: FlowNodeTemplateType = {
|
|||||||
sourceHandle: getHandleConfig(true, true, true, true),
|
sourceHandle: getHandleConfig(true, true, true, true),
|
||||||
targetHandle: getHandleConfig(true, true, true, true),
|
targetHandle: getHandleConfig(true, true, true, true),
|
||||||
avatar: 'core/workflow/template/aiChat',
|
avatar: 'core/workflow/template/aiChat',
|
||||||
name: 'AI 对话',
|
name: i18nT('workflow:template.ai_chat'),
|
||||||
intro: 'AI 大模型对话',
|
intro: i18nT('workflow:template.ai_chat_intro'),
|
||||||
showStatus: true,
|
showStatus: true,
|
||||||
isTool: true,
|
isTool: true,
|
||||||
version: '481',
|
version: '481',
|
||||||
@@ -40,20 +42,14 @@ export const AiChatModule: FlowNodeTemplateType = {
|
|||||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||||
label: '',
|
label: '',
|
||||||
value: 0,
|
value: 0,
|
||||||
valueType: WorkflowIOValueTypeEnum.number,
|
valueType: WorkflowIOValueTypeEnum.number
|
||||||
min: 0,
|
|
||||||
max: 10,
|
|
||||||
step: 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: NodeInputKeyEnum.aiChatMaxToken,
|
key: NodeInputKeyEnum.aiChatMaxToken,
|
||||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||||
label: '',
|
label: '',
|
||||||
value: 2000,
|
value: 2000,
|
||||||
valueType: WorkflowIOValueTypeEnum.number,
|
valueType: WorkflowIOValueTypeEnum.number
|
||||||
min: 100,
|
|
||||||
max: 4000,
|
|
||||||
step: 50
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: NodeInputKeyEnum.aiChatIsResponseText,
|
key: NodeInputKeyEnum.aiChatIsResponseText,
|
||||||
@@ -74,6 +70,13 @@ export const AiChatModule: FlowNodeTemplateType = {
|
|||||||
label: '',
|
label: '',
|
||||||
valueType: WorkflowIOValueTypeEnum.string
|
valueType: WorkflowIOValueTypeEnum.string
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: NodeInputKeyEnum.aiChatVision,
|
||||||
|
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||||
|
label: '',
|
||||||
|
valueType: WorkflowIOValueTypeEnum.boolean,
|
||||||
|
value: true
|
||||||
|
},
|
||||||
// settings modal ---
|
// settings modal ---
|
||||||
{
|
{
|
||||||
...Input_Template_System_Prompt,
|
...Input_Template_System_Prompt,
|
||||||
@@ -82,8 +85,9 @@ export const AiChatModule: FlowNodeTemplateType = {
|
|||||||
placeholder: chatNodeSystemPromptTip
|
placeholder: chatNodeSystemPromptTip
|
||||||
},
|
},
|
||||||
Input_Template_History,
|
Input_Template_History,
|
||||||
{ ...Input_Template_UserChatInput, toolDescription: '用户问题' },
|
Input_Template_Dataset_Quote,
|
||||||
Input_Template_Dataset_Quote
|
Input_Template_Text_Quote,
|
||||||
|
{ ...Input_Template_UserChatInput, toolDescription: '用户问题' }
|
||||||
],
|
],
|
||||||
outputs: [
|
outputs: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import {
|
|||||||
import { Input_Template_UserChatInput } from '../input';
|
import { Input_Template_UserChatInput } from '../input';
|
||||||
import { DatasetSearchModeEnum } from '../../../dataset/constants';
|
import { DatasetSearchModeEnum } from '../../../dataset/constants';
|
||||||
import { getHandleConfig } from '../utils';
|
import { getHandleConfig } from '../utils';
|
||||||
|
import { i18nT } from '../../../../../web/i18n/utils';
|
||||||
|
|
||||||
export const Dataset_SEARCH_DESC =
|
export const Dataset_SEARCH_DESC = i18nT('workflow:template.dataset_search_intro');
|
||||||
'调用“语义检索”和“全文检索”能力,从“知识库”中查找可能与问题相关的参考内容';
|
|
||||||
|
|
||||||
export const DatasetSearchModule: FlowNodeTemplateType = {
|
export const DatasetSearchModule: FlowNodeTemplateType = {
|
||||||
id: FlowNodeTypeEnum.datasetSearchNode,
|
id: FlowNodeTypeEnum.datasetSearchNode,
|
||||||
@@ -24,7 +24,7 @@ export const DatasetSearchModule: FlowNodeTemplateType = {
|
|||||||
sourceHandle: getHandleConfig(true, true, true, true),
|
sourceHandle: getHandleConfig(true, true, true, true),
|
||||||
targetHandle: getHandleConfig(true, true, true, true),
|
targetHandle: getHandleConfig(true, true, true, true),
|
||||||
avatar: 'core/workflow/template/datasetSearch',
|
avatar: 'core/workflow/template/datasetSearch',
|
||||||
name: '知识库搜索',
|
name: i18nT('workflow:template.dataset_search'),
|
||||||
intro: Dataset_SEARCH_DESC,
|
intro: Dataset_SEARCH_DESC,
|
||||||
showStatus: true,
|
showStatus: true,
|
||||||
isTool: true,
|
isTool: true,
|
||||||
@@ -90,6 +90,25 @@ export const DatasetSearchModule: FlowNodeTemplateType = {
|
|||||||
{
|
{
|
||||||
...Input_Template_UserChatInput,
|
...Input_Template_UserChatInput,
|
||||||
toolDescription: '需要检索的内容'
|
toolDescription: '需要检索的内容'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: NodeInputKeyEnum.collectionFilterMatch,
|
||||||
|
renderTypeList: [FlowNodeInputTypeEnum.JSONEditor, FlowNodeInputTypeEnum.reference],
|
||||||
|
label: '集合元数据过滤',
|
||||||
|
valueType: WorkflowIOValueTypeEnum.object,
|
||||||
|
isPro: true,
|
||||||
|
description: `目前支持标签和创建时间过滤,需按照以下格式填写:
|
||||||
|
{
|
||||||
|
"tags": {
|
||||||
|
"$and": ["标签 1","标签 2"],
|
||||||
|
"$or": ["有 $and 标签时,and 生效,or 不生效"]
|
||||||
|
},
|
||||||
|
"createTime": {
|
||||||
|
"$gte": "YYYY-MM-DD HH:mm 格式即可,集合的创建时间大于该时间",
|
||||||
|
"$lte": "YYYY-MM-DD HH:mm 格式即可,集合的创建时间小于该时间,可和 $gte 共同使用"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
outputs: [
|
outputs: [
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { i18nT } from '../../../../../../web/i18n/utils';
|
||||||
|
import {
|
||||||
|
FlowNodeTemplateTypeEnum,
|
||||||
|
NodeInputKeyEnum,
|
||||||
|
NodeOutputKeyEnum,
|
||||||
|
WorkflowIOValueTypeEnum
|
||||||
|
} from '../../../constants';
|
||||||
|
import {
|
||||||
|
FlowNodeInputTypeEnum,
|
||||||
|
FlowNodeOutputTypeEnum,
|
||||||
|
FlowNodeTypeEnum
|
||||||
|
} from '../../../node/constant';
|
||||||
|
import { FlowNodeTemplateType } from '../../../type/node';
|
||||||
|
import { getHandleConfig } from '../../utils';
|
||||||
|
|
||||||
|
export const ReadFilesNodes: FlowNodeTemplateType = {
|
||||||
|
id: FlowNodeTypeEnum.readFiles,
|
||||||
|
templateType: FlowNodeTemplateTypeEnum.tools,
|
||||||
|
flowNodeType: FlowNodeTypeEnum.readFiles,
|
||||||
|
sourceHandle: getHandleConfig(true, true, true, true),
|
||||||
|
targetHandle: getHandleConfig(true, true, true, true),
|
||||||
|
avatar: 'core/workflow/template/readFiles',
|
||||||
|
name: i18nT('app:workflow.read_files'),
|
||||||
|
intro: i18nT('app:workflow.read_files_tip'),
|
||||||
|
showStatus: true,
|
||||||
|
version: '489',
|
||||||
|
isTool: true,
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
key: NodeInputKeyEnum.fileUrlList,
|
||||||
|
renderTypeList: [FlowNodeInputTypeEnum.reference],
|
||||||
|
valueType: WorkflowIOValueTypeEnum.arrayString,
|
||||||
|
label: i18nT('app:workflow.file_url'),
|
||||||
|
required: true,
|
||||||
|
value: []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
id: NodeOutputKeyEnum.text,
|
||||||
|
key: NodeOutputKeyEnum.text,
|
||||||
|
label: i18nT('app:workflow.read_files_result'),
|
||||||
|
description: i18nT('app:workflow.read_files_result_desc'),
|
||||||
|
valueType: WorkflowIOValueTypeEnum.string,
|
||||||
|
type: FlowNodeOutputTypeEnum.static
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
4
packages/global/core/workflow/template/system/readFiles/type.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export type ReadFileNodeResponse = {
|
||||||
|
url: string;
|
||||||
|
name: string;
|
||||||
|
}[];
|
||||||
@@ -2,6 +2,7 @@ import { FlowNodeTypeEnum } from '../../node/constant';
|
|||||||
import { FlowNodeTemplateType } from '../../type/node.d';
|
import { FlowNodeTemplateType } from '../../type/node.d';
|
||||||
import { FlowNodeTemplateTypeEnum } from '../../constants';
|
import { FlowNodeTemplateTypeEnum } from '../../constants';
|
||||||
import { getHandleConfig } from '../utils';
|
import { getHandleConfig } from '../utils';
|
||||||
|
import { i18nT } from '../../../../../web/i18n/utils';
|
||||||
|
|
||||||
export const SystemConfigNode: FlowNodeTemplateType = {
|
export const SystemConfigNode: FlowNodeTemplateType = {
|
||||||
id: FlowNodeTypeEnum.systemConfig,
|
id: FlowNodeTypeEnum.systemConfig,
|
||||||
@@ -10,8 +11,8 @@ export const SystemConfigNode: FlowNodeTemplateType = {
|
|||||||
sourceHandle: getHandleConfig(false, false, false, false),
|
sourceHandle: getHandleConfig(false, false, false, false),
|
||||||
targetHandle: getHandleConfig(false, false, false, false),
|
targetHandle: getHandleConfig(false, false, false, false),
|
||||||
avatar: 'core/workflow/template/systemConfig',
|
avatar: 'core/workflow/template/systemConfig',
|
||||||
name: '系统配置',
|
name: i18nT('workflow:template.system_config'),
|
||||||
intro: '可以配置应用的系统参数。',
|
intro: '',
|
||||||
unique: true,
|
unique: true,
|
||||||
forbidDelete: true,
|
forbidDelete: true,
|
||||||
version: '481',
|
version: '481',
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
import { chatNodeSystemPromptTip } from '../tip';
|
import { chatNodeSystemPromptTip } from '../tip';
|
||||||
import { LLMModelTypeEnum } from '../../../ai/constants';
|
import { LLMModelTypeEnum } from '../../../ai/constants';
|
||||||
import { getHandleConfig } from '../utils';
|
import { getHandleConfig } from '../utils';
|
||||||
|
import { i18nT } from '../../../../../web/i18n/utils';
|
||||||
|
|
||||||
export const ToolModule: FlowNodeTemplateType = {
|
export const ToolModule: FlowNodeTemplateType = {
|
||||||
id: FlowNodeTypeEnum.tools,
|
id: FlowNodeTypeEnum.tools,
|
||||||
@@ -27,8 +28,8 @@ export const ToolModule: FlowNodeTemplateType = {
|
|||||||
sourceHandle: getHandleConfig(true, true, false, true),
|
sourceHandle: getHandleConfig(true, true, false, true),
|
||||||
targetHandle: getHandleConfig(true, true, false, true),
|
targetHandle: getHandleConfig(true, true, false, true),
|
||||||
avatar: 'core/workflow/template/toolCall',
|
avatar: 'core/workflow/template/toolCall',
|
||||||
name: '工具调用',
|
name: i18nT('workflow:template.tool_call'),
|
||||||
intro: '通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。',
|
intro: i18nT('workflow:template.tool_call_intro'),
|
||||||
showStatus: true,
|
showStatus: true,
|
||||||
version: '481',
|
version: '481',
|
||||||
inputs: [
|
inputs: [
|
||||||
@@ -41,21 +42,23 @@ export const ToolModule: FlowNodeTemplateType = {
|
|||||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||||
label: '',
|
label: '',
|
||||||
value: 0,
|
value: 0,
|
||||||
valueType: WorkflowIOValueTypeEnum.number,
|
valueType: WorkflowIOValueTypeEnum.number
|
||||||
min: 0,
|
|
||||||
max: 10,
|
|
||||||
step: 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: NodeInputKeyEnum.aiChatMaxToken,
|
key: NodeInputKeyEnum.aiChatMaxToken,
|
||||||
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
renderTypeList: [FlowNodeInputTypeEnum.hidden], // Set in the pop-up window
|
||||||
label: '',
|
label: '',
|
||||||
value: 2000,
|
value: 2000,
|
||||||
valueType: WorkflowIOValueTypeEnum.number,
|
valueType: WorkflowIOValueTypeEnum.number
|
||||||
min: 100,
|
|
||||||
max: 4000,
|
|
||||||
step: 50
|
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: NodeInputKeyEnum.aiChatVision,
|
||||||
|
renderTypeList: [FlowNodeInputTypeEnum.hidden],
|
||||||
|
label: '',
|
||||||
|
valueType: WorkflowIOValueTypeEnum.boolean,
|
||||||
|
value: true
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
...Input_Template_System_Prompt,
|
...Input_Template_System_Prompt,
|
||||||
label: 'core.ai.Prompt',
|
label: 'core.ai.Prompt',
|
||||||
|
|||||||
@@ -7,6 +7,17 @@ import {
|
|||||||
} from '../../constants';
|
} from '../../constants';
|
||||||
import { getHandleConfig } from '../utils';
|
import { getHandleConfig } from '../utils';
|
||||||
import { Input_Template_UserChatInput } from '../input';
|
import { Input_Template_UserChatInput } from '../input';
|
||||||
|
import { i18nT } from '../../../../../web/i18n/utils';
|
||||||
|
import { FlowNodeOutputItemType } from '../../type/io';
|
||||||
|
|
||||||
|
export const userFilesInput: FlowNodeOutputItemType = {
|
||||||
|
id: NodeOutputKeyEnum.userFiles,
|
||||||
|
key: NodeOutputKeyEnum.userFiles,
|
||||||
|
label: i18nT('app:workflow.user_file_input'),
|
||||||
|
description: i18nT('app:workflow.user_file_input_desc'),
|
||||||
|
type: FlowNodeOutputTypeEnum.static,
|
||||||
|
valueType: WorkflowIOValueTypeEnum.arrayString
|
||||||
|
};
|
||||||
|
|
||||||
export const WorkflowStart: FlowNodeTemplateType = {
|
export const WorkflowStart: FlowNodeTemplateType = {
|
||||||
id: FlowNodeTypeEnum.workflowStart,
|
id: FlowNodeTypeEnum.workflowStart,
|
||||||
@@ -15,7 +26,7 @@ export const WorkflowStart: FlowNodeTemplateType = {
|
|||||||
sourceHandle: getHandleConfig(false, true, false, false),
|
sourceHandle: getHandleConfig(false, true, false, false),
|
||||||
targetHandle: getHandleConfig(false, false, false, false),
|
targetHandle: getHandleConfig(false, false, false, false),
|
||||||
avatar: 'core/workflow/template/workflowStart',
|
avatar: 'core/workflow/template/workflowStart',
|
||||||
name: '流程开始',
|
name: i18nT('workflow:template.workflow_start'),
|
||||||
intro: '',
|
intro: '',
|
||||||
forbidDelete: true,
|
forbidDelete: true,
|
||||||
unique: true,
|
unique: true,
|
||||||
@@ -25,7 +36,7 @@ export const WorkflowStart: FlowNodeTemplateType = {
|
|||||||
{
|
{
|
||||||
id: NodeOutputKeyEnum.userChatInput,
|
id: NodeOutputKeyEnum.userChatInput,
|
||||||
key: NodeOutputKeyEnum.userChatInput,
|
key: NodeOutputKeyEnum.userChatInput,
|
||||||
label: 'core.module.input.label.user question',
|
label: i18nT('common:core.module.input.label.user question'),
|
||||||
type: FlowNodeOutputTypeEnum.static,
|
type: FlowNodeOutputTypeEnum.static,
|
||||||
valueType: WorkflowIOValueTypeEnum.string
|
valueType: WorkflowIOValueTypeEnum.string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export type WorkflowTemplateType = {
|
|||||||
avatar: string;
|
avatar: string;
|
||||||
intro?: string;
|
intro?: string;
|
||||||
author?: string;
|
author?: string;
|
||||||
|
inputExplanationUrl?: string;
|
||||||
version: string;
|
version: string;
|
||||||
|
|
||||||
showStatus?: boolean;
|
showStatus?: boolean;
|
||||||
|
|||||||
1
packages/global/core/workflow/type/io.d.ts
vendored
@@ -52,6 +52,7 @@ export type FlowNodeInputItemType = InputComponentPropsType & {
|
|||||||
|
|
||||||
// render components params
|
// render components params
|
||||||
canEdit?: boolean; // dynamic inputs
|
canEdit?: boolean; // dynamic inputs
|
||||||
|
isPro?: boolean; // Pro version field
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FlowNodeOutputItemType = {
|
export type FlowNodeOutputItemType = {
|
||||||
|
|||||||
1
packages/global/core/workflow/type/node.d.ts
vendored
@@ -31,6 +31,7 @@ export type FlowNodeCommonType = {
|
|||||||
avatar?: string;
|
avatar?: string;
|
||||||
name: string;
|
name: string;
|
||||||
intro?: string; // template list intro
|
intro?: string; // template list intro
|
||||||
|
inputExplanationUrl?: string;
|
||||||
showStatus?: boolean; // chatting response step status
|
showStatus?: boolean; // chatting response step status
|
||||||
version: string;
|
version: string;
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import {
|
|||||||
WorkflowIOValueTypeEnum,
|
WorkflowIOValueTypeEnum,
|
||||||
NodeInputKeyEnum,
|
NodeInputKeyEnum,
|
||||||
VariableInputEnum,
|
VariableInputEnum,
|
||||||
variableMap
|
variableMap,
|
||||||
|
VARIABLE_NODE_ID
|
||||||
} from './constants';
|
} from './constants';
|
||||||
import { FlowNodeInputItemType, FlowNodeOutputItemType } from './type/io.d';
|
import { FlowNodeInputItemType, FlowNodeOutputItemType, ReferenceValueProps } from './type/io.d';
|
||||||
import { StoreNodeItemType } from './type/node';
|
import { StoreNodeItemType } from './type/node';
|
||||||
import type {
|
import type {
|
||||||
VariableItemType,
|
VariableItemType,
|
||||||
@@ -23,6 +24,7 @@ import {
|
|||||||
} from '../app/constants';
|
} from '../app/constants';
|
||||||
import { IfElseResultEnum } from './template/system/ifElse/constant';
|
import { IfElseResultEnum } from './template/system/ifElse/constant';
|
||||||
import { RuntimeNodeItemType } from './runtime/type';
|
import { RuntimeNodeItemType } from './runtime/type';
|
||||||
|
import { getReferenceVariableValue } from './runtime/utils';
|
||||||
|
|
||||||
export const getHandleId = (nodeId: string, type: 'source' | 'target', key: string) => {
|
export const getHandleId = (nodeId: string, type: 'source' | 'target', key: string) => {
|
||||||
return `${nodeId}-${type}-${key}`;
|
return `${nodeId}-${type}-${key}`;
|
||||||
@@ -80,6 +82,8 @@ export const splitGuideModule = (guideModules?: StoreNodeItemType) => {
|
|||||||
chatInputGuide
|
chatInputGuide
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get app chat config: db > nodes
|
||||||
export const getAppChatConfig = ({
|
export const getAppChatConfig = ({
|
||||||
chatConfig,
|
chatConfig,
|
||||||
systemConfigNode,
|
systemConfigNode,
|
||||||
@@ -123,6 +127,7 @@ export const getAppChatConfig = ({
|
|||||||
|
|
||||||
export const getOrInitModuleInputValue = (input: FlowNodeInputItemType) => {
|
export const getOrInitModuleInputValue = (input: FlowNodeInputItemType) => {
|
||||||
if (input.value !== undefined || !input.valueType) return input.value;
|
if (input.value !== undefined || !input.valueType) return input.value;
|
||||||
|
if (input.defaultValue !== undefined) return input.defaultValue;
|
||||||
|
|
||||||
const map: Record<string, any> = {
|
const map: Record<string, any> = {
|
||||||
[WorkflowIOValueTypeEnum.boolean]: false,
|
[WorkflowIOValueTypeEnum.boolean]: false,
|
||||||
@@ -226,3 +231,90 @@ export const updatePluginInputByVariables = (
|
|||||||
: node
|
: node
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const removePluginInputVariables = (
|
||||||
|
variables: Record<string, any>,
|
||||||
|
nodes: RuntimeNodeItemType[]
|
||||||
|
) => {
|
||||||
|
const pluginInputNode = nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginInput);
|
||||||
|
|
||||||
|
if (!pluginInputNode) return variables;
|
||||||
|
return Object.keys(variables).reduce(
|
||||||
|
(acc, key) => {
|
||||||
|
if (!pluginInputNode.inputs.find((input) => input.key === key)) {
|
||||||
|
acc[key] = variables[key];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{} as Record<string, any>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function replaceVariableLabel({
|
||||||
|
text,
|
||||||
|
nodes,
|
||||||
|
variables,
|
||||||
|
runningNode
|
||||||
|
}: {
|
||||||
|
text: any;
|
||||||
|
nodes: RuntimeNodeItemType[];
|
||||||
|
variables: Record<string, string | number>;
|
||||||
|
runningNode: RuntimeNodeItemType;
|
||||||
|
}) {
|
||||||
|
if (typeof text !== 'string') return text;
|
||||||
|
|
||||||
|
const globalVariables = Object.keys(variables).map((key) => {
|
||||||
|
return {
|
||||||
|
nodeId: VARIABLE_NODE_ID,
|
||||||
|
id: key,
|
||||||
|
value: variables[key]
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
// Upstream node outputs
|
||||||
|
const nodeVariables = nodes
|
||||||
|
.map((node) => {
|
||||||
|
return node.outputs.map((output) => {
|
||||||
|
return {
|
||||||
|
nodeId: node.nodeId,
|
||||||
|
id: output.id,
|
||||||
|
value: output.value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.flat();
|
||||||
|
|
||||||
|
// Get runningNode inputs(Will be replaced with reference)
|
||||||
|
const customInputs = runningNode.inputs.flatMap((item) => {
|
||||||
|
if (Array.isArray(item.value)) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: item.key,
|
||||||
|
value: getReferenceVariableValue({
|
||||||
|
value: item.value as ReferenceValueProps,
|
||||||
|
nodes,
|
||||||
|
variables
|
||||||
|
}),
|
||||||
|
nodeId: runningNode.nodeId
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
|
||||||
|
const allVariables = [...globalVariables, ...nodeVariables, ...customInputs];
|
||||||
|
|
||||||
|
// Replace {{$xxx.xxx$}} to value
|
||||||
|
for (const key in allVariables) {
|
||||||
|
const val = allVariables[key];
|
||||||
|
const regex = new RegExp(`\\{\\{\\$(${val.nodeId}\\.${val.id})\\$\\}\\}`, 'g');
|
||||||
|
if (['string', 'number'].includes(typeof val.value)) {
|
||||||
|
text = text.replace(regex, String(val.value));
|
||||||
|
} else if (['object'].includes(typeof val.value)) {
|
||||||
|
text = text.replace(regex, JSON.stringify(val.value));
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return text || '';
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"jschardet": "3.1.1",
|
"jschardet": "3.1.1",
|
||||||
"nanoid": "^4.0.1",
|
"nanoid": "^4.0.1",
|
||||||
"next": "14.2.5",
|
"next": "14.2.5",
|
||||||
"openai": "4.28.0",
|
"openai": "4.53.0",
|
||||||
"openapi-types": "^12.1.3",
|
"openapi-types": "^12.1.3",
|
||||||
"timezones-list": "^3.0.2"
|
"timezones-list": "^3.0.2"
|
||||||
},
|
},
|
||||||
|
|||||||
14
packages/global/support/permission/type.d.ts
vendored
@@ -1,11 +1,13 @@
|
|||||||
import { TeamMemberWithUserSchema } from '../user/team/type';
|
import { TeamMemberWithUserSchema } from '../user/team/type';
|
||||||
import { AuthUserTypeEnum, PermissionKeyEnum } from './constant';
|
import { AuthUserTypeEnum, PermissionKeyEnum, PerResourceTypeEnum } from './constant';
|
||||||
|
|
||||||
// PermissionValueType, the type of permission's value is a number, which is a bit field actually.
|
// PermissionValueType, the type of permission's value is a number, which is a bit field actually.
|
||||||
// It is spired by the permission system in Linux.
|
// It is spired by the permission system in Linux.
|
||||||
// The lowest 3 bits present the permission of reading, writing and managing.
|
// The lowest 3 bits present the permission of reading, writing and managing.
|
||||||
// The higher bits are advanced permissions or extended permissions, which could be customized.
|
// The higher bits are advanced permissions or extended permissions, which could be customized.
|
||||||
export type PermissionValueType = number;
|
export type PermissionValueType = number;
|
||||||
|
export type ResourceType = `${PerResourceTypeEnum}`;
|
||||||
|
|
||||||
export type PermissionListType<T = {}> = Record<
|
export type PermissionListType<T = {}> = Record<
|
||||||
T | PermissionKeyEnum,
|
T | PermissionKeyEnum,
|
||||||
{
|
{
|
||||||
@@ -16,16 +18,6 @@ export type PermissionListType<T = {}> = Record<
|
|||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type AuthResponseType = {
|
|
||||||
teamId: string;
|
|
||||||
tmbId: string;
|
|
||||||
isOwner: boolean;
|
|
||||||
canWrite: boolean;
|
|
||||||
authType?: `${AuthUserTypeEnum}`;
|
|
||||||
appId?: string;
|
|
||||||
apikey?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ResourcePermissionType = {
|
export type ResourcePermissionType = {
|
||||||
teamId: string;
|
teamId: string;
|
||||||
tmbId: string;
|
tmbId: string;
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
export enum UserAuthTypeEnum {
|
export enum UserAuthTypeEnum {
|
||||||
register = 'register',
|
register = 'register',
|
||||||
findPassword = 'findPassword',
|
findPassword = 'findPassword',
|
||||||
wxLogin = 'wxLogin'
|
wxLogin = 'wxLogin',
|
||||||
|
bindNotification = 'bindNotification'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const userAuthTypeMap = {
|
export const userAuthTypeMap = {
|
||||||
[UserAuthTypeEnum.register]: 'register',
|
[UserAuthTypeEnum.register]: 'register',
|
||||||
[UserAuthTypeEnum.findPassword]: 'findPassword',
|
[UserAuthTypeEnum.findPassword]: 'findPassword',
|
||||||
[UserAuthTypeEnum.wxLogin]: 'wxLogin'
|
[UserAuthTypeEnum.wxLogin]: 'wxLogin',
|
||||||
|
[UserAuthTypeEnum.bindNotification]: 'bindNotification'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,3 +15,14 @@ export const InformLevelMap = {
|
|||||||
label: '紧急'
|
label: '紧急'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export enum SendInformTemplateCodeEnum {
|
||||||
|
EXPIRE_SOON = 'EXPIRE_SOON',
|
||||||
|
EXPIRED = 'EXPIRED',
|
||||||
|
FREE_CLEAN = 'FREE_CLEAN',
|
||||||
|
REGISTER = 'REGISTER',
|
||||||
|
RESET_PASSWORD = 'RESET_PASSWORD',
|
||||||
|
BIND_NOTIFICATION = 'BIND_NOTIFICATION',
|
||||||
|
LACK_OF_POINTS = 'LACK_OF_POINTS',
|
||||||
|
CUSTOM = 'CUSTOM'
|
||||||
|
}
|
||||||
|
|||||||
11
packages/global/support/user/inform/type.d.ts
vendored
@@ -1,13 +1,16 @@
|
|||||||
import { InformLevelEnum } from './constants';
|
import { InformLevelEnum, SendInformTemplateCodeEnum } from './constants';
|
||||||
|
|
||||||
export type SendInformProps = {
|
export type SendInformProps = {
|
||||||
title: string;
|
|
||||||
content: string;
|
|
||||||
level: `${InformLevelEnum}`;
|
level: `${InformLevelEnum}`;
|
||||||
|
templateCode: `${SendInformTemplateCodeEnum}`;
|
||||||
|
templateParam: Record<string, any>;
|
||||||
|
customLockMinutes?: number; // custom lock minutes
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SendInform2UserProps = SendInformProps & {
|
export type SendInform2UserProps = SendInformProps & {
|
||||||
tmbId: string;
|
teamId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SendInform2User = SendInformProps & {
|
export type SendInform2User = SendInformProps & {
|
||||||
type: `${InformTypeEnum}`;
|
type: `${InformTypeEnum}`;
|
||||||
tmbId: string;
|
tmbId: string;
|
||||||
|
|||||||
@@ -3,22 +3,13 @@ export const TeamMemberCollectionName = 'team_members';
|
|||||||
export const TeamTagsCollectionName = 'team_tags';
|
export const TeamTagsCollectionName = 'team_tags';
|
||||||
|
|
||||||
export enum TeamMemberRoleEnum {
|
export enum TeamMemberRoleEnum {
|
||||||
owner = 'owner',
|
owner = 'owner'
|
||||||
admin = 'admin',
|
|
||||||
visitor = 'visitor'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TeamMemberRoleMap = {
|
export const TeamMemberRoleMap = {
|
||||||
[TeamMemberRoleEnum.owner]: {
|
[TeamMemberRoleEnum.owner]: {
|
||||||
value: TeamMemberRoleEnum.owner,
|
value: TeamMemberRoleEnum.owner,
|
||||||
label: 'user.team.role.Owner'
|
label: 'user.team.role.Owner'
|
||||||
},
|
|
||||||
[TeamMemberRoleEnum.admin]: {
|
|
||||||
value: TeamMemberRoleEnum.admin,
|
|
||||||
label: 'user.team.role.Admin'
|
|
||||||
},
|
|
||||||
[TeamMemberRoleEnum.visitor]: {
|
|
||||||
value: TeamMemberRoleEnum.visitor,
|
|
||||||
label: 'user.team.role.Visitor'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,6 +19,7 @@ export enum TeamMemberStatusEnum {
|
|||||||
reject = 'reject',
|
reject = 'reject',
|
||||||
leave = 'leave'
|
leave = 'leave'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TeamMemberStatusMap = {
|
export const TeamMemberStatusMap = {
|
||||||
[TeamMemberStatusEnum.waiting]: {
|
[TeamMemberStatusEnum.waiting]: {
|
||||||
label: 'user.team.member.waiting',
|
label: 'user.team.member.waiting',
|
||||||
@@ -46,4 +38,5 @@ export const TeamMemberStatusMap = {
|
|||||||
color: 'red.600'
|
color: 'red.600'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const notLeaveStatus = { $ne: TeamMemberStatusEnum.leave };
|
export const notLeaveStatus = { $ne: TeamMemberStatusEnum.leave };
|
||||||
|
|||||||
4
packages/global/support/user/team/type.d.ts
vendored
@@ -18,7 +18,9 @@ export type TeamSchema = {
|
|||||||
};
|
};
|
||||||
lafAccount: LafAccountType;
|
lafAccount: LafAccountType;
|
||||||
defaultPermission: PermissionValueType;
|
defaultPermission: PermissionValueType;
|
||||||
|
notificationAccount?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type tagsType = {
|
export type tagsType = {
|
||||||
label: string;
|
label: string;
|
||||||
key: string;
|
key: string;
|
||||||
@@ -63,6 +65,7 @@ export type TeamTmbItemType = {
|
|||||||
role: `${TeamMemberRoleEnum}`;
|
role: `${TeamMemberRoleEnum}`;
|
||||||
status: `${TeamMemberStatusEnum}`;
|
status: `${TeamMemberStatusEnum}`;
|
||||||
lafAccount?: LafAccountType;
|
lafAccount?: LafAccountType;
|
||||||
|
notificationAccount?: string;
|
||||||
permission: TeamPermission;
|
permission: TeamPermission;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -72,7 +75,6 @@ export type TeamMemberItemType = {
|
|||||||
teamId: string;
|
teamId: string;
|
||||||
memberName: string;
|
memberName: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
// TODO: this should be deprecated.
|
|
||||||
role: `${TeamMemberRoleEnum}`;
|
role: `${TeamMemberRoleEnum}`;
|
||||||
status: `${TeamMemberStatusEnum}`;
|
status: `${TeamMemberStatusEnum}`;
|
||||||
permission: TeamPermission;
|
permission: TeamPermission;
|
||||||
|
|||||||
6
packages/global/support/user/type.d.ts
vendored
@@ -1,12 +1,10 @@
|
|||||||
|
import { TeamPermission } from '../permission/user/controller';
|
||||||
import { UserStatusEnum } from './constant';
|
import { UserStatusEnum } from './constant';
|
||||||
import { TeamTmbItemType } from './team/type';
|
import { TeamTmbItemType } from './team/type';
|
||||||
|
|
||||||
export type UserModelSchema = {
|
export type UserModelSchema = {
|
||||||
_id: string;
|
_id: string;
|
||||||
username: string;
|
username: string;
|
||||||
email?: string;
|
|
||||||
phonePrefix?: number;
|
|
||||||
phone?: string;
|
|
||||||
password: string;
|
password: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
promotionRate: number;
|
promotionRate: number;
|
||||||
@@ -31,4 +29,6 @@ export type UserType = {
|
|||||||
openaiAccount: UserModelSchema['openaiAccount'];
|
openaiAccount: UserModelSchema['openaiAccount'];
|
||||||
team: TeamTmbItemType;
|
team: TeamTmbItemType;
|
||||||
standardInfo?: standardInfoType;
|
standardInfo?: standardInfoType;
|
||||||
|
notificationAccount?: string;
|
||||||
|
permission: TeamPermission;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
import { i18nT } from '../../../../web/i18n/utils';
|
||||||
|
|
||||||
export enum UsageSourceEnum {
|
export enum UsageSourceEnum {
|
||||||
fastgpt = 'fastgpt',
|
fastgpt = 'fastgpt',
|
||||||
api = 'api',
|
api = 'api',
|
||||||
shareLink = 'shareLink',
|
shareLink = 'shareLink',
|
||||||
training = 'training'
|
training = 'training',
|
||||||
|
cronJob = 'cronJob'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UsageSourceMap = {
|
export const UsageSourceMap = {
|
||||||
@@ -17,5 +20,8 @@ export const UsageSourceMap = {
|
|||||||
},
|
},
|
||||||
[UsageSourceEnum.training]: {
|
[UsageSourceEnum.training]: {
|
||||||
label: 'dataset.Training Name'
|
label: 'dataset.Training Name'
|
||||||
|
},
|
||||||
|
[UsageSourceEnum.cronJob]: {
|
||||||
|
label: i18nT('common:cron_job_run_app')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"duck-duck-scrape": "^2.2.5",
|
"duck-duck-scrape": "^2.2.5",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"axios": "^1.5.1",
|
||||||
"expr-eval": "^2.0.2"
|
"expr-eval": "^2.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -4,10 +4,19 @@ import { FastGPTProUrl, isProduction } from '../service/common/system/constants'
|
|||||||
import { GET, POST } from '@fastgpt/service/common/api/plusRequest';
|
import { GET, POST } from '@fastgpt/service/common/api/plusRequest';
|
||||||
import { SystemPluginTemplateItemType } from '@fastgpt/global/core/workflow/type';
|
import { SystemPluginTemplateItemType } from '@fastgpt/global/core/workflow/type';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
|
import { WorkerNameEnum, runWorker } from '@fastgpt/service/worker/utils';
|
||||||
|
|
||||||
let list = [
|
// Run in main thread
|
||||||
|
const staticPluginList = [
|
||||||
'getTime',
|
'getTime',
|
||||||
'fetchUrl',
|
'fetchUrl',
|
||||||
|
'Doc2X',
|
||||||
|
'Doc2X/URLPDF2text',
|
||||||
|
'Doc2X/URLImg2text',
|
||||||
|
'feishu'
|
||||||
|
];
|
||||||
|
// Run in worker thread (Have npm packages)
|
||||||
|
const packagePluginList = [
|
||||||
'mathExprVal',
|
'mathExprVal',
|
||||||
'duckduckgo',
|
'duckduckgo',
|
||||||
'duckduckgo/search',
|
'duckduckgo/search',
|
||||||
@@ -16,6 +25,8 @@ let list = [
|
|||||||
'duckduckgo/searchVideo'
|
'duckduckgo/searchVideo'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const list = [...staticPluginList, ...packagePluginList];
|
||||||
|
|
||||||
/* Get plugins */
|
/* Get plugins */
|
||||||
export const getCommunityPlugins = () => {
|
export const getCommunityPlugins = () => {
|
||||||
return list.map<SystemPluginTemplateItemType>((name) => {
|
return list.map<SystemPluginTemplateItemType>((name) => {
|
||||||
@@ -58,8 +69,7 @@ export const getSystemPluginTemplates = async (refresh = false) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getCommunityCb = async () => {
|
export const getCommunityCb = async () => {
|
||||||
// Do not modify the following code
|
const loadCommunityModule = async (name: string) => {
|
||||||
const loadModule = async (name: string) => {
|
|
||||||
const module = await import(`./src/${name}/index`);
|
const module = await import(`./src/${name}/index`);
|
||||||
return module.default;
|
return module.default;
|
||||||
};
|
};
|
||||||
@@ -70,7 +80,14 @@ export const getCommunityCb = async () => {
|
|||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
cb: await loadModule(name)
|
cb: staticPluginList.includes(name)
|
||||||
|
? await loadCommunityModule(name)
|
||||||
|
: (e: any) => {
|
||||||
|
return runWorker(WorkerNameEnum.systemPluginRun, {
|
||||||
|
pluginName: name,
|
||||||
|
data: e
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
})
|
})
|
||||||
|
|||||||
24
packages/plugins/runtime/worker.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { SystemPluginResponseType } from '../type';
|
||||||
|
import { parentPort } from 'worker_threads';
|
||||||
|
|
||||||
|
const loadModule = async (name: string): Promise<(e: any) => SystemPluginResponseType> => {
|
||||||
|
const module = await import(`../src/${name}/index`);
|
||||||
|
return module.default;
|
||||||
|
};
|
||||||
|
|
||||||
|
parentPort?.on('message', async ({ pluginName, data }: { pluginName: string; data: any }) => {
|
||||||
|
try {
|
||||||
|
const cb = await loadModule(pluginName);
|
||||||
|
parentPort?.postMessage({
|
||||||
|
type: 'success',
|
||||||
|
data: await cb(data)
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
parentPort?.postMessage({
|
||||||
|
type: 'error',
|
||||||
|
data: error
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
158
packages/plugins/src/Doc2X/URLImg2text/index.ts
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
import { delay } from '@fastgpt/global/common/system/utils';
|
||||||
|
import { addLog } from '@fastgpt/service/common/system/log';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
apikey: string;
|
||||||
|
url: string;
|
||||||
|
img_correction: boolean;
|
||||||
|
formula: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Response type same as HTTP outputs
|
||||||
|
type Response = Promise<{
|
||||||
|
result: string;
|
||||||
|
success: boolean;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
const main = async ({ apikey, url, img_correction, formula }: Props): Response => {
|
||||||
|
// Check the apikey
|
||||||
|
if (!apikey) {
|
||||||
|
return {
|
||||||
|
result: `API key is required`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let real_api_key = apikey;
|
||||||
|
if (!apikey.startsWith('sk-')) {
|
||||||
|
const response = await fetch('https://api.doc2x.noedgeai.com/api/token/refresh', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apikey}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (response.status !== 200) {
|
||||||
|
return {
|
||||||
|
result: `Get token failed: ${await response.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
real_api_key = data.data.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the image binary from the URL
|
||||||
|
const extension = url.split('.').pop()?.toLowerCase();
|
||||||
|
const name = url.split('/').pop()?.split('.').shift();
|
||||||
|
let mini = '';
|
||||||
|
switch (extension) {
|
||||||
|
case 'jpg':
|
||||||
|
case 'jpeg':
|
||||||
|
mini = 'image/jpeg';
|
||||||
|
break;
|
||||||
|
case 'png':
|
||||||
|
mini = 'image/png';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
result: `Not supported image format, only support jpg/jpeg/png`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
return {
|
||||||
|
result: `Failed to fetch image from URL: ${url}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const blob = await response.blob();
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', new Blob([blob], { type: mini }), name + '.' + extension);
|
||||||
|
formData.append('img_correction', img_correction ? '1' : '0');
|
||||||
|
formData.append('equation', formula ? '1' : '0');
|
||||||
|
|
||||||
|
let upload_url = 'https://api.doc2x.noedgeai.com/api/platform/async/img';
|
||||||
|
if (real_api_key.startsWith('sk-')) {
|
||||||
|
upload_url = 'https://api.doc2x.noedgeai.com/api/v1/async/img';
|
||||||
|
}
|
||||||
|
|
||||||
|
let uuid;
|
||||||
|
const uploadAttempts = [1, 2, 3];
|
||||||
|
for await (const attempt of uploadAttempts) {
|
||||||
|
const upload_response = await fetch(upload_url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${real_api_key}`
|
||||||
|
},
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!upload_response.ok) {
|
||||||
|
// Rate limit, wait for 10s and retry at most 3 times
|
||||||
|
if (upload_response.status === 429 && attempt < 3) {
|
||||||
|
await delay(10000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
result: `Failed to upload image: ${await upload_response.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const upload_data = await upload_response.json();
|
||||||
|
uuid = upload_data.data.uuid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the result by uuid
|
||||||
|
let result_url = 'https://api.doc2x.noedgeai.com/api/platform/async/status?uuid=' + uuid;
|
||||||
|
if (real_api_key.startsWith('sk-')) {
|
||||||
|
result_url = 'https://api.doc2x.noedgeai.com/api/v1/async/status?uuid=' + uuid;
|
||||||
|
}
|
||||||
|
const maxAttempts = 100;
|
||||||
|
// Wait for the result, at most 100s
|
||||||
|
for await (const _ of Array(maxAttempts).keys()) {
|
||||||
|
const result_response = await fetch(result_url, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${real_api_key}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!result_response.ok) {
|
||||||
|
return {
|
||||||
|
result: `Failed to get result: ${await result_response.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const result_data = await result_response.json();
|
||||||
|
if (['ready', 'processing'].includes(result_data.data.status)) {
|
||||||
|
await delay(1000);
|
||||||
|
} else if (result_data.data.status === 'pages limit exceeded') {
|
||||||
|
return {
|
||||||
|
result: 'Doc2X Pages limit exceeded',
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
} else if (result_data.data.status === 'success') {
|
||||||
|
let result = result_data.data.result.pages[0].md;
|
||||||
|
result = result.replace(/\\[\(\)]/g, '$').replace(/\\[\[\]]/g, '$$');
|
||||||
|
return {
|
||||||
|
result: result,
|
||||||
|
success: true
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
result: `Failed to get result: ${await result_data.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
result: 'Timeout waiting for result',
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default main;
|
||||||
421
packages/plugins/src/Doc2X/URLImg2text/template.json
Normal file
@@ -0,0 +1,421 @@
|
|||||||
|
{
|
||||||
|
"author": "Menghuan1918",
|
||||||
|
"version": "488",
|
||||||
|
"name": "Doc2X 图像(URL)识别",
|
||||||
|
"avatar": "plugins/doc2x",
|
||||||
|
"intro": "将传入的图片(URL)发送至Doc2X进行解析,返回带LaTeX公式的markdown格式的文本",
|
||||||
|
"inputExplanationUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
|
||||||
|
"showStatus": true,
|
||||||
|
"weight": 10,
|
||||||
|
|
||||||
|
"isTool": true,
|
||||||
|
"templateType": "tools",
|
||||||
|
|
||||||
|
"workflow": {
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"nodeId": "pluginInput",
|
||||||
|
"name": "自定义插件输入",
|
||||||
|
"intro": "可以配置插件需要哪些输入,利用这些输入来运行插件",
|
||||||
|
"avatar": "core/workflow/template/workflowStart",
|
||||||
|
"flowNodeType": "pluginInput",
|
||||||
|
"showStatus": false,
|
||||||
|
"position": {
|
||||||
|
"x": 388.243055058894,
|
||||||
|
"y": -75.09744210499466
|
||||||
|
},
|
||||||
|
"version": "481",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"renderTypeList": ["input"],
|
||||||
|
"selectedTypeIndex": 0,
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "apikey",
|
||||||
|
"label": "apikey",
|
||||||
|
"description": "Doc2X的验证密匙,对于个人用户可以从Doc2X官网 - 个人信息 - 身份令牌获得",
|
||||||
|
"required": true,
|
||||||
|
"toolDescription": "",
|
||||||
|
"defaultValue": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"selectedTypeIndex": 0,
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "url",
|
||||||
|
"label": "url",
|
||||||
|
"description": "待处理图片的URL",
|
||||||
|
"required": true,
|
||||||
|
"toolDescription": "待处理图片的URL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["switch"],
|
||||||
|
"selectedTypeIndex": 0,
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "img_correction",
|
||||||
|
"label": "img_correction",
|
||||||
|
"description": "是否启用图形矫正功能",
|
||||||
|
"required": true,
|
||||||
|
"toolDescription": "",
|
||||||
|
"defaultValue": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["switch"],
|
||||||
|
"selectedTypeIndex": 0,
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "formula",
|
||||||
|
"label": "formula",
|
||||||
|
"description": "是否开启纯公式识别(仅适用于图片内容仅有公式时)",
|
||||||
|
"required": true,
|
||||||
|
"toolDescription": "",
|
||||||
|
"defaultValue": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"id": "apikey",
|
||||||
|
"valueType": "string",
|
||||||
|
"key": "apikey",
|
||||||
|
"label": "apikey",
|
||||||
|
"type": "hidden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "url",
|
||||||
|
"valueType": "string",
|
||||||
|
"key": "url",
|
||||||
|
"label": "url",
|
||||||
|
"type": "hidden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "img_correction",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"key": "img_correction",
|
||||||
|
"label": "img_correction",
|
||||||
|
"type": "hidden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "formula",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"key": "formula",
|
||||||
|
"label": "formula",
|
||||||
|
"type": "hidden"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nodeId": "pluginOutput",
|
||||||
|
"name": "自定义插件输出",
|
||||||
|
"intro": "自定义配置外部输出,使用插件时,仅暴露自定义配置的输出",
|
||||||
|
"avatar": "core/workflow/template/pluginOutput",
|
||||||
|
"flowNodeType": "pluginOutput",
|
||||||
|
"showStatus": false,
|
||||||
|
"position": {
|
||||||
|
"x": 1654.8021754314786,
|
||||||
|
"y": -22.243376051504086
|
||||||
|
},
|
||||||
|
"version": "481",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "result",
|
||||||
|
"label": "result",
|
||||||
|
"description": "处理结果(或者是报错信息)",
|
||||||
|
"value": ["zHG5jJBkXmjB", "xWQuEf50F3mr"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "success",
|
||||||
|
"label": "success",
|
||||||
|
"description": "是否处理成功",
|
||||||
|
"value": ["zHG5jJBkXmjB", "m6CJJj7GFud5"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nodeId": "zHG5jJBkXmjB",
|
||||||
|
"name": "HTTP 请求",
|
||||||
|
"intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
|
||||||
|
"avatar": "core/workflow/template/httpRequest",
|
||||||
|
"flowNodeType": "httpRequest468",
|
||||||
|
"showStatus": true,
|
||||||
|
"position": {
|
||||||
|
"x": 1081.967607938733,
|
||||||
|
"y": -426.08028677656125
|
||||||
|
},
|
||||||
|
"version": "481",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"key": "system_addInputParam",
|
||||||
|
"renderTypeList": ["addInputParam"],
|
||||||
|
"valueType": "dynamic",
|
||||||
|
"label": "",
|
||||||
|
"required": false,
|
||||||
|
"description": "core.module.input.description.HTTP Dynamic Input",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpMethod",
|
||||||
|
"renderTypeList": ["custom"],
|
||||||
|
"valueType": "string",
|
||||||
|
"label": "",
|
||||||
|
"value": "POST",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpReqUrl",
|
||||||
|
"renderTypeList": ["hidden"],
|
||||||
|
"valueType": "string",
|
||||||
|
"label": "",
|
||||||
|
"description": "core.module.input.description.Http Request Url",
|
||||||
|
"placeholder": "https://api.ai.com/getInventory",
|
||||||
|
"required": false,
|
||||||
|
"value": "Doc2X/URLImg2text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpHeader",
|
||||||
|
"renderTypeList": ["custom"],
|
||||||
|
"valueType": "any",
|
||||||
|
"value": [],
|
||||||
|
"label": "",
|
||||||
|
"description": "core.module.input.description.Http Request Header",
|
||||||
|
"placeholder": "core.module.input.description.Http Request Header",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpParams",
|
||||||
|
"renderTypeList": ["hidden"],
|
||||||
|
"valueType": "any",
|
||||||
|
"value": [],
|
||||||
|
"label": "",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpJsonBody",
|
||||||
|
"renderTypeList": ["hidden"],
|
||||||
|
"valueType": "any",
|
||||||
|
"value": "{\n \"apikey\": \"{{apikey}}\",\n \"url\": \"{{url}}\",\n \"img_correction\": \"{{img_correction}}\",\n \"formula\": \"{{img_correction}}\"\n}",
|
||||||
|
"label": "",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "apikey",
|
||||||
|
"label": "apikey",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"value": ["pluginInput", "apikey"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "url",
|
||||||
|
"label": "url",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"value": ["pluginInput", "url"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "img_correction",
|
||||||
|
"label": "img_correction",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"value": ["pluginInput", "img_correction"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "formula",
|
||||||
|
"label": "formula",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"value": ["pluginInput", "formula"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"id": "error",
|
||||||
|
"key": "error",
|
||||||
|
"label": "请求错误",
|
||||||
|
"description": "HTTP请求错误信息,成功时返回空",
|
||||||
|
"valueType": "object",
|
||||||
|
"type": "static"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "httpRawResponse",
|
||||||
|
"key": "httpRawResponse",
|
||||||
|
"label": "原始响应",
|
||||||
|
"required": true,
|
||||||
|
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
|
||||||
|
"valueType": "any",
|
||||||
|
"type": "static"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "system_addOutputParam",
|
||||||
|
"key": "system_addOutputParam",
|
||||||
|
"type": "dynamic",
|
||||||
|
"valueType": "dynamic",
|
||||||
|
"label": "",
|
||||||
|
"customFieldConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "xWQuEf50F3mr",
|
||||||
|
"valueType": "string",
|
||||||
|
"type": "dynamic",
|
||||||
|
"key": "result",
|
||||||
|
"label": "result"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "m6CJJj7GFud5",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"type": "dynamic",
|
||||||
|
"key": "success",
|
||||||
|
"label": "success"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"source": "pluginInput",
|
||||||
|
"target": "zHG5jJBkXmjB",
|
||||||
|
"sourceHandle": "pluginInput-source-right",
|
||||||
|
"targetHandle": "zHG5jJBkXmjB-target-left"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "zHG5jJBkXmjB",
|
||||||
|
"target": "pluginOutput",
|
||||||
|
"sourceHandle": "zHG5jJBkXmjB-source-right",
|
||||||
|
"targetHandle": "pluginOutput-target-left"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
130
packages/plugins/src/Doc2X/URLPDF2text/index.ts
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
import { delay } from '@fastgpt/global/common/system/utils';
|
||||||
|
import { addLog } from '@fastgpt/service/common/system/log';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
apikey: string;
|
||||||
|
url: string;
|
||||||
|
ocr: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Response type same as HTTP outputs
|
||||||
|
type Response = Promise<{
|
||||||
|
result: string;
|
||||||
|
success: boolean;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
const main = async ({ apikey, url, ocr }: Props): Response => {
|
||||||
|
// Check the apikey
|
||||||
|
if (!apikey) {
|
||||||
|
return {
|
||||||
|
result: `API key is required`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let real_api_key = apikey;
|
||||||
|
if (!apikey.startsWith('sk-')) {
|
||||||
|
const response = await fetch('https://api.doc2x.noedgeai.com/api/token/refresh', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apikey}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (response.status !== 200) {
|
||||||
|
return {
|
||||||
|
result: `Get token failed: ${await response.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
real_api_key = data.data.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get the image binary from the URL
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('pdf_url', url);
|
||||||
|
formData.append('ocr', ocr ? '1' : '0');
|
||||||
|
|
||||||
|
let upload_url = 'https://api.doc2x.noedgeai.com/api/platform/async/pdf';
|
||||||
|
if (real_api_key.startsWith('sk-')) {
|
||||||
|
upload_url = 'https://api.doc2x.noedgeai.com/api/v1/async/pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
let uuid;
|
||||||
|
const uploadAttempts = [1, 2, 3];
|
||||||
|
for await (const attempt of uploadAttempts) {
|
||||||
|
const upload_response = await fetch(upload_url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${real_api_key}`
|
||||||
|
},
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
if (!upload_response.ok) {
|
||||||
|
if (upload_response.status === 429 && attempt < 3) {
|
||||||
|
await delay(10000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
result: `Failed to upload file: ${await upload_response.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const upload_data = await upload_response.json();
|
||||||
|
uuid = upload_data.data.uuid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the result by uuid
|
||||||
|
let result_url = 'https://api.doc2x.noedgeai.com/api/platform/async/status?uuid=' + uuid;
|
||||||
|
if (real_api_key.startsWith('sk-')) {
|
||||||
|
result_url = 'https://api.doc2x.noedgeai.com/api/v1/async/status?uuid=' + uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = '';
|
||||||
|
// Wait for the result, at most 100s
|
||||||
|
const maxAttempts = 100;
|
||||||
|
for await (const _ of Array(maxAttempts).keys()) {
|
||||||
|
const result_response = await fetch(result_url, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${real_api_key}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!result_response.ok) {
|
||||||
|
return {
|
||||||
|
result: `Failed to get result: ${await result_response.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const result_data = await result_response.json();
|
||||||
|
if (['ready', 'processing'].includes(result_data.data.status)) {
|
||||||
|
await delay(1000);
|
||||||
|
} else if (result_data.data.status === 'pages limit exceeded') {
|
||||||
|
return {
|
||||||
|
result: 'Doc2X Pages limit exceeded',
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
} else if (result_data.data.status === 'success') {
|
||||||
|
result = await Promise.all(
|
||||||
|
result_data.data.result.pages.map((page: { md: any }) => page.md)
|
||||||
|
).then((pages) => pages.join('\n'));
|
||||||
|
result = result.replace(/\\[\(\)]/g, '$').replace(/\\[\[\]]/g, '$$');
|
||||||
|
return {
|
||||||
|
result: result,
|
||||||
|
success: true
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
result: `Failed to get result: ${await result_data.text()}`,
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
result: 'Timeout waiting for result',
|
||||||
|
success: false
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default main;
|
||||||
373
packages/plugins/src/Doc2X/URLPDF2text/template.json
Normal file
@@ -0,0 +1,373 @@
|
|||||||
|
{
|
||||||
|
"author": "Menghuan1918",
|
||||||
|
"version": "488",
|
||||||
|
"name": "Doc2X PDF文件(URL)识别",
|
||||||
|
"avatar": "plugins/doc2x",
|
||||||
|
"intro": "将传入的PDF文件(URL)发送至Doc2X进行解析,返回带LaTeX公式的markdown格式的文本",
|
||||||
|
"inputExplanationUrl": "https://fael3z0zfze.feishu.cn/wiki/Rkc5witXWiJoi5kORd2cofh6nDg?fromScene=spaceOverview",
|
||||||
|
"showStatus": true,
|
||||||
|
"weight": 10,
|
||||||
|
|
||||||
|
"isTool": true,
|
||||||
|
"templateType": "tools",
|
||||||
|
|
||||||
|
"workflow": {
|
||||||
|
"nodes": [
|
||||||
|
{
|
||||||
|
"nodeId": "pluginInput",
|
||||||
|
"name": "自定义插件输入",
|
||||||
|
"intro": "可以配置插件需要哪些输入,利用这些输入来运行插件",
|
||||||
|
"avatar": "core/workflow/template/workflowStart",
|
||||||
|
"flowNodeType": "pluginInput",
|
||||||
|
"showStatus": false,
|
||||||
|
"position": {
|
||||||
|
"x": 388.243055058894,
|
||||||
|
"y": -75.09744210499466
|
||||||
|
},
|
||||||
|
"version": "481",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"renderTypeList": ["input"],
|
||||||
|
"selectedTypeIndex": 0,
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "apikey",
|
||||||
|
"label": "apikey",
|
||||||
|
"description": "Doc2X的验证密匙,对于个人用户可以从Doc2X官网 - 个人信息 - 身份令牌获得",
|
||||||
|
"required": true,
|
||||||
|
"toolDescription": "",
|
||||||
|
"defaultValue": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"selectedTypeIndex": 0,
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "url",
|
||||||
|
"label": "url",
|
||||||
|
"description": "待处理PDF文件的URL",
|
||||||
|
"required": true,
|
||||||
|
"toolDescription": "待处理PDF文件的URL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["switch"],
|
||||||
|
"selectedTypeIndex": 0,
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "ocr",
|
||||||
|
"label": "ocr",
|
||||||
|
"description": "是否开启对PDF文件内图片的OCR识别,建议开启",
|
||||||
|
"required": true,
|
||||||
|
"toolDescription": "",
|
||||||
|
"defaultValue": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"id": "apikey",
|
||||||
|
"valueType": "string",
|
||||||
|
"key": "apikey",
|
||||||
|
"label": "apikey",
|
||||||
|
"type": "hidden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "url",
|
||||||
|
"valueType": "string",
|
||||||
|
"key": "url",
|
||||||
|
"label": "url",
|
||||||
|
"type": "hidden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "formula",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"key": "ocr",
|
||||||
|
"label": "ocr",
|
||||||
|
"type": "hidden"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nodeId": "pluginOutput",
|
||||||
|
"name": "自定义插件输出",
|
||||||
|
"intro": "自定义配置外部输出,使用插件时,仅暴露自定义配置的输出",
|
||||||
|
"avatar": "core/workflow/template/pluginOutput",
|
||||||
|
"flowNodeType": "pluginOutput",
|
||||||
|
"showStatus": false,
|
||||||
|
"position": {
|
||||||
|
"x": 1654.8021754314786,
|
||||||
|
"y": -22.243376051504086
|
||||||
|
},
|
||||||
|
"version": "481",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "result",
|
||||||
|
"label": "result",
|
||||||
|
"description": "处理结果(或者是报错信息)",
|
||||||
|
"value": ["zHG5jJBkXmjB", "xWQuEf50F3mr"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "success",
|
||||||
|
"label": "success",
|
||||||
|
"description": "是否处理成功",
|
||||||
|
"value": ["zHG5jJBkXmjB", "m6CJJj7GFud5"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"nodeId": "zHG5jJBkXmjB",
|
||||||
|
"name": "HTTP 请求",
|
||||||
|
"intro": "可以发出一个 HTTP 请求,实现更为复杂的操作(联网搜索、数据库查询等)",
|
||||||
|
"avatar": "core/workflow/template/httpRequest",
|
||||||
|
"flowNodeType": "httpRequest468",
|
||||||
|
"showStatus": true,
|
||||||
|
"position": {
|
||||||
|
"x": 1081.967607938733,
|
||||||
|
"y": -426.08028677656125
|
||||||
|
},
|
||||||
|
"version": "481",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"key": "system_addInputParam",
|
||||||
|
"renderTypeList": ["addInputParam"],
|
||||||
|
"valueType": "dynamic",
|
||||||
|
"label": "",
|
||||||
|
"required": false,
|
||||||
|
"description": "core.module.input.description.HTTP Dynamic Input",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpMethod",
|
||||||
|
"renderTypeList": ["custom"],
|
||||||
|
"valueType": "string",
|
||||||
|
"label": "",
|
||||||
|
"value": "POST",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpReqUrl",
|
||||||
|
"renderTypeList": ["hidden"],
|
||||||
|
"valueType": "string",
|
||||||
|
"label": "",
|
||||||
|
"description": "core.module.input.description.Http Request Url",
|
||||||
|
"placeholder": "https://api.ai.com/getInventory",
|
||||||
|
"required": false,
|
||||||
|
"value": "Doc2X/URLPDF2text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpHeader",
|
||||||
|
"renderTypeList": ["custom"],
|
||||||
|
"valueType": "any",
|
||||||
|
"value": [],
|
||||||
|
"label": "",
|
||||||
|
"description": "core.module.input.description.Http Request Header",
|
||||||
|
"placeholder": "core.module.input.description.Http Request Header",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpParams",
|
||||||
|
"renderTypeList": ["hidden"],
|
||||||
|
"valueType": "any",
|
||||||
|
"value": [],
|
||||||
|
"label": "",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "system_httpJsonBody",
|
||||||
|
"renderTypeList": ["hidden"],
|
||||||
|
"valueType": "any",
|
||||||
|
"value": "{\n \"apikey\": \"{{apikey}}\",\n \"url\": \"{{url}}\",\n \"ocr\": \"{{ocr}}\"\n}",
|
||||||
|
"label": "",
|
||||||
|
"required": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "apikey",
|
||||||
|
"label": "apikey",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"value": ["pluginInput", "apikey"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "string",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "url",
|
||||||
|
"label": "url",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"value": ["pluginInput", "url"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"renderTypeList": ["reference"],
|
||||||
|
"valueType": "boolean",
|
||||||
|
"canEdit": true,
|
||||||
|
"key": "ocr",
|
||||||
|
"label": "ocr",
|
||||||
|
"customInputConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": true
|
||||||
|
},
|
||||||
|
"required": true,
|
||||||
|
"value": ["pluginInput", "formula"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"id": "error",
|
||||||
|
"key": "error",
|
||||||
|
"label": "请求错误",
|
||||||
|
"description": "HTTP请求错误信息,成功时返回空",
|
||||||
|
"valueType": "object",
|
||||||
|
"type": "static"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "httpRawResponse",
|
||||||
|
"key": "httpRawResponse",
|
||||||
|
"label": "原始响应",
|
||||||
|
"required": true,
|
||||||
|
"description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
|
||||||
|
"valueType": "any",
|
||||||
|
"type": "static"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "system_addOutputParam",
|
||||||
|
"key": "system_addOutputParam",
|
||||||
|
"type": "dynamic",
|
||||||
|
"valueType": "dynamic",
|
||||||
|
"label": "",
|
||||||
|
"customFieldConfig": {
|
||||||
|
"selectValueTypeList": [
|
||||||
|
"string",
|
||||||
|
"number",
|
||||||
|
"boolean",
|
||||||
|
"object",
|
||||||
|
"arrayString",
|
||||||
|
"arrayNumber",
|
||||||
|
"arrayBoolean",
|
||||||
|
"arrayObject",
|
||||||
|
"any",
|
||||||
|
"chatHistory",
|
||||||
|
"datasetQuote",
|
||||||
|
"dynamic",
|
||||||
|
"selectApp",
|
||||||
|
"selectDataset"
|
||||||
|
],
|
||||||
|
"showDescription": false,
|
||||||
|
"showDefaultValue": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "xWQuEf50F3mr",
|
||||||
|
"valueType": "string",
|
||||||
|
"type": "dynamic",
|
||||||
|
"key": "result",
|
||||||
|
"label": "result"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "m6CJJj7GFud5",
|
||||||
|
"valueType": "boolean",
|
||||||
|
"type": "dynamic",
|
||||||
|
"key": "success",
|
||||||
|
"label": "success"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"edges": [
|
||||||
|
{
|
||||||
|
"source": "pluginInput",
|
||||||
|
"target": "zHG5jJBkXmjB",
|
||||||
|
"sourceHandle": "pluginInput-source-right",
|
||||||
|
"targetHandle": "zHG5jJBkXmjB-target-left"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "zHG5jJBkXmjB",
|
||||||
|
"target": "pluginOutput",
|
||||||
|
"sourceHandle": "zHG5jJBkXmjB-source-right",
|
||||||
|
"targetHandle": "pluginOutput-target-left"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
17
packages/plugins/src/Doc2X/template.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"author": "Menghuan1918",
|
||||||
|
"version": "488",
|
||||||
|
"name": "Doc2X服务",
|
||||||
|
"avatar": "plugins/doc2x",
|
||||||
|
"intro": "传入的URL形式的图片或PDF文件发送至Doc2X进行解析,返回带LaTeX公式的markdown格式的文本。",
|
||||||
|
"showStatus": true,
|
||||||
|
"weight": 10,
|
||||||
|
|
||||||
|
"isTool": true,
|
||||||
|
"templateType": "tools",
|
||||||
|
|
||||||
|
"workflow": {
|
||||||
|
"nodes": [],
|
||||||
|
"edges": []
|
||||||
|
}
|
||||||
|
}
|
||||||