Compare commits
21 Commits
v4.8.10
...
v4.8.10-fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02bf400bf3 | ||
|
|
11cbcca2d4 | ||
|
|
34422f9549 | ||
|
|
aeba79267a | ||
|
|
7473be5922 | ||
|
|
de59b3d2e5 | ||
|
|
08190c2f0d | ||
|
|
6a85c8c2b6 | ||
|
|
bbdab1d40e | ||
|
|
78ad2791cd | ||
|
|
5f3c8e9046 | ||
|
|
30057f01a6 | ||
|
|
3ea185315d | ||
|
|
a1ae08f62b | ||
|
|
91ec895fd2 | ||
|
|
1a33642635 | ||
|
|
e9681c8ed5 | ||
|
|
69ff65973f | ||
|
|
52ac445557 | ||
|
|
d45cb2f84a | ||
|
|
1cb71c6bfb |
BIN
.github/imgs/intro1.png
vendored
|
Before Width: | Height: | Size: 259 KiB After Width: | Height: | Size: 173 KiB |
BIN
.github/imgs/intro2.png
vendored
|
Before Width: | Height: | Size: 371 KiB After Width: | Height: | Size: 273 KiB |
BIN
.github/imgs/intro3.png
vendored
|
Before Width: | Height: | Size: 259 KiB After Width: | Height: | Size: 168 KiB |
BIN
.github/imgs/intro4.png
vendored
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 159 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 98 KiB |
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 127 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 68 KiB |
|
Before Width: | Height: | Size: 170 KiB After Width: | Height: | Size: 147 KiB |
|
Before Width: | Height: | Size: 161 KiB After Width: | Height: | Size: 134 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 215 KiB After Width: | Height: | Size: 147 KiB |
|
Before Width: | Height: | Size: 179 KiB After Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 299 KiB After Width: | Height: | Size: 298 KiB |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 163 KiB After Width: | Height: | Size: 146 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 141 KiB |
|
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 114 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 209 KiB After Width: | Height: | Size: 119 KiB |
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: 'V4.8.10(进行中)'
|
title: 'V4.8.10'
|
||||||
description: 'FastGPT V4.8.10 更新说明'
|
description: 'FastGPT V4.8.10 更新说明'
|
||||||
icon: 'upgrade'
|
icon: 'upgrade'
|
||||||
draft: false
|
draft: false
|
||||||
@@ -24,8 +24,8 @@ STORE_LOG_LEVEL=warn
|
|||||||
|
|
||||||
### 3. 修改镜像tag
|
### 3. 修改镜像tag
|
||||||
|
|
||||||
- 更新 FastGPT 镜像 tag: v4.8.10-alpha
|
- 更新 FastGPT 镜像 tag: v4.8.10-fix
|
||||||
- 更新 FastGPT 商业版镜像 tag: v4.8.10-alpha
|
- 更新 FastGPT 商业版镜像 tag: v4.8.10-fix
|
||||||
- Sandbox 镜像,可以不更新
|
- Sandbox 镜像,可以不更新
|
||||||
|
|
||||||
## 4. 执行初始化
|
## 4. 执行初始化
|
||||||
@@ -45,46 +45,60 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4810' \
|
|||||||
|
|
||||||
## V4.8.10 更新说明
|
## V4.8.10 更新说明
|
||||||
|
|
||||||
完整内容请见:[4.8.10 release](https://github.com/labring/FastGPT/releases/tag/v4.8.10-alpha)
|
完整内容请见:[4.8.10 release](https://github.com/labring/FastGPT/releases/tag/v4.8.10)
|
||||||
|
|
||||||
1. 新增 - 模板市场
|
1. 新增 - 模板市场。
|
||||||
2. 新增 - 工作流节点拖动自动对齐吸附
|
2. 新增 - 工作流节点拖动自动对齐吸附。
|
||||||
3. 新增 - 用户选择节点(Debug 模式暂未支持)
|
3. 新增 - 用户选择节点(Debug 模式暂未支持)。
|
||||||
4. 新增 - 工作流撤销和重做
|
4. 新增 - 工作流增加 uid 全局变量。
|
||||||
5. 新增 - 工作流本次编辑记录,取代自动保存
|
5. 新增 - 工作流撤销和重做。
|
||||||
6. 新增 - 工作流版本支持重命名
|
6. 新增 - 工作流本次编辑记录,取代自动保存。
|
||||||
7. 新增 - 应用调用迁移成单独节点,同时可以传递全局变量和用户的文件。
|
7. 新增 - 工作流版本支持重命名。
|
||||||
8. 新增 - 插件增加使用说明配置。
|
8. 新增 - 工作流的“应用调用”节点弃用,迁移成单独节点,与插件使用方式相同,同时可以传递全局变量和用户上传的文件。
|
||||||
9. 新增 - 工作流导出导入,支持直接导出和导入 JSON 文件,便于交流。
|
9. 新增 - 插件增加使用说明配置。
|
||||||
10. 新增 - HTTP模块支持超时配置、支持更多的 Body 类型,params 和 headers 支持新的变量选择模式。
|
10. 新增 - 插件自定义输入支持单选框。
|
||||||
11. 新增 - 发送验证码安全校验。
|
11. 新增 - HTTP 节点支持 text/plain 模式。
|
||||||
12. 商业版新增 - 飞书机器人接入
|
12. 新增 - HTTP模块支持超时配置、支持更多的 Body 类型,params 和 headers 支持新的变量选择模式。
|
||||||
13. 商业版新增 - 公众号接入接入
|
13. 新增 - 工作流导出导入,支持直接导出和导入 JSON 文件,便于交流。
|
||||||
14. 商业版新增 - 自助开票申请
|
14. 新增 - 发送验证码安全校验。
|
||||||
15. 商业版新增 - SSO 定制
|
15. 商业版新增 - 飞书机器人接入。
|
||||||
16. 优化 - 工作流循环校验,避免 skip 循环空转。同时支持分支完全并发执行。
|
16. 商业版新增 - 公众号接入接入。
|
||||||
17. 优化 - SSE 响应优化。
|
17. 商业版新增 - 自助开票申请。
|
||||||
18. 优化 - 无 SSL 证书情况下,优化复制。
|
18. 商业版新增 - SSO 定制。
|
||||||
19. 优化 - 单选框打开后自动滚动到选中的位置。
|
19. 优化 - 工作流循环校验,避免 skip 循环空转。同时支持分支完全并发执行。
|
||||||
20. 优化 - 知识库集合禁用,目录禁用会递归修改其下所有 children 的禁用状态。
|
20. 优化 - 工作流嵌套执行,参数可能存在的污染问题。
|
||||||
21. 优化 - 节点选择,避免切换 tab 时候,path 加载报错。
|
21. 优化 - 部分全局变量,增加数据类型约束。
|
||||||
22. 优化 - 最新 React Markdown 组件,支持 Base64 图片。
|
22. 优化 - 节点选择,避免切换 tab 时候,path 加载报错。
|
||||||
23. 优化 - 知识库列表 UI。
|
23. 优化 - 最新 React Markdown 组件,支持 Base64 图片。
|
||||||
24. 优化 - 知识库详情页 UI。
|
24. 优化 - 对话框性能问题。
|
||||||
25. 优化 - 支持无网络配置情况下运行。
|
25. 优化 - 单选框打开后自动滚动到选中的位置。
|
||||||
26. 优化 - 部分全局变量,增加数据类型约束。
|
26. 优化 - 知识库集合禁用,目录禁用会递归修改其下所有 children 的禁用状态。
|
||||||
27. 优化 - 查看工作流详情,切换 tab 时,自动滚动到顶部。
|
27. 优化 - SSE 响应代码优化。
|
||||||
28. 优化 - 对话框性能问题。
|
28. 优化 - 无 SSL 证书情况下,优化复制。
|
||||||
29. 修复 - 全局变量 key 可能重复。
|
29. 优化 - 知识库列表 UI。
|
||||||
30. 修复 - Prompt 模式调用工具,stream=false 模式下,会携带 0: 开头标记。
|
30. 优化 - 知识库详情页 UI。
|
||||||
31. 修复 - 对话日志鉴权问题:仅为 APP 管理员的用户,无法查看对话日志详情。
|
31. 优化 - 支持无网络配置情况下运行。
|
||||||
32. 修复 - 选择 Milvus 部署时,无法导出知识库。
|
32. 优化 - 调整.env.template关于mongodb的说明,使得更易于理解。
|
||||||
33. 修复 - 创建 APP 副本,无法复制系统配置。
|
33. 优化 - 新的支付模式。
|
||||||
34. 修复 - 图片识别模式下,自动解析图片链接正则不够严谨问题。
|
34. 优化 - 用户默认头像。
|
||||||
35. 修复 - 内容提取的数据类型与输出数据类型未一致。
|
35. 修复 - Prompt 模式调用工具,stream=false 模式下,会携带 0: 开头标记。
|
||||||
36. 修复 - 工作流运行时间统计错误。
|
36. 修复 - 对话日志鉴权问题:仅为 APP 管理员的用户,无法查看对话日志详情。
|
||||||
37. 修复 - stream 模式下,工具调用有可能出现 undefined
|
37. 修复 - 选择 Milvus 部署时,无法导出知识库。
|
||||||
38. 修复 - 全局变量在 API 中无法持久化。
|
38. 修复 - 创建 APP 副本,无法复制系统配置。
|
||||||
39. 修复 - OpenAPI,detail=false模式下,不应该返回 tool 调用结果,仅返回文字。(可解决 cow 不适配问题)
|
39. 修复 - 图片识别模式下,自动解析图片链接正则不够严谨问题。
|
||||||
40. 修复 - 知识库标签重复加载。
|
40. 修复 - 内容提取的数据类型与输出数据类型未一致。
|
||||||
41. 修复 - Debug 模式下,循环调用边问题。
|
41. 修复 - 工作流运行时间统计错误。
|
||||||
|
42. 修复 - stream 模式下,工具调用有可能出现 undefined。
|
||||||
|
43. 修复 - reranker typo。
|
||||||
|
44. 修复 - home host typo。
|
||||||
|
45. 修复 - i18n display。
|
||||||
|
46. 修复 - 全局变量可重复定义 key。
|
||||||
|
47. 修复 - 全局变量在 Debug 模式下不可持久化。
|
||||||
|
48. 修复 - 全局变量在 API 中无法持久化。
|
||||||
|
49. 修复 - OpenAPI,detail=false模式下,不应该返回 tool 调用结果,仅返回文字。(可解决 cow 不适配问题)。
|
||||||
|
50. 修复 - 知识库标签重复加载。
|
||||||
|
51. 修复 - 网络链接重新获取时,自定义分割符不生效。
|
||||||
|
52. 修复 - 插件运行时,会传递额外的全局变量,可能造成插件内变量污染。
|
||||||
|
53. 文档 - qa docs。
|
||||||
|
54. 文档 - Update feishu.md。
|
||||||
|
55. 文档 - update baseURL。
|
||||||
|
|||||||
@@ -16,8 +16,13 @@ weight: 813
|
|||||||
## V4.8.11 更新预告
|
## V4.8.11 更新预告
|
||||||
|
|
||||||
1.
|
1.
|
||||||
2. 新增 - 插件自定义输入支持单选框
|
2. 新增 - 工作流循环执行节点。
|
||||||
3. 新增 - 插件输出,支持指定某些字段为工具调用结果
|
3. 新增 - 工作流用户表单输入节点。
|
||||||
4. 新增 - 插件支持配置使用引导、全局变量和文件输入
|
4. 新增 - 插件输出,支持指定某些字段为工具调用结果。
|
||||||
5. 优化 - SSE 响应代码。
|
5. 新增 - 插件支持配置使用引导、全局变量和文件输入。
|
||||||
6. 优化 - 非 HTTPS 环境下支持复制(除非 textarea 复制也不支持)
|
6. 新增 - 简易模式支持新的版本管理方式。
|
||||||
|
7. 新增 - 聊天记录滚动加载,不再只加载 30 条。
|
||||||
|
8. 优化 - 工作流嵌套层级限制 20 层,避免因编排不合理导致的无限死循环。
|
||||||
|
9. 优化 - 工作流 handler 性能优化。
|
||||||
|
10. 修复 - 知识库选择权限问题。
|
||||||
|
11. 修复 - 空 chatId 发起对话,首轮携带用户选择时会异常。
|
||||||
|
|||||||
0
fastgpt@4.0
Normal file
@@ -10,8 +10,7 @@
|
|||||||
"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",
|
||||||
"i18n:delete-unused-keys": "node ./scripts/i18n/delete-unused-keys.js",
|
"api:gen": "tsc ./scripts/openapi/index.ts && node ./scripts/openapi/index.js && npx @redocly/cli build-docs ./scripts/openapi/openapi.json -o ./projects/app/public/openapi/index.html"
|
||||||
"i18n:query": "node ./scripts/i18n/query.js"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@chakra-ui/cli": "^2.4.1",
|
"@chakra-ui/cli": "^2.4.1",
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ export enum DispatchNodeResponseKeyEnum {
|
|||||||
assistantResponses = 'assistantResponses', // assistant response
|
assistantResponses = 'assistantResponses', // assistant response
|
||||||
rewriteHistories = 'rewriteHistories', // If have the response, workflow histories will be rewrite
|
rewriteHistories = 'rewriteHistories', // If have the response, workflow histories will be rewrite
|
||||||
|
|
||||||
interactive = 'INTERACTIVE' // is interactive
|
interactive = 'INTERACTIVE', // is interactive
|
||||||
|
runTimes = 'runTimes' // run times
|
||||||
}
|
}
|
||||||
|
|
||||||
export const needReplaceReferenceInputTypeList = [
|
export const needReplaceReferenceInputTypeList = [
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export type ChatDispatchProps = {
|
|||||||
maxRunTimes: number;
|
maxRunTimes: number;
|
||||||
isToolCall?: boolean;
|
isToolCall?: boolean;
|
||||||
workflowStreamResponse?: WorkflowResponseType;
|
workflowStreamResponse?: WorkflowResponseType;
|
||||||
|
workflowDispatchDeep?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ModuleDispatchProps<T> = ChatDispatchProps & {
|
export type ModuleDispatchProps<T> = ChatDispatchProps & {
|
||||||
@@ -181,6 +182,7 @@ export type DispatchNodeResultType<T = {}> = {
|
|||||||
[DispatchNodeResponseKeyEnum.toolResponses]?: ToolRunResponseItemType; // Tool response
|
[DispatchNodeResponseKeyEnum.toolResponses]?: ToolRunResponseItemType; // Tool response
|
||||||
[DispatchNodeResponseKeyEnum.assistantResponses]?: AIChatItemValueItemType[]; // Assistant response(Store to db)
|
[DispatchNodeResponseKeyEnum.assistantResponses]?: AIChatItemValueItemType[]; // Assistant response(Store to db)
|
||||||
[DispatchNodeResponseKeyEnum.rewriteHistories]?: ChatItemType[];
|
[DispatchNodeResponseKeyEnum.rewriteHistories]?: ChatItemType[];
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]?: number;
|
||||||
} & T;
|
} & T;
|
||||||
|
|
||||||
/* Single node props */
|
/* Single node props */
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ export const ClassifyQuestionModule: FlowNodeTemplateType = {
|
|||||||
label: '',
|
label: '',
|
||||||
value: [
|
value: [
|
||||||
{
|
{
|
||||||
value: i18nT('workflow:greeting'),
|
value: 'Greeting',
|
||||||
key: 'wqre'
|
key: 'wqre'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: i18nT('workflow:about_xxx_question'),
|
value: 'Question regarding xxx',
|
||||||
key: 'sdfa'
|
key: 'sdfa'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: i18nT('workflow:other_questions'),
|
value: 'Other Questions',
|
||||||
key: 'agex'
|
key: 'agex'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { ClientSession } from '../../../common/mongo';
|
|||||||
import { getLLMModel, getVectorModel } from '../../ai/model';
|
import { getLLMModel, getVectorModel } from '../../ai/model';
|
||||||
import { addLog } from '../../../common/system/log';
|
import { addLog } from '../../../common/system/log';
|
||||||
import { getCollectionWithDataset } from '../controller';
|
import { getCollectionWithDataset } from '../controller';
|
||||||
|
import { mongoSessionRun } from '../../../common/mongo/sessionRun';
|
||||||
|
|
||||||
export const lockTrainingDataByTeamId = async (teamId: string): Promise<any> => {
|
export const lockTrainingDataByTeamId = async (teamId: string): Promise<any> => {
|
||||||
try {
|
try {
|
||||||
@@ -64,7 +65,7 @@ export async function pushDataListToTrainingQueue({
|
|||||||
vectorModel: string;
|
vectorModel: string;
|
||||||
session?: ClientSession;
|
session?: ClientSession;
|
||||||
} & PushDatasetDataProps): Promise<PushDatasetDataResponse> {
|
} & PushDatasetDataProps): Promise<PushDatasetDataResponse> {
|
||||||
const checkModelValid = async () => {
|
const { model, maxToken, weight } = await (async () => {
|
||||||
const agentModelData = getLLMModel(agentModel);
|
const agentModelData = getLLMModel(agentModel);
|
||||||
if (!agentModelData) {
|
if (!agentModelData) {
|
||||||
return Promise.reject(`File model ${agentModel} is inValid`);
|
return Promise.reject(`File model ${agentModel} is inValid`);
|
||||||
@@ -91,9 +92,16 @@ export async function pushDataListToTrainingQueue({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(`Training mode "${trainingMode}" is inValid`);
|
return Promise.reject(`Training mode "${trainingMode}" is inValid`);
|
||||||
};
|
})();
|
||||||
|
|
||||||
const { model, maxToken, weight } = await checkModelValid();
|
// filter repeat or equal content
|
||||||
|
const set = new Set();
|
||||||
|
const filterResult: Record<string, PushDatasetDataChunkProps[]> = {
|
||||||
|
success: [],
|
||||||
|
overToken: [],
|
||||||
|
repeat: [],
|
||||||
|
error: []
|
||||||
|
};
|
||||||
|
|
||||||
// format q and a, remove empty char
|
// format q and a, remove empty char
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
@@ -108,19 +116,8 @@ export async function pushDataListToTrainingQueue({
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
});
|
|
||||||
|
|
||||||
// filter repeat or equal content
|
// filter repeat content
|
||||||
const set = new Set();
|
|
||||||
const filterResult: Record<string, PushDatasetDataChunkProps[]> = {
|
|
||||||
success: [],
|
|
||||||
overToken: [],
|
|
||||||
repeat: [],
|
|
||||||
error: []
|
|
||||||
};
|
|
||||||
|
|
||||||
// filter repeat content
|
|
||||||
data.forEach((item) => {
|
|
||||||
if (!item.q) {
|
if (!item.q) {
|
||||||
filterResult.error.push(item);
|
filterResult.error.push(item);
|
||||||
return;
|
return;
|
||||||
@@ -150,40 +147,55 @@ export async function pushDataListToTrainingQueue({
|
|||||||
const failedDocuments: PushDatasetDataChunkProps[] = [];
|
const failedDocuments: PushDatasetDataChunkProps[] = [];
|
||||||
|
|
||||||
// 使用 insertMany 批量插入
|
// 使用 insertMany 批量插入
|
||||||
try {
|
const batchSize = 200;
|
||||||
await MongoDatasetTraining.insertMany(
|
const insertData = async (startIndex: number, session: ClientSession) => {
|
||||||
filterResult.success.map((item) => ({
|
const list = filterResult.success.slice(startIndex, startIndex + batchSize);
|
||||||
teamId,
|
|
||||||
tmbId,
|
|
||||||
datasetId,
|
|
||||||
collectionId,
|
|
||||||
billId,
|
|
||||||
mode: trainingMode,
|
|
||||||
prompt,
|
|
||||||
model,
|
|
||||||
q: item.q,
|
|
||||||
a: item.a,
|
|
||||||
chunkIndex: item.chunkIndex ?? 0,
|
|
||||||
weight: weight ?? 0,
|
|
||||||
indexes: item.indexes
|
|
||||||
})),
|
|
||||||
{
|
|
||||||
session,
|
|
||||||
ordered: false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} catch (error: any) {
|
|
||||||
addLog.error(`Insert error`, error);
|
|
||||||
// 如果有错误,将失败的文档添加到失败列表中
|
|
||||||
error.writeErrors?.forEach((writeError: any) => {
|
|
||||||
failedDocuments.push(data[writeError.index]);
|
|
||||||
});
|
|
||||||
console.log('failed', failedDocuments);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 对于失败的文档,尝试单独插入
|
if (list.length === 0) return;
|
||||||
for await (const item of failedDocuments) {
|
|
||||||
await MongoDatasetTraining.create(item);
|
try {
|
||||||
|
await MongoDatasetTraining.insertMany(
|
||||||
|
list.map((item) => ({
|
||||||
|
teamId,
|
||||||
|
tmbId,
|
||||||
|
datasetId,
|
||||||
|
collectionId,
|
||||||
|
billId,
|
||||||
|
mode: trainingMode,
|
||||||
|
prompt,
|
||||||
|
model,
|
||||||
|
q: item.q,
|
||||||
|
a: item.a,
|
||||||
|
chunkIndex: item.chunkIndex ?? 0,
|
||||||
|
weight: weight ?? 0,
|
||||||
|
indexes: item.indexes
|
||||||
|
})),
|
||||||
|
{
|
||||||
|
session,
|
||||||
|
ordered: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error: any) {
|
||||||
|
addLog.error(`Insert error`, error);
|
||||||
|
// 如果有错误,将失败的文档添加到失败列表中
|
||||||
|
error.writeErrors?.forEach((writeError: any) => {
|
||||||
|
failedDocuments.push(data[writeError.index]);
|
||||||
|
});
|
||||||
|
console.log('failed', failedDocuments);
|
||||||
|
}
|
||||||
|
console.log(startIndex, '===');
|
||||||
|
// 对于失败的文档,尝试单独插入
|
||||||
|
await MongoDatasetTraining.create(failedDocuments, { session });
|
||||||
|
|
||||||
|
return insertData(startIndex + batchSize, session);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (session) {
|
||||||
|
await insertData(0, session);
|
||||||
|
} else {
|
||||||
|
await mongoSessionRun(async (session) => {
|
||||||
|
await insertData(0, session);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
delete filterResult.success;
|
delete filterResult.success;
|
||||||
|
|||||||
3
packages/service/core/workflow/constants.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export const WORKFLOW_MAX_RUN_TIMES = process.env.WORKFLOW_MAX_RUN_TIMES
|
||||||
|
? parseInt(process.env.WORKFLOW_MAX_RUN_TIMES)
|
||||||
|
: 500;
|
||||||
@@ -194,7 +194,10 @@ export const runToolWithFunctionCall = async (
|
|||||||
isEntry: true,
|
isEntry: true,
|
||||||
inputs: updateToolInputValue({ params: startParams, inputs: item.inputs })
|
inputs: updateToolInputValue({ params: startParams, inputs: item.inputs })
|
||||||
}
|
}
|
||||||
: item
|
: {
|
||||||
|
...item,
|
||||||
|
isEntry: false
|
||||||
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -295,7 +298,10 @@ export const runToolWithFunctionCall = async (
|
|||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages: filterMessages,
|
completeMessages: filterMessages,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +313,10 @@ export const runToolWithFunctionCall = async (
|
|||||||
{
|
{
|
||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -327,7 +336,8 @@ export const runToolWithFunctionCall = async (
|
|||||||
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value]
|
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value],
|
||||||
|
runTimes: (response?.runTimes || 0) + 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
|||||||
dispatchFlowResponse, // tool flow response
|
dispatchFlowResponse, // tool flow response
|
||||||
totalTokens,
|
totalTokens,
|
||||||
completeMessages = [], // The actual message sent to AI(just save text)
|
completeMessages = [], // The actual message sent to AI(just save text)
|
||||||
assistantResponses = [] // FastGPT system store assistant.value response
|
assistantResponses = [], // FastGPT system store assistant.value response
|
||||||
|
runTimes
|
||||||
} = await (async () => {
|
} = await (async () => {
|
||||||
const adaptMessages = chats2GPTMessages({ messages, reserveId: false });
|
const adaptMessages = chats2GPTMessages({ messages, reserveId: false });
|
||||||
|
|
||||||
@@ -134,6 +135,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
|||||||
...props,
|
...props,
|
||||||
toolNodes,
|
toolNodes,
|
||||||
toolModel,
|
toolModel,
|
||||||
|
maxRunToolTimes: 30,
|
||||||
messages: adaptMessages
|
messages: adaptMessages
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -194,6 +196,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
|||||||
const previewAssistantResponses = filterToolResponseToPreview(assistantResponses);
|
const previewAssistantResponses = filterToolResponseToPreview(assistantResponses);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: runTimes,
|
||||||
[NodeOutputKeyEnum.answerText]: previewAssistantResponses
|
[NodeOutputKeyEnum.answerText]: previewAssistantResponses
|
||||||
.filter((item) => item.text?.content)
|
.filter((item) => item.text?.content)
|
||||||
.map((item) => item.text?.content || '')
|
.map((item) => item.text?.content || '')
|
||||||
|
|||||||
@@ -180,7 +180,8 @@ export const runToolWithPromptCall = async (
|
|||||||
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value]
|
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value],
|
||||||
|
runTimes: (response?.runTimes || 0) + 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +227,10 @@ export const runToolWithPromptCall = async (
|
|||||||
isEntry: true,
|
isEntry: true,
|
||||||
inputs: updateToolInputValue({ params: startParams, inputs: item.inputs })
|
inputs: updateToolInputValue({ params: startParams, inputs: item.inputs })
|
||||||
}
|
}
|
||||||
: item
|
: {
|
||||||
|
...item,
|
||||||
|
isEntry: false
|
||||||
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -315,7 +319,8 @@ ANSWER: `;
|
|||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages: filterMessages,
|
completeMessages: filterMessages,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes: (response?.runTimes || 0) + toolsRunResponse.moduleRunResponse.runTimes
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,7 +332,8 @@ ANSWER: `;
|
|||||||
{
|
{
|
||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes: (response?.runTimes || 0) + toolsRunResponse.moduleRunResponse.runTimes
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,13 +45,12 @@ export const runToolWithToolChoice = async (
|
|||||||
messages: ChatCompletionMessageParam[];
|
messages: ChatCompletionMessageParam[];
|
||||||
toolNodes: ToolNodeItemType[];
|
toolNodes: ToolNodeItemType[];
|
||||||
toolModel: LLMModelItemType;
|
toolModel: LLMModelItemType;
|
||||||
|
maxRunToolTimes: number;
|
||||||
},
|
},
|
||||||
response?: RunToolResponse
|
response?: RunToolResponse
|
||||||
): Promise<RunToolResponse> => {
|
): Promise<RunToolResponse> => {
|
||||||
|
const { messages, toolNodes, toolModel, maxRunToolTimes, ...workflowProps } = props;
|
||||||
const {
|
const {
|
||||||
toolModel,
|
|
||||||
toolNodes,
|
|
||||||
messages,
|
|
||||||
res,
|
res,
|
||||||
requestOrigin,
|
requestOrigin,
|
||||||
runtimeNodes,
|
runtimeNodes,
|
||||||
@@ -59,7 +58,12 @@ export const runToolWithToolChoice = async (
|
|||||||
stream,
|
stream,
|
||||||
workflowStreamResponse,
|
workflowStreamResponse,
|
||||||
params: { temperature = 0, maxToken = 4000, aiChatVision }
|
params: { temperature = 0, maxToken = 4000, aiChatVision }
|
||||||
} = props;
|
} = workflowProps;
|
||||||
|
|
||||||
|
if (maxRunToolTimes <= 0 && response) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
const assistantResponses = response?.assistantResponses || [];
|
const assistantResponses = response?.assistantResponses || [];
|
||||||
|
|
||||||
const tools: ChatCompletionTool[] = toolNodes.map((item) => {
|
const tools: ChatCompletionTool[] = toolNodes.map((item) => {
|
||||||
@@ -196,7 +200,7 @@ export const runToolWithToolChoice = async (
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
const toolRunResponse = await dispatchWorkFlow({
|
const toolRunResponse = await dispatchWorkFlow({
|
||||||
...props,
|
...workflowProps,
|
||||||
isToolCall: true,
|
isToolCall: true,
|
||||||
runtimeNodes: runtimeNodes.map((item) =>
|
runtimeNodes: runtimeNodes.map((item) =>
|
||||||
item.nodeId === toolNode.nodeId
|
item.nodeId === toolNode.nodeId
|
||||||
@@ -205,7 +209,10 @@ export const runToolWithToolChoice = async (
|
|||||||
isEntry: true,
|
isEntry: true,
|
||||||
inputs: updateToolInputValue({ params: startParams, inputs: item.inputs })
|
inputs: updateToolInputValue({ params: startParams, inputs: item.inputs })
|
||||||
}
|
}
|
||||||
: item
|
: {
|
||||||
|
...item,
|
||||||
|
isEntry: false
|
||||||
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -252,11 +259,22 @@ export const runToolWithToolChoice = async (
|
|||||||
role: ChatCompletionRequestMessageRoleEnum.Assistant,
|
role: ChatCompletionRequestMessageRoleEnum.Assistant,
|
||||||
tool_calls: toolCalls
|
tool_calls: toolCalls
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
|
...
|
||||||
|
user
|
||||||
|
assistant: tool data
|
||||||
|
*/
|
||||||
const concatToolMessages = [
|
const concatToolMessages = [
|
||||||
...requestMessages,
|
...requestMessages,
|
||||||
assistantToolMsgParams
|
assistantToolMsgParams
|
||||||
] as ChatCompletionMessageParam[];
|
] as ChatCompletionMessageParam[];
|
||||||
const tokens = await countGptMessagesTokens(concatToolMessages, tools);
|
const tokens = await countGptMessagesTokens(concatToolMessages, tools);
|
||||||
|
/*
|
||||||
|
...
|
||||||
|
user
|
||||||
|
assistant: tool data
|
||||||
|
tool: tool response
|
||||||
|
*/
|
||||||
const completeMessages = [
|
const completeMessages = [
|
||||||
...concatToolMessages,
|
...concatToolMessages,
|
||||||
...toolsRunResponse.map((item) => item?.toolMsgParams)
|
...toolsRunResponse.map((item) => item?.toolMsgParams)
|
||||||
@@ -307,19 +325,26 @@ export const runToolWithToolChoice = async (
|
|||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return runToolWithToolChoice(
|
return runToolWithToolChoice(
|
||||||
{
|
{
|
||||||
...props,
|
...props,
|
||||||
|
maxRunToolTimes: maxRunToolTimes - 1,
|
||||||
messages: completeMessages
|
messages: completeMessages
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
dispatchFlowResponse,
|
dispatchFlowResponse,
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
assistantResponses: toolNodeAssistants
|
assistantResponses: toolNodeAssistants,
|
||||||
|
runTimes:
|
||||||
|
(response?.runTimes || 0) +
|
||||||
|
flatToolsResponseData.reduce((sum, item) => sum + item.runTimes, 0)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -339,10 +364,12 @@ export const runToolWithToolChoice = async (
|
|||||||
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
dispatchFlowResponse: response?.dispatchFlowResponse || [],
|
||||||
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
totalTokens: response?.totalTokens ? response.totalTokens + tokens : tokens,
|
||||||
completeMessages,
|
completeMessages,
|
||||||
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value]
|
assistantResponses: [...assistantResponses, ...toolNodeAssistant.value],
|
||||||
|
runTimes: (response?.runTimes || 0) + 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
addLog.warn(`LLM response error`, {
|
addLog.warn(`LLM response error`, {
|
||||||
requestBody
|
requestBody
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type { RuntimeNodeItemType } from '@fastgpt/global/core/workflow/runtime/
|
|||||||
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
|
import { ChatNodeUsageType } from '@fastgpt/global/support/wallet/bill/type';
|
||||||
import type { DispatchFlowResponse } from '../../type.d';
|
import type { DispatchFlowResponse } from '../../type.d';
|
||||||
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
||||||
|
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||||
|
|
||||||
export type DispatchToolModuleProps = ModuleDispatchProps<{
|
export type DispatchToolModuleProps = ModuleDispatchProps<{
|
||||||
[NodeInputKeyEnum.history]?: ChatItemType[];
|
[NodeInputKeyEnum.history]?: ChatItemType[];
|
||||||
@@ -25,6 +26,7 @@ export type RunToolResponse = {
|
|||||||
totalTokens: number;
|
totalTokens: number;
|
||||||
completeMessages?: ChatCompletionMessageParam[];
|
completeMessages?: ChatCompletionMessageParam[];
|
||||||
assistantResponses?: AIChatItemValueItemType[];
|
assistantResponses?: AIChatItemValueItemType[];
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: number;
|
||||||
};
|
};
|
||||||
export type ToolNodeItemType = RuntimeNodeItemType & {
|
export type ToolNodeItemType = RuntimeNodeItemType & {
|
||||||
toolParams: RuntimeNodeItemType['inputs'];
|
toolParams: RuntimeNodeItemType['inputs'];
|
||||||
|
|||||||
@@ -119,6 +119,31 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
...props
|
...props
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
|
// 初始化深度和自动增加深度,避免无限嵌套
|
||||||
|
if (!props.workflowDispatchDeep) {
|
||||||
|
props.workflowDispatchDeep = 1;
|
||||||
|
} else {
|
||||||
|
props.workflowDispatchDeep += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.workflowDispatchDeep > 20) {
|
||||||
|
return {
|
||||||
|
flowResponses: [],
|
||||||
|
flowUsages: [],
|
||||||
|
debugResponse: {
|
||||||
|
finishedNodes: [],
|
||||||
|
finishedEdges: [],
|
||||||
|
nextStepRunNodes: []
|
||||||
|
},
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: 1,
|
||||||
|
[DispatchNodeResponseKeyEnum.assistantResponses]: [],
|
||||||
|
[DispatchNodeResponseKeyEnum.toolResponses]: null,
|
||||||
|
newVariables: removeSystemVariable(variables)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let workflowRunTimes = 0;
|
||||||
|
|
||||||
// set sse response headers
|
// set sse response headers
|
||||||
if (stream && res) {
|
if (stream && res) {
|
||||||
res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
|
res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
|
||||||
@@ -154,7 +179,8 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
nodeDispatchUsages,
|
nodeDispatchUsages,
|
||||||
toolResponses,
|
toolResponses,
|
||||||
assistantResponses,
|
assistantResponses,
|
||||||
rewriteHistories
|
rewriteHistories,
|
||||||
|
runTimes = 1
|
||||||
}: Omit<
|
}: Omit<
|
||||||
DispatchNodeResultType<{
|
DispatchNodeResultType<{
|
||||||
[NodeOutputKeyEnum.answerText]?: string;
|
[NodeOutputKeyEnum.answerText]?: string;
|
||||||
@@ -163,6 +189,10 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
'nodeResponse'
|
'nodeResponse'
|
||||||
>
|
>
|
||||||
) {
|
) {
|
||||||
|
// Add run times
|
||||||
|
workflowRunTimes += runTimes;
|
||||||
|
props.maxRunTimes -= runTimes;
|
||||||
|
|
||||||
if (responseData) {
|
if (responseData) {
|
||||||
chatResponses.push(responseData);
|
chatResponses.push(responseData);
|
||||||
}
|
}
|
||||||
@@ -303,10 +333,8 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 每个节点 运行/跳过 后,初始化边的状态
|
// 每个节点确定 运行/跳过 前,初始化边的状态
|
||||||
function nodeRunAfterHook(node: RuntimeNodeItemType) {
|
function nodeRunBeforeHook(node: RuntimeNodeItemType) {
|
||||||
node.isEntry = false;
|
|
||||||
|
|
||||||
runtimeEdges.forEach((item) => {
|
runtimeEdges.forEach((item) => {
|
||||||
if (item.target === node.nodeId) {
|
if (item.target === node.nodeId) {
|
||||||
item.status = 'waiting';
|
item.status = 'waiting';
|
||||||
@@ -322,7 +350,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
// Thread avoidance
|
// Thread avoidance
|
||||||
await surrenderProcess();
|
await surrenderProcess();
|
||||||
|
|
||||||
addLog.debug(`Run node`, { maxRunTimes: props.maxRunTimes, uid: user._id });
|
addLog.debug(`Run node`, { maxRunTimes: props.maxRunTimes, appId: props.runningAppInfo.id });
|
||||||
|
|
||||||
// Get node run status by edges
|
// Get node run status by edges
|
||||||
const status = checkNodeRunStatus({
|
const status = checkNodeRunStatus({
|
||||||
@@ -331,11 +359,12 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
});
|
});
|
||||||
const nodeRunResult = await (() => {
|
const nodeRunResult = await (() => {
|
||||||
if (status === 'run') {
|
if (status === 'run') {
|
||||||
props.maxRunTimes--;
|
nodeRunBeforeHook(node);
|
||||||
addLog.debug(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
|
addLog.debug(`[dispatchWorkFlow] nodeRunWithActive: ${node.name}`);
|
||||||
return nodeRunWithActive(node);
|
return nodeRunWithActive(node);
|
||||||
}
|
}
|
||||||
if (status === 'skip' && !skippedNodeIdList.has(node.nodeId)) {
|
if (status === 'skip' && !skippedNodeIdList.has(node.nodeId)) {
|
||||||
|
nodeRunBeforeHook(node);
|
||||||
props.maxRunTimes -= 0.1;
|
props.maxRunTimes -= 0.1;
|
||||||
skippedNodeIdList.add(node.nodeId);
|
skippedNodeIdList.add(node.nodeId);
|
||||||
addLog.debug(`[dispatchWorkFlow] nodeRunWithSkip: ${node.name}`);
|
addLog.debug(`[dispatchWorkFlow] nodeRunWithSkip: ${node.name}`);
|
||||||
@@ -502,8 +531,6 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
dispatchRes[item.key] = valueTypeFormat(item.defaultValue, item.valueType);
|
dispatchRes[item.key] = valueTypeFormat(item.defaultValue, item.valueType);
|
||||||
});
|
});
|
||||||
|
|
||||||
nodeRunAfterHook(node);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
node,
|
node,
|
||||||
runStatus: 'run',
|
runStatus: 'run',
|
||||||
@@ -520,7 +547,6 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
}> {
|
}> {
|
||||||
// Set target edges status to skipped
|
// Set target edges status to skipped
|
||||||
const targetEdges = runtimeEdges.filter((item) => item.source === node.nodeId);
|
const targetEdges = runtimeEdges.filter((item) => item.source === node.nodeId);
|
||||||
nodeRunAfterHook(node);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
node,
|
node,
|
||||||
@@ -535,9 +561,12 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
const entryNodes = runtimeNodes.filter((item) => item.isEntry);
|
const entryNodes = runtimeNodes.filter((item) => item.isEntry);
|
||||||
|
|
||||||
// reset entry
|
// reset entry
|
||||||
// runtimeNodes.forEach((item) => {
|
runtimeNodes.forEach((item) => {
|
||||||
// item.isEntry = false;
|
// Interactive node is not the entry node, return interactive result
|
||||||
// });
|
if (item.flowNodeType !== FlowNodeTypeEnum.userSelect) {
|
||||||
|
item.isEntry = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
await Promise.all(entryNodes.map((node) => checkNodeCanRun(node)));
|
await Promise.all(entryNodes.map((node) => checkNodeCanRun(node)));
|
||||||
|
|
||||||
// focus try to run pluginOutput
|
// focus try to run pluginOutput
|
||||||
@@ -565,6 +594,7 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons
|
|||||||
finishedEdges: runtimeEdges,
|
finishedEdges: runtimeEdges,
|
||||||
nextStepRunNodes: debugNextStepRunNodes
|
nextStepRunNodes: debugNextStepRunNodes
|
||||||
},
|
},
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: workflowRunTimes,
|
||||||
[DispatchNodeResponseKeyEnum.assistantResponses]:
|
[DispatchNodeResponseKeyEnum.assistantResponses]:
|
||||||
mergeAssistantResponseAnswerText(chatAssistantResponse),
|
mergeAssistantResponseAnswerText(chatAssistantResponse),
|
||||||
[DispatchNodeResponseKeyEnum.toolResponses]: toolRunResponse,
|
[DispatchNodeResponseKeyEnum.toolResponses]: toolRunResponse,
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import { DispatchNodeResponseKeyEnum } from '@fastgpt/global/core/workflow/runtime/constants';
|
||||||
DispatchNodeResponseKeyEnum,
|
|
||||||
SseResponseEventEnum
|
|
||||||
} from '@fastgpt/global/core/workflow/runtime/constants';
|
|
||||||
import {
|
import {
|
||||||
DispatchNodeResultType,
|
DispatchNodeResultType,
|
||||||
ModuleDispatchProps
|
ModuleDispatchProps
|
||||||
@@ -26,14 +23,12 @@ type UserSelectResponse = DispatchNodeResultType<{
|
|||||||
|
|
||||||
export const dispatchUserSelect = async (props: Props): Promise<UserSelectResponse> => {
|
export const dispatchUserSelect = async (props: Props): Promise<UserSelectResponse> => {
|
||||||
const {
|
const {
|
||||||
workflowStreamResponse,
|
|
||||||
runningAppInfo: { id: appId },
|
|
||||||
histories,
|
histories,
|
||||||
chatId,
|
node,
|
||||||
node: { nodeId, isEntry },
|
|
||||||
params: { description, userSelectOptions },
|
params: { description, userSelectOptions },
|
||||||
query
|
query
|
||||||
} = props;
|
} = props;
|
||||||
|
const { nodeId, isEntry } = node;
|
||||||
|
|
||||||
// Interactive node is not the entry node, return interactive result
|
// Interactive node is not the entry node, return interactive result
|
||||||
if (!isEntry) {
|
if (!isEntry) {
|
||||||
@@ -48,6 +43,8 @@ export const dispatchUserSelect = async (props: Props): Promise<UserSelectRespon
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
node.isEntry = false;
|
||||||
|
|
||||||
const { text: userSelectedVal } = chatValue2RuntimePrompt(query);
|
const { text: userSelectedVal } = chatValue2RuntimePrompt(query);
|
||||||
|
|
||||||
// Error status
|
// Error status
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
|||||||
appId: String(plugin.id)
|
appId: String(plugin.id)
|
||||||
};
|
};
|
||||||
|
|
||||||
const { flowResponses, flowUsages, assistantResponses } = await dispatchWorkFlow({
|
const { flowResponses, flowUsages, assistantResponses, runTimes } = await dispatchWorkFlow({
|
||||||
...props,
|
...props,
|
||||||
runningAppInfo: {
|
runningAppInfo: {
|
||||||
id: String(plugin.id),
|
id: String(plugin.id),
|
||||||
@@ -92,6 +92,7 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise<RunPlugi
|
|||||||
return {
|
return {
|
||||||
assistantResponses,
|
assistantResponses,
|
||||||
// responseData, // debug
|
// responseData, // debug
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: runTimes,
|
||||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||||
moduleLogo: plugin.avatar,
|
moduleLogo: plugin.avatar,
|
||||||
totalPoints: usagePoints,
|
totalPoints: usagePoints,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export const dispatchRunAppNode = async (props: Props): Promise<Response> => {
|
|||||||
appId: String(appData._id)
|
appId: String(appData._id)
|
||||||
};
|
};
|
||||||
|
|
||||||
const { flowResponses, flowUsages, assistantResponses } = await dispatchWorkFlow({
|
const { flowResponses, flowUsages, assistantResponses, runTimes } = await dispatchWorkFlow({
|
||||||
...props,
|
...props,
|
||||||
runningAppInfo: {
|
runningAppInfo: {
|
||||||
id: String(appData._id),
|
id: String(appData._id),
|
||||||
@@ -107,6 +107,7 @@ export const dispatchRunAppNode = async (props: Props): Promise<Response> => {
|
|||||||
const { text } = chatValue2RuntimePrompt(assistantResponses);
|
const { text } = chatValue2RuntimePrompt(assistantResponses);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: runTimes,
|
||||||
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
[DispatchNodeResponseKeyEnum.nodeResponse]: {
|
||||||
moduleLogo: appData.avatar,
|
moduleLogo: appData.avatar,
|
||||||
query: userChatInput,
|
query: userChatInput,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export type DispatchFlowResponse = {
|
|||||||
};
|
};
|
||||||
[DispatchNodeResponseKeyEnum.toolResponses]: ToolRunResponseItemType;
|
[DispatchNodeResponseKeyEnum.toolResponses]: ToolRunResponseItemType;
|
||||||
[DispatchNodeResponseKeyEnum.assistantResponses]: AIChatItemValueItemType[];
|
[DispatchNodeResponseKeyEnum.assistantResponses]: AIChatItemValueItemType[];
|
||||||
|
[DispatchNodeResponseKeyEnum.runTimes]: number;
|
||||||
newVariables: Record<string, string>;
|
newVariables: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -38,11 +38,13 @@ export const authPluginByTmbId = async ({
|
|||||||
export const authAppByTmbId = async ({
|
export const authAppByTmbId = async ({
|
||||||
tmbId,
|
tmbId,
|
||||||
appId,
|
appId,
|
||||||
per
|
per,
|
||||||
|
isRoot
|
||||||
}: {
|
}: {
|
||||||
tmbId: string;
|
tmbId: string;
|
||||||
appId: string;
|
appId: string;
|
||||||
per: PermissionValueType;
|
per: PermissionValueType;
|
||||||
|
isRoot?: boolean;
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
app: AppDetailType;
|
app: AppDetailType;
|
||||||
}> => {
|
}> => {
|
||||||
@@ -55,6 +57,14 @@ export const authAppByTmbId = async ({
|
|||||||
return Promise.reject(AppErrEnum.unExist);
|
return Promise.reject(AppErrEnum.unExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRoot) {
|
||||||
|
return {
|
||||||
|
...app,
|
||||||
|
defaultPermission: app.defaultPermission,
|
||||||
|
permission: new AppPermission({ isOwner: true })
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (String(app.teamId) !== teamId) {
|
if (String(app.teamId) !== teamId) {
|
||||||
return Promise.reject(AppErrEnum.unAuthApp);
|
return Promise.reject(AppErrEnum.unAuthApp);
|
||||||
}
|
}
|
||||||
@@ -136,7 +146,8 @@ export const authApp = async ({
|
|||||||
const { app } = await authAppByTmbId({
|
const { app } = await authAppByTmbId({
|
||||||
tmbId,
|
tmbId,
|
||||||
appId,
|
appId,
|
||||||
per
|
per,
|
||||||
|
isRoot: result.isRoot
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -78,13 +78,18 @@ export const delResourcePermission = ({
|
|||||||
|
|
||||||
/* 下面代码等迁移 */
|
/* 下面代码等迁移 */
|
||||||
/* create token */
|
/* create token */
|
||||||
export function createJWT(user: { _id?: string; team?: { teamId?: string; tmbId: string } }) {
|
export function createJWT(user: {
|
||||||
|
_id?: string;
|
||||||
|
team?: { teamId?: string; tmbId: string };
|
||||||
|
isRoot?: boolean;
|
||||||
|
}) {
|
||||||
const key = process.env.TOKEN_KEY as string;
|
const key = process.env.TOKEN_KEY as string;
|
||||||
const token = jwt.sign(
|
const token = jwt.sign(
|
||||||
{
|
{
|
||||||
userId: String(user._id),
|
userId: String(user._id),
|
||||||
teamId: String(user.team?.teamId),
|
teamId: String(user.team?.teamId),
|
||||||
tmbId: String(user.team?.tmbId),
|
tmbId: String(user.team?.tmbId),
|
||||||
|
isRoot: user.isRoot,
|
||||||
exp: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7
|
exp: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 7
|
||||||
},
|
},
|
||||||
key
|
key
|
||||||
@@ -98,6 +103,7 @@ export function authJWT(token: string) {
|
|||||||
userId: string;
|
userId: string;
|
||||||
teamId: string;
|
teamId: string;
|
||||||
tmbId: string;
|
tmbId: string;
|
||||||
|
isRoot: boolean;
|
||||||
}>((resolve, reject) => {
|
}>((resolve, reject) => {
|
||||||
const key = process.env.TOKEN_KEY as string;
|
const key = process.env.TOKEN_KEY as string;
|
||||||
|
|
||||||
@@ -110,7 +116,8 @@ export function authJWT(token: string) {
|
|||||||
resolve({
|
resolve({
|
||||||
userId: decoded.userId,
|
userId: decoded.userId,
|
||||||
teamId: decoded.teamId || '',
|
teamId: decoded.teamId || '',
|
||||||
tmbId: decoded.tmbId
|
tmbId: decoded.tmbId,
|
||||||
|
isRoot: decoded.isRoot
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -183,7 +190,7 @@ export async function parseHeaderCert({
|
|||||||
|
|
||||||
const { cookie, token, rootkey, authorization } = (req.headers || {}) as ReqHeaderAuthType;
|
const { cookie, token, rootkey, authorization } = (req.headers || {}) as ReqHeaderAuthType;
|
||||||
|
|
||||||
const { uid, teamId, tmbId, appId, openApiKey, authType } = await (async () => {
|
const { uid, teamId, tmbId, appId, openApiKey, authType, isRoot } = await (async () => {
|
||||||
if (authApiKey && authorization) {
|
if (authApiKey && authorization) {
|
||||||
// apikey from authorization
|
// apikey from authorization
|
||||||
const authResponse = await parseAuthorization(authorization);
|
const authResponse = await parseAuthorization(authorization);
|
||||||
@@ -205,7 +212,8 @@ export async function parseHeaderCert({
|
|||||||
tmbId: res.tmbId,
|
tmbId: res.tmbId,
|
||||||
appId: '',
|
appId: '',
|
||||||
openApiKey: '',
|
openApiKey: '',
|
||||||
authType: AuthUserTypeEnum.token
|
authType: AuthUserTypeEnum.token,
|
||||||
|
isRoot: res.isRoot
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (authRoot && rootkey) {
|
if (authRoot && rootkey) {
|
||||||
@@ -217,7 +225,8 @@ export async function parseHeaderCert({
|
|||||||
tmbId: '',
|
tmbId: '',
|
||||||
appId: '',
|
appId: '',
|
||||||
openApiKey: '',
|
openApiKey: '',
|
||||||
authType: AuthUserTypeEnum.root
|
authType: AuthUserTypeEnum.root,
|
||||||
|
isRoot: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +243,8 @@ export async function parseHeaderCert({
|
|||||||
tmbId: String(tmbId),
|
tmbId: String(tmbId),
|
||||||
appId,
|
appId,
|
||||||
authType,
|
authType,
|
||||||
apikey: openApiKey
|
apikey: openApiKey,
|
||||||
|
isRoot: !!isRoot
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,13 @@ import { ParentIdType } from '@fastgpt/global/common/parentFolder/type';
|
|||||||
export const authDatasetByTmbId = async ({
|
export const authDatasetByTmbId = async ({
|
||||||
tmbId,
|
tmbId,
|
||||||
datasetId,
|
datasetId,
|
||||||
per
|
per,
|
||||||
|
isRoot = false
|
||||||
}: {
|
}: {
|
||||||
tmbId: string;
|
tmbId: string;
|
||||||
datasetId: string;
|
datasetId: string;
|
||||||
per: PermissionValueType;
|
per: PermissionValueType;
|
||||||
|
isRoot?: boolean;
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
dataset: DatasetSchemaType & {
|
dataset: DatasetSchemaType & {
|
||||||
permission: DatasetPermission;
|
permission: DatasetPermission;
|
||||||
@@ -44,6 +46,15 @@ export const authDatasetByTmbId = async ({
|
|||||||
return Promise.reject(DatasetErrEnum.unExist);
|
return Promise.reject(DatasetErrEnum.unExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRoot) {
|
||||||
|
return {
|
||||||
|
...dataset,
|
||||||
|
permission: new DatasetPermission({
|
||||||
|
isOwner: true
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (String(dataset.teamId) !== teamId) {
|
if (String(dataset.teamId) !== teamId) {
|
||||||
return Promise.reject(DatasetErrEnum.unAuthDataset);
|
return Promise.reject(DatasetErrEnum.unAuthDataset);
|
||||||
}
|
}
|
||||||
@@ -79,13 +90,15 @@ export const authDatasetByTmbId = async ({
|
|||||||
const { dataset: parent } = await authDatasetByTmbId({
|
const { dataset: parent } = await authDatasetByTmbId({
|
||||||
tmbId,
|
tmbId,
|
||||||
datasetId: dataset.parentId,
|
datasetId: dataset.parentId,
|
||||||
per
|
per,
|
||||||
|
isRoot
|
||||||
});
|
});
|
||||||
|
|
||||||
const Per = new DatasetPermission({
|
const Per = new DatasetPermission({
|
||||||
per: parent.permission.value,
|
per: parent.permission.value,
|
||||||
isOwner
|
isOwner
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Per,
|
Per,
|
||||||
defaultPermission: parent.defaultPermission
|
defaultPermission: parent.defaultPermission
|
||||||
@@ -131,7 +144,8 @@ export const authDataset = async ({
|
|||||||
const { dataset } = await authDatasetByTmbId({
|
const { dataset } = await authDatasetByTmbId({
|
||||||
tmbId,
|
tmbId,
|
||||||
datasetId,
|
datasetId,
|
||||||
per
|
per,
|
||||||
|
isRoot: result.isRoot
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -144,15 +158,17 @@ export const authDataset = async ({
|
|||||||
export async function authDatasetCollection({
|
export async function authDatasetCollection({
|
||||||
collectionId,
|
collectionId,
|
||||||
per = NullPermission,
|
per = NullPermission,
|
||||||
|
isRoot = false,
|
||||||
...props
|
...props
|
||||||
}: AuthModeType & {
|
}: AuthModeType & {
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
|
isRoot?: boolean;
|
||||||
}): Promise<
|
}): Promise<
|
||||||
AuthResponseType<DatasetPermission> & {
|
AuthResponseType<DatasetPermission> & {
|
||||||
collection: CollectionWithDatasetType;
|
collection: CollectionWithDatasetType;
|
||||||
}
|
}
|
||||||
> {
|
> {
|
||||||
const { teamId, tmbId } = await parseHeaderCert(props);
|
const { teamId, tmbId, isRoot: isRootFromHeader } = await parseHeaderCert(props);
|
||||||
const collection = await getCollectionWithDataset(collectionId);
|
const collection = await getCollectionWithDataset(collectionId);
|
||||||
|
|
||||||
if (!collection) {
|
if (!collection) {
|
||||||
@@ -162,7 +178,8 @@ export async function authDatasetCollection({
|
|||||||
const { dataset } = await authDatasetByTmbId({
|
const { dataset } = await authDatasetByTmbId({
|
||||||
tmbId,
|
tmbId,
|
||||||
datasetId: collection.datasetId._id,
|
datasetId: collection.datasetId._id,
|
||||||
per
|
per,
|
||||||
|
isRoot: isRootFromHeader || isRoot
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -184,7 +201,7 @@ export async function authDatasetFile({
|
|||||||
file: DatasetFileSchema;
|
file: DatasetFileSchema;
|
||||||
}
|
}
|
||||||
> {
|
> {
|
||||||
const { teamId, tmbId } = await parseHeaderCert(props);
|
const { teamId, tmbId, isRoot } = await parseHeaderCert(props);
|
||||||
|
|
||||||
const [file, collection] = await Promise.all([
|
const [file, collection] = await Promise.all([
|
||||||
getFileById({ bucketName: BucketNameEnum.dataset, fileId }),
|
getFileById({ bucketName: BucketNameEnum.dataset, fileId }),
|
||||||
@@ -206,7 +223,8 @@ export async function authDatasetFile({
|
|||||||
const { permission } = await authDatasetCollection({
|
const { permission } = await authDatasetCollection({
|
||||||
...props,
|
...props,
|
||||||
collectionId: collection._id,
|
collectionId: collection._id,
|
||||||
per
|
per,
|
||||||
|
isRoot
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { getTmbInfoByTmbId } from '../../user/team/controller';
|
|||||||
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
|
||||||
import { AuthModeType, AuthResponseType } from '../type';
|
import { AuthModeType, AuthResponseType } from '../type';
|
||||||
import { NullPermission } from '@fastgpt/global/support/permission/constant';
|
import { NullPermission } from '@fastgpt/global/support/permission/constant';
|
||||||
|
import { TeamPermission } from '@fastgpt/global/support/permission/user/controller';
|
||||||
|
|
||||||
/* auth user role */
|
/* auth user role */
|
||||||
export async function authUserPer(props: AuthModeType): Promise<
|
export async function authUserPer(props: AuthModeType): Promise<
|
||||||
@@ -14,6 +15,15 @@ export async function authUserPer(props: AuthModeType): Promise<
|
|||||||
const result = await parseHeaderCert(props);
|
const result = await parseHeaderCert(props);
|
||||||
const tmb = await getTmbInfoByTmbId({ tmbId: result.tmbId });
|
const tmb = await getTmbInfoByTmbId({ tmbId: result.tmbId });
|
||||||
|
|
||||||
|
if (result.isRoot) {
|
||||||
|
return {
|
||||||
|
...result,
|
||||||
|
permission: new TeamPermission({
|
||||||
|
isOwner: true
|
||||||
|
}),
|
||||||
|
tmb
|
||||||
|
};
|
||||||
|
}
|
||||||
if (!tmb.permission.checkPer(props.per ?? NullPermission)) {
|
if (!tmb.permission.checkPer(props.per ?? NullPermission)) {
|
||||||
return Promise.reject(TeamErrEnum.unAuthTeam);
|
return Promise.reject(TeamErrEnum.unAuthTeam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type PagingData<T> = {
|
|||||||
total?: number;
|
total?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function usePagination<T = any>({
|
export function usePagination<ResT = any>({
|
||||||
api,
|
api,
|
||||||
pageSize = 10,
|
pageSize = 10,
|
||||||
params = {},
|
params = {},
|
||||||
@@ -25,7 +25,7 @@ export function usePagination<T = any>({
|
|||||||
onChange,
|
onChange,
|
||||||
elementRef
|
elementRef
|
||||||
}: {
|
}: {
|
||||||
api: (data: any) => any;
|
api: (data: any) => Promise<PagingData<ResT>>;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
params?: Record<string, any>;
|
params?: Record<string, any>;
|
||||||
defaultRequest?: boolean;
|
defaultRequest?: boolean;
|
||||||
@@ -41,7 +41,7 @@ export function usePagination<T = any>({
|
|||||||
const [total, setTotal] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
const totalRef = useRef(total);
|
const totalRef = useRef(total);
|
||||||
totalRef.current = total;
|
totalRef.current = total;
|
||||||
const [data, setData] = useState<T[]>([]);
|
const [data, setData] = useState<ResT[]>([]);
|
||||||
const dataLengthRef = useRef(data.length);
|
const dataLengthRef = useRef(data.length);
|
||||||
dataLengthRef.current = data.length;
|
dataLengthRef.current = data.length;
|
||||||
const maxPage = useMemo(() => Math.ceil(total / pageSize) || 1, [pageSize, total]);
|
const maxPage = useMemo(() => Math.ceil(total / pageSize) || 1, [pageSize, total]);
|
||||||
@@ -49,7 +49,7 @@ export function usePagination<T = any>({
|
|||||||
const { mutate, isLoading } = useMutation({
|
const { mutate, isLoading } = useMutation({
|
||||||
mutationFn: async (num: number = pageNum) => {
|
mutationFn: async (num: number = pageNum) => {
|
||||||
try {
|
try {
|
||||||
const res: PagingData<T> = await api({
|
const res: PagingData<ResT> = await api({
|
||||||
pageNum: num,
|
pageNum: num,
|
||||||
pageSize,
|
pageSize,
|
||||||
...params
|
...params
|
||||||
@@ -107,7 +107,7 @@ export function usePagination<T = any>({
|
|||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const val = +e.target.value;
|
const val = +e.target.value;
|
||||||
if (val && e.keyCode === 13) {
|
if (val && e.key === 'Enter') {
|
||||||
if (val === pageNum) return;
|
if (val === pageNum) return;
|
||||||
if (val >= maxPage) {
|
if (val >= maxPage) {
|
||||||
mutate(maxPage);
|
mutate(maxPage);
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
"logs_empty": "还没有日志噢~",
|
"logs_empty": "还没有日志噢~",
|
||||||
"logs_message_total": "消息总数",
|
"logs_message_total": "消息总数",
|
||||||
"logs_title": "标题",
|
"logs_title": "标题",
|
||||||
|
"logs_chat_user": "使用者",
|
||||||
"mark_count": "标注答案数量",
|
"mark_count": "标注答案数量",
|
||||||
"module": {
|
"module": {
|
||||||
"Confirm Sync": "将会更新至最新的模板配置,不存在模板中的字段将会被删除(包括所有自定义字段),建议您先复制一份节点,再更新原来节点的版本。",
|
"Confirm Sync": "将会更新至最新的模板配置,不存在模板中的字段将会被删除(包括所有自定义字段),建议您先复制一份节点,再更新原来节点的版本。",
|
||||||
|
|||||||
@@ -543,7 +543,7 @@
|
|||||||
"module similarity": "相似度",
|
"module similarity": "相似度",
|
||||||
"module temperature": "温度",
|
"module temperature": "温度",
|
||||||
"module time": "运行时长",
|
"module time": "运行时长",
|
||||||
"module tokens": "总 tokens",
|
"module tokens": "AI Tokens 消耗",
|
||||||
"plugin output": "插件输出值",
|
"plugin output": "插件输出值",
|
||||||
"search using reRank": "结果重排",
|
"search using reRank": "结果重排",
|
||||||
"text output": "文本输出",
|
"text output": "文本输出",
|
||||||
|
|||||||
100
pnpm-lock.yaml
generated
@@ -22,7 +22,7 @@ importers:
|
|||||||
version: 13.3.0
|
version: 13.3.0
|
||||||
next-i18next:
|
next-i18next:
|
||||||
specifier: 15.3.0
|
specifier: 15.3.0
|
||||||
version: 15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
version: 15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
||||||
prettier:
|
prettier:
|
||||||
specifier: 3.2.4
|
specifier: 3.2.4
|
||||||
version: 3.2.4
|
version: 3.2.4
|
||||||
@@ -250,7 +250,7 @@ importers:
|
|||||||
version: 2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
version: 2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
||||||
'@chakra-ui/next-js':
|
'@chakra-ui/next-js':
|
||||||
specifier: 2.1.5
|
specifier: 2.1.5
|
||||||
version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)
|
version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)
|
||||||
'@chakra-ui/react':
|
'@chakra-ui/react':
|
||||||
specifier: 2.8.1
|
specifier: 2.8.1
|
||||||
version: 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
@@ -313,7 +313,7 @@ importers:
|
|||||||
version: 4.17.21
|
version: 4.17.21
|
||||||
next-i18next:
|
next-i18next:
|
||||||
specifier: 15.3.0
|
specifier: 15.3.0
|
||||||
version: 15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
version: 15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
||||||
papaparse:
|
papaparse:
|
||||||
specifier: ^5.4.1
|
specifier: ^5.4.1
|
||||||
version: 5.4.1
|
version: 5.4.1
|
||||||
@@ -374,7 +374,7 @@ importers:
|
|||||||
version: 2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
version: 2.1.1(@chakra-ui/system@2.6.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
||||||
'@chakra-ui/next-js':
|
'@chakra-ui/next-js':
|
||||||
specifier: 2.1.5
|
specifier: 2.1.5
|
||||||
version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)
|
version: 2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)
|
||||||
'@chakra-ui/react':
|
'@chakra-ui/react':
|
||||||
specifier: 2.8.1
|
specifier: 2.8.1
|
||||||
version: 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
version: 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
@@ -470,7 +470,7 @@ importers:
|
|||||||
version: 14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
|
version: 14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8)
|
||||||
next-i18next:
|
next-i18next:
|
||||||
specifier: 15.3.0
|
specifier: 15.3.0
|
||||||
version: 15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
version: 15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1)
|
||||||
nextjs-node-loader:
|
nextjs-node-loader:
|
||||||
specifier: ^1.1.5
|
specifier: ^1.1.5
|
||||||
version: 1.1.5(webpack@5.92.1)
|
version: 1.1.5(webpack@5.92.1)
|
||||||
@@ -721,6 +721,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==}
|
resolution: {integrity: sha512-o9HBZL1G2129luEUlG1hB4N/nlYNWHnpwlND9eOMclRqqu1YDy2sSYVCFUZwl8I1Gxh+QSRrP2vD7EpUmFVXxg==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
|
'@babel/generator@7.25.6':
|
||||||
|
resolution: {integrity: sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==}
|
||||||
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@babel/helper-annotate-as-pure@7.24.7':
|
'@babel/helper-annotate-as-pure@7.24.7':
|
||||||
resolution: {integrity: sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg==}
|
resolution: {integrity: sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
@@ -837,6 +841,11 @@ packages:
|
|||||||
engines: {node: '>=6.0.0'}
|
engines: {node: '>=6.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
'@babel/parser@7.25.6':
|
||||||
|
resolution: {integrity: sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==}
|
||||||
|
engines: {node: '>=6.0.0'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
'@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.24.7':
|
'@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.24.7':
|
||||||
resolution: {integrity: sha512-TiT1ss81W80eQsN+722OaeQMY/G4yTb4G9JrqeiDADs3N8lbPMGldWi9x8tyqCW5NLx1Jh2AvkE6r6QvEltMMQ==}
|
resolution: {integrity: sha512-TiT1ss81W80eQsN+722OaeQMY/G4yTb4G9JrqeiDADs3N8lbPMGldWi9x8tyqCW5NLx1Jh2AvkE6r6QvEltMMQ==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
@@ -1338,14 +1347,26 @@ packages:
|
|||||||
resolution: {integrity: sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==}
|
resolution: {integrity: sha512-jYqfPrU9JTF0PmPy1tLYHW4Mp4KlgxJD9l2nP9fD6yT/ICi554DmrWBAEYpIelzjHf1msDP3PxJIRt/nFNfBig==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
|
'@babel/template@7.25.0':
|
||||||
|
resolution: {integrity: sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==}
|
||||||
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@babel/traverse@7.24.8':
|
'@babel/traverse@7.24.8':
|
||||||
resolution: {integrity: sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==}
|
resolution: {integrity: sha512-t0P1xxAPzEDcEPmjprAQq19NWum4K0EQPjMwZQZbHt+GiZqvjCHjj755Weq1YRPVzBI+3zSfvScfpnuIecVFJQ==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
|
'@babel/traverse@7.25.6':
|
||||||
|
resolution: {integrity: sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==}
|
||||||
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@babel/types@7.24.9':
|
'@babel/types@7.24.9':
|
||||||
resolution: {integrity: sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==}
|
resolution: {integrity: sha512-xm8XrMKz0IlUdocVbYJe0Z9xEgidU7msskG8BbhnTPK/HZ2z/7FP7ykqPgrUH+C+r414mNfNWam1f2vqOjqjYQ==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
|
'@babel/types@7.25.6':
|
||||||
|
resolution: {integrity: sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==}
|
||||||
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@bany/curl-to-json@1.2.8':
|
'@bany/curl-to-json@1.2.8':
|
||||||
resolution: {integrity: sha512-hPt9KUM2sGZ5Ojx3O9utjzUgjRZI3CZPAlLf+cRY9EUzVs7tWt1OpA0bhEUTX2PEEkOeyZ6sC0tAQMOHh9ld+Q==}
|
resolution: {integrity: sha512-hPt9KUM2sGZ5Ojx3O9utjzUgjRZI3CZPAlLf+cRY9EUzVs7tWt1OpA0bhEUTX2PEEkOeyZ6sC0tAQMOHh9ld+Q==}
|
||||||
|
|
||||||
@@ -8920,14 +8941,14 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@ampproject/remapping': 2.3.0
|
'@ampproject/remapping': 2.3.0
|
||||||
'@babel/code-frame': 7.24.7
|
'@babel/code-frame': 7.24.7
|
||||||
'@babel/generator': 7.24.10
|
'@babel/generator': 7.25.6
|
||||||
'@babel/helper-compilation-targets': 7.24.8
|
'@babel/helper-compilation-targets': 7.24.8
|
||||||
'@babel/helper-module-transforms': 7.24.9(@babel/core@7.24.9)
|
'@babel/helper-module-transforms': 7.24.9(@babel/core@7.24.9)
|
||||||
'@babel/helpers': 7.24.8
|
'@babel/helpers': 7.24.8
|
||||||
'@babel/parser': 7.24.8
|
'@babel/parser': 7.25.6
|
||||||
'@babel/template': 7.24.7
|
'@babel/template': 7.24.7
|
||||||
'@babel/traverse': 7.24.8
|
'@babel/traverse': 7.25.6
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
convert-source-map: 2.0.0
|
convert-source-map: 2.0.0
|
||||||
debug: 4.3.5
|
debug: 4.3.5
|
||||||
gensync: 1.0.0-beta.2
|
gensync: 1.0.0-beta.2
|
||||||
@@ -8943,9 +8964,16 @@ snapshots:
|
|||||||
'@jridgewell/trace-mapping': 0.3.25
|
'@jridgewell/trace-mapping': 0.3.25
|
||||||
jsesc: 2.5.2
|
jsesc: 2.5.2
|
||||||
|
|
||||||
|
'@babel/generator@7.25.6':
|
||||||
|
dependencies:
|
||||||
|
'@babel/types': 7.25.6
|
||||||
|
'@jridgewell/gen-mapping': 0.3.5
|
||||||
|
'@jridgewell/trace-mapping': 0.3.25
|
||||||
|
jsesc: 2.5.2
|
||||||
|
|
||||||
'@babel/helper-annotate-as-pure@7.24.7':
|
'@babel/helper-annotate-as-pure@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
'@babel/helper-builder-binary-assignment-operator-visitor@7.24.7':
|
'@babel/helper-builder-binary-assignment-operator-visitor@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -8997,7 +9025,7 @@ snapshots:
|
|||||||
|
|
||||||
'@babel/helper-environment-visitor@7.24.7':
|
'@babel/helper-environment-visitor@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
'@babel/helper-function-name@7.24.7':
|
'@babel/helper-function-name@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -9017,8 +9045,8 @@ snapshots:
|
|||||||
|
|
||||||
'@babel/helper-module-imports@7.24.7':
|
'@babel/helper-module-imports@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/traverse': 7.24.8
|
'@babel/traverse': 7.25.6
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -9059,8 +9087,8 @@ snapshots:
|
|||||||
|
|
||||||
'@babel/helper-simple-access@7.24.7':
|
'@babel/helper-simple-access@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/traverse': 7.24.8
|
'@babel/traverse': 7.25.6
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
@@ -9073,7 +9101,7 @@ snapshots:
|
|||||||
|
|
||||||
'@babel/helper-split-export-declaration@7.24.7':
|
'@babel/helper-split-export-declaration@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
'@babel/helper-string-parser@7.24.8': {}
|
'@babel/helper-string-parser@7.24.8': {}
|
||||||
|
|
||||||
@@ -9093,7 +9121,7 @@ snapshots:
|
|||||||
'@babel/helpers@7.24.8':
|
'@babel/helpers@7.24.8':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/template': 7.24.7
|
'@babel/template': 7.24.7
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
'@babel/highlight@7.24.7':
|
'@babel/highlight@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -9106,6 +9134,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.24.9
|
||||||
|
|
||||||
|
'@babel/parser@7.25.6':
|
||||||
|
dependencies:
|
||||||
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
'@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.24.7(@babel/core@7.24.9)':
|
'@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.24.7(@babel/core@7.24.9)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/core': 7.24.9
|
'@babel/core': 7.24.9
|
||||||
@@ -9735,8 +9767,14 @@ snapshots:
|
|||||||
'@babel/template@7.24.7':
|
'@babel/template@7.24.7':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/code-frame': 7.24.7
|
'@babel/code-frame': 7.24.7
|
||||||
'@babel/parser': 7.24.8
|
'@babel/parser': 7.25.6
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
|
'@babel/template@7.25.0':
|
||||||
|
dependencies:
|
||||||
|
'@babel/code-frame': 7.24.7
|
||||||
|
'@babel/parser': 7.25.6
|
||||||
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
'@babel/traverse@7.24.8':
|
'@babel/traverse@7.24.8':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -9753,12 +9791,30 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
'@babel/traverse@7.25.6':
|
||||||
|
dependencies:
|
||||||
|
'@babel/code-frame': 7.24.7
|
||||||
|
'@babel/generator': 7.25.6
|
||||||
|
'@babel/parser': 7.25.6
|
||||||
|
'@babel/template': 7.25.0
|
||||||
|
'@babel/types': 7.25.6
|
||||||
|
debug: 4.3.5
|
||||||
|
globals: 11.12.0
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- supports-color
|
||||||
|
|
||||||
'@babel/types@7.24.9':
|
'@babel/types@7.24.9':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/helper-string-parser': 7.24.8
|
'@babel/helper-string-parser': 7.24.8
|
||||||
'@babel/helper-validator-identifier': 7.24.7
|
'@babel/helper-validator-identifier': 7.24.7
|
||||||
to-fast-properties: 2.0.0
|
to-fast-properties: 2.0.0
|
||||||
|
|
||||||
|
'@babel/types@7.25.6':
|
||||||
|
dependencies:
|
||||||
|
'@babel/helper-string-parser': 7.24.8
|
||||||
|
'@babel/helper-validator-identifier': 7.24.7
|
||||||
|
to-fast-properties: 2.0.0
|
||||||
|
|
||||||
'@bany/curl-to-json@1.2.8':
|
'@bany/curl-to-json@1.2.8':
|
||||||
dependencies:
|
dependencies:
|
||||||
minimist: 1.2.8
|
minimist: 1.2.8
|
||||||
@@ -10031,7 +10087,7 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@types/react'
|
- '@types/react'
|
||||||
|
|
||||||
'@chakra-ui/next-js@2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)':
|
'@chakra-ui/next-js@2.1.5(@chakra-ui/react@2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react@18.3.1)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@chakra-ui/react': 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
'@chakra-ui/react': 2.8.1(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@emotion/styled@11.11.0(@emotion/react@11.11.1(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(react@18.3.1))(@types/react@18.3.1)(framer-motion@9.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
|
||||||
'@emotion/cache': 11.11.0
|
'@emotion/cache': 11.11.0
|
||||||
@@ -11796,7 +11852,7 @@ snapshots:
|
|||||||
|
|
||||||
'@types/babel__generator@7.6.8':
|
'@types/babel__generator@7.6.8':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.24.9
|
'@babel/types': 7.25.6
|
||||||
|
|
||||||
'@types/babel__template@7.4.4':
|
'@types/babel__template@7.4.4':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -16634,7 +16690,7 @@ snapshots:
|
|||||||
|
|
||||||
neo-async@2.6.2: {}
|
neo-async@2.6.2: {}
|
||||||
|
|
||||||
next-i18next@15.3.0(i18next@23.11.5)(next@14.2.5(@babel/core@7.24.9)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1):
|
next-i18next@15.3.0(i18next@23.11.5)(next@14.2.5(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(sass@1.77.8))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/runtime': 7.24.8
|
'@babel/runtime': 7.24.8
|
||||||
'@types/hoist-non-react-statics': 3.3.5
|
'@types/hoist-non-react-statics': 3.3.5
|
||||||
|
|||||||
@@ -36,3 +36,6 @@ HOME_URL=/
|
|||||||
# 日志等级: debug, info, warn, error
|
# 日志等级: debug, info, warn, error
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
STORE_LOG_LEVEL=warn
|
STORE_LOG_LEVEL=warn
|
||||||
|
|
||||||
|
# 工作流最大运行次数,避免极端的死循环情况
|
||||||
|
WORKFLOW_MAX_RUN_TIMES=500
|
||||||
@@ -462,6 +462,14 @@
|
|||||||
"sourceHandle": "rvbo634w3AYj-source-sdfa",
|
"sourceHandle": "rvbo634w3AYj-source-sdfa",
|
||||||
"targetHandle": "7kwgL1dVlwG6-target-left"
|
"targetHandle": "7kwgL1dVlwG6-target-left"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"chatConfig": {
|
||||||
|
"scheduledTriggerConfig": {
|
||||||
|
"cronString": "",
|
||||||
|
"timezone": "Asia/Shanghai",
|
||||||
|
"defaultPrompt": ""
|
||||||
|
},
|
||||||
|
"welcomeText": "你好,我是知识库助手,请不要忘记选择知识库噢~\n[你是谁]\n[如何使用]"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
443
projects/app/public/openapi/index.html
Normal file
@@ -6,7 +6,6 @@ import {
|
|||||||
Flex,
|
Flex,
|
||||||
ModalBody,
|
ModalBody,
|
||||||
useDisclosure,
|
useDisclosure,
|
||||||
Image,
|
|
||||||
HStack,
|
HStack,
|
||||||
Switch,
|
Switch,
|
||||||
ModalFooter
|
ModalFooter
|
||||||
|
|||||||
@@ -9,13 +9,11 @@ import { formatChatValue2InputType } from '../utils';
|
|||||||
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
import { ChatRoleEnum } from '@fastgpt/global/core/chat/constants';
|
||||||
import { ChatBoxContext } from '../Provider';
|
import { ChatBoxContext } from '../Provider';
|
||||||
import { useContextSelector } from 'use-context-selector';
|
import { useContextSelector } from 'use-context-selector';
|
||||||
import { SendPromptFnType } from '../type';
|
|
||||||
|
|
||||||
export type ChatControllerProps = {
|
export type ChatControllerProps = {
|
||||||
isLastChild: boolean;
|
isLastChild: boolean;
|
||||||
chat: ChatSiteItemType;
|
chat: ChatSiteItemType;
|
||||||
showVoiceIcon?: boolean;
|
showVoiceIcon?: boolean;
|
||||||
onSendMessage: SendPromptFnType;
|
|
||||||
onRetry?: () => void;
|
onRetry?: () => void;
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
onMark?: () => void;
|
onMark?: () => void;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { useCopyData } from '@/web/common/hooks/useCopyData';
|
|||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { SendPromptFnType } from '../type';
|
|
||||||
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
import { AIChatItemValueItemType, ChatItemValueItemType } from '@fastgpt/global/core/chat/type';
|
||||||
import { CodeClassNameEnum } from '@/components/Markdown/utils';
|
import { CodeClassNameEnum } from '@/components/Markdown/utils';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
@@ -51,7 +50,6 @@ type BasicProps = {
|
|||||||
|
|
||||||
type Props = BasicProps & {
|
type Props = BasicProps & {
|
||||||
type: ChatRoleEnum.Human | ChatRoleEnum.AI;
|
type: ChatRoleEnum.Human | ChatRoleEnum.AI;
|
||||||
onSendMessage: SendPromptFnType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const RenderQuestionGuide = ({ questionGuides }: { questionGuides: string[] }) => {
|
const RenderQuestionGuide = ({ questionGuides }: { questionGuides: string[] }) => {
|
||||||
@@ -80,14 +78,12 @@ const AIContentCard = React.memo(function AIContentCard({
|
|||||||
dataId,
|
dataId,
|
||||||
isLastChild,
|
isLastChild,
|
||||||
isChatting,
|
isChatting,
|
||||||
onSendMessage,
|
|
||||||
questionGuides
|
questionGuides
|
||||||
}: {
|
}: {
|
||||||
dataId: string;
|
dataId: string;
|
||||||
chatValue: ChatItemValueItemType[];
|
chatValue: ChatItemValueItemType[];
|
||||||
isLastChild: boolean;
|
isLastChild: boolean;
|
||||||
isChatting: boolean;
|
isChatting: boolean;
|
||||||
onSendMessage: SendPromptFnType;
|
|
||||||
questionGuides: string[];
|
questionGuides: string[];
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -101,7 +97,6 @@ const AIContentCard = React.memo(function AIContentCard({
|
|||||||
value={value}
|
value={value}
|
||||||
isLastChild={isLastChild && i === chatValue.length - 1}
|
isLastChild={isLastChild && i === chatValue.length - 1}
|
||||||
isChatting={isChatting}
|
isChatting={isChatting}
|
||||||
onSendMessage={onSendMessage}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -113,16 +108,7 @@ const AIContentCard = React.memo(function AIContentCard({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const ChatItem = (props: Props) => {
|
const ChatItem = (props: Props) => {
|
||||||
const {
|
const { type, avatar, statusBoxData, children, isLastChild, questionGuides = [], chat } = props;
|
||||||
type,
|
|
||||||
avatar,
|
|
||||||
statusBoxData,
|
|
||||||
children,
|
|
||||||
isLastChild,
|
|
||||||
questionGuides = [],
|
|
||||||
onSendMessage,
|
|
||||||
chat
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
const styleMap: BoxProps =
|
const styleMap: BoxProps =
|
||||||
type === ChatRoleEnum.Human
|
type === ChatRoleEnum.Human
|
||||||
@@ -270,7 +256,6 @@ const ChatItem = (props: Props) => {
|
|||||||
dataId={chat.dataId}
|
dataId={chat.dataId}
|
||||||
isLastChild={isLastChild && i === splitAiResponseResults.length - 1}
|
isLastChild={isLastChild && i === splitAiResponseResults.length - 1}
|
||||||
isChatting={isChatting}
|
isChatting={isChatting}
|
||||||
onSendMessage={onSendMessage}
|
|
||||||
questionGuides={questionGuides}
|
questionGuides={questionGuides}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ import dynamic from 'next/dynamic';
|
|||||||
import type { StreamResponseType } from '@/web/common/api/fetch';
|
import type { StreamResponseType } from '@/web/common/api/fetch';
|
||||||
import { useContextSelector } from 'use-context-selector';
|
import { useContextSelector } from 'use-context-selector';
|
||||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||||
import { useCreation, useMemoizedFn, useThrottleFn, useTrackedEffect } from 'ahooks';
|
import { useCreation, useMemoizedFn, useThrottleFn } from 'ahooks';
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
|
|
||||||
const ResponseTags = dynamic(() => import('./components/ResponseTags'));
|
const ResponseTags = dynamic(() => import('./components/ResponseTags'));
|
||||||
@@ -832,12 +832,10 @@ const ChatBox = (
|
|||||||
};
|
};
|
||||||
window.addEventListener('message', windowMessage);
|
window.addEventListener('message', windowMessage);
|
||||||
|
|
||||||
eventBus.on(EventNameEnum.sendQuestion, ({ text }: { text: string }) => {
|
const fn: SendPromptFnType = (e) => {
|
||||||
if (!text) return;
|
sendPrompt(e);
|
||||||
sendPrompt({
|
};
|
||||||
text
|
eventBus.on(EventNameEnum.sendQuestion, fn);
|
||||||
});
|
|
||||||
});
|
|
||||||
eventBus.on(EventNameEnum.editQuestion, ({ text }: { text: string }) => {
|
eventBus.on(EventNameEnum.editQuestion, ({ text }: { text: string }) => {
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
resetInputVal({ text });
|
resetInputVal({ text });
|
||||||
@@ -881,7 +879,6 @@ const ChatBox = (
|
|||||||
onRetry={retryInput(item.dataId)}
|
onRetry={retryInput(item.dataId)}
|
||||||
onDelete={delOneMessage(item.dataId)}
|
onDelete={delOneMessage(item.dataId)}
|
||||||
isLastChild={index === chatHistories.length - 1}
|
isLastChild={index === chatHistories.length - 1}
|
||||||
onSendMessage={sendPrompt}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{item.obj === ChatRoleEnum.AI && (
|
{item.obj === ChatRoleEnum.AI && (
|
||||||
@@ -891,7 +888,6 @@ const ChatBox = (
|
|||||||
avatar={appAvatar}
|
avatar={appAvatar}
|
||||||
chat={item}
|
chat={item}
|
||||||
isLastChild={index === chatHistories.length - 1}
|
isLastChild={index === chatHistories.length - 1}
|
||||||
onSendMessage={sendPrompt}
|
|
||||||
{...{
|
{...{
|
||||||
showVoiceIcon,
|
showVoiceIcon,
|
||||||
shareId,
|
shareId,
|
||||||
@@ -977,7 +973,6 @@ const ChatBox = (
|
|||||||
outLinkUid,
|
outLinkUid,
|
||||||
questionGuides,
|
questionGuides,
|
||||||
retryInput,
|
retryInput,
|
||||||
sendPrompt,
|
|
||||||
shareId,
|
shareId,
|
||||||
showEmpty,
|
showEmpty,
|
||||||
showMarkIcon,
|
showMarkIcon,
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export const checkIsInteractiveByHistories = (chatHistories: ChatSiteItemType[])
|
|||||||
] as AIChatItemValueItemType;
|
] as AIChatItemValueItemType;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
lastMessageValue &&
|
||||||
lastMessageValue.type === ChatItemValueTypeEnum.interactive &&
|
lastMessageValue.type === ChatItemValueTypeEnum.interactive &&
|
||||||
!!lastMessageValue?.interactive?.params &&
|
!!lastMessageValue?.interactive?.params &&
|
||||||
// 如果用户选择了,则不认为是交互模式(可能是上一轮以交互结尾,发起的新的一轮对话)
|
// 如果用户选择了,则不认为是交互模式(可能是上一轮以交互结尾,发起的新的一轮对话)
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import { ChatSiteItemType } from '@fastgpt/global/core/chat/type';
|
|||||||
import { useCallback, useRef, useState } from 'react';
|
import { useCallback, useRef, useState } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { PluginRunBoxTabEnum } from './PluginRunBox/constants';
|
import { PluginRunBoxTabEnum } from './PluginRunBox/constants';
|
||||||
import { ComponentRef as ChatComponentRef } from './ChatBox/type';
|
import { ComponentRef as ChatComponentRef, SendPromptFnType } from './ChatBox/type';
|
||||||
|
import { eventBus, EventNameEnum } from '@/web/common/utils/eventbus';
|
||||||
|
|
||||||
export const useChat = () => {
|
export const useChat = () => {
|
||||||
const ChatBoxRef = useRef<ChatComponentRef>(null);
|
const ChatBoxRef = useRef<ChatComponentRef>(null);
|
||||||
@@ -61,3 +62,5 @@ export const useChat = () => {
|
|||||||
resetChatRecords
|
resetChatRecords
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const onSendPrompt: SendPromptFnType = (e) => eventBus.emit(EventNameEnum.sendQuestion, e);
|
||||||
|
|||||||
@@ -12,24 +12,20 @@ import {
|
|||||||
import { ChatItemValueTypeEnum } from '@fastgpt/global/core/chat/constants';
|
import { ChatItemValueTypeEnum } from '@fastgpt/global/core/chat/constants';
|
||||||
import {
|
import {
|
||||||
AIChatItemValueItemType,
|
AIChatItemValueItemType,
|
||||||
ChatSiteItemType,
|
|
||||||
ToolModuleResponseItemType,
|
ToolModuleResponseItemType,
|
||||||
UserChatItemValueItemType
|
UserChatItemValueItemType
|
||||||
} from '@fastgpt/global/core/chat/type';
|
} from '@fastgpt/global/core/chat/type';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||||
import { SendPromptFnType } from '../ChatContainer/ChatBox/type';
|
|
||||||
import { useContextSelector } from 'use-context-selector';
|
|
||||||
import { ChatBoxContext } from '../ChatContainer/ChatBox/Provider';
|
|
||||||
import { InteractiveNodeResponseItemType } from '@fastgpt/global/core/workflow/template/system/userSelect/type';
|
import { InteractiveNodeResponseItemType } from '@fastgpt/global/core/workflow/template/system/userSelect/type';
|
||||||
import { isEqual } from 'lodash';
|
import { isEqual } from 'lodash';
|
||||||
|
import { onSendPrompt } from '../ChatContainer/useChat';
|
||||||
|
|
||||||
type props = {
|
type props = {
|
||||||
value: UserChatItemValueItemType | AIChatItemValueItemType;
|
value: UserChatItemValueItemType | AIChatItemValueItemType;
|
||||||
isLastChild: boolean;
|
isLastChild: boolean;
|
||||||
isChatting: boolean;
|
isChatting: boolean;
|
||||||
onSendMessage?: SendPromptFnType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const RenderText = React.memo(function RenderText({
|
const RenderText = React.memo(function RenderText({
|
||||||
@@ -128,67 +124,51 @@ ${toolResponse}`}
|
|||||||
},
|
},
|
||||||
(prevProps, nextProps) => isEqual(prevProps, nextProps)
|
(prevProps, nextProps) => isEqual(prevProps, nextProps)
|
||||||
);
|
);
|
||||||
const RenderInteractive = React.memo(
|
const RenderInteractive = React.memo(function RenderInteractive({
|
||||||
function RenderInteractive({
|
interactive
|
||||||
isChatting,
|
}: {
|
||||||
interactive,
|
interactive: InteractiveNodeResponseItemType;
|
||||||
onSendMessage,
|
}) {
|
||||||
chatHistories
|
return (
|
||||||
}: {
|
<>
|
||||||
isChatting: boolean;
|
{interactive?.params?.description && <Markdown source={interactive.params.description} />}
|
||||||
interactive: InteractiveNodeResponseItemType;
|
<Flex flexDirection={'column'} gap={2} w={'250px'}>
|
||||||
onSendMessage?: SendPromptFnType;
|
{interactive.params.userSelectOptions?.map((option) => {
|
||||||
chatHistories: ChatSiteItemType[];
|
const selected = option.value === interactive?.params?.userSelectedVal;
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{interactive?.params?.description && <Markdown source={interactive.params.description} />}
|
|
||||||
<Flex flexDirection={'column'} gap={2} w={'250px'}>
|
|
||||||
{interactive.params.userSelectOptions?.map((option) => {
|
|
||||||
const selected = option.value === interactive?.params?.userSelectedVal;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
key={option.key}
|
key={option.key}
|
||||||
variant={'whitePrimary'}
|
variant={'whitePrimary'}
|
||||||
whiteSpace={'pre-wrap'}
|
whiteSpace={'pre-wrap'}
|
||||||
isDisabled={interactive?.params?.userSelectedVal !== undefined}
|
isDisabled={interactive?.params?.userSelectedVal !== undefined}
|
||||||
{...(selected
|
{...(selected
|
||||||
? {
|
? {
|
||||||
_disabled: {
|
_disabled: {
|
||||||
cursor: 'default',
|
cursor: 'default',
|
||||||
borderColor: 'primary.300',
|
borderColor: 'primary.300',
|
||||||
bg: 'primary.50 !important',
|
bg: 'primary.50 !important',
|
||||||
color: 'primary.600'
|
color: 'primary.600'
|
||||||
}
|
|
||||||
}
|
}
|
||||||
: {})}
|
}
|
||||||
onClick={() => {
|
: {})}
|
||||||
onSendMessage?.({
|
onClick={() => {
|
||||||
text: option.value,
|
onSendPrompt({
|
||||||
isInteractivePrompt: true
|
text: option.value,
|
||||||
});
|
isInteractivePrompt: true
|
||||||
}}
|
});
|
||||||
>
|
}}
|
||||||
{option.value}
|
>
|
||||||
</Button>
|
{option.value}
|
||||||
);
|
</Button>
|
||||||
})}
|
);
|
||||||
</Flex>
|
})}
|
||||||
</>
|
</Flex>
|
||||||
);
|
</>
|
||||||
},
|
);
|
||||||
(
|
});
|
||||||
prevProps,
|
|
||||||
nextProps // isChatting 更新时候,onSendMessage 和 chatHistories 肯定都更新了,这里不需要额外的刷新
|
|
||||||
) =>
|
|
||||||
prevProps.isChatting === nextProps.isChatting &&
|
|
||||||
isEqual(prevProps.interactive, nextProps.interactive)
|
|
||||||
);
|
|
||||||
|
|
||||||
const AIResponseBox = ({ value, isLastChild, isChatting, onSendMessage }: props) => {
|
|
||||||
const chatHistories = useContextSelector(ChatBoxContext, (v) => v.chatHistories);
|
|
||||||
|
|
||||||
|
const AIResponseBox = ({ value, isLastChild, isChatting }: props) => {
|
||||||
if (value.type === ChatItemValueTypeEnum.text && value.text)
|
if (value.type === ChatItemValueTypeEnum.text && value.text)
|
||||||
return <RenderText showAnimation={isChatting && isLastChild} text={value.text.content} />;
|
return <RenderText showAnimation={isChatting && isLastChild} text={value.text.content} />;
|
||||||
if (value.type === ChatItemValueTypeEnum.tool && value.tools)
|
if (value.type === ChatItemValueTypeEnum.tool && value.tools)
|
||||||
@@ -198,14 +178,7 @@ const AIResponseBox = ({ value, isLastChild, isChatting, onSendMessage }: props)
|
|||||||
value.interactive &&
|
value.interactive &&
|
||||||
value.interactive.type === 'userSelect'
|
value.interactive.type === 'userSelect'
|
||||||
)
|
)
|
||||||
return (
|
return <RenderInteractive interactive={value.interactive} />;
|
||||||
<RenderInteractive
|
|
||||||
isChatting={isChatting}
|
|
||||||
interactive={value.interactive}
|
|
||||||
onSendMessage={onSendMessage}
|
|
||||||
chatHistories={chatHistories}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default React.memo(AIResponseBox);
|
export default React.memo(AIResponseBox);
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import MyModal from '@fastgpt/web/components/common/MyModal';
|
import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { Box, ModalBody } from '@chakra-ui/react';
|
import { Box, ModalBody } from '@chakra-ui/react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
|
||||||
import { checkBalancePayResult } from '@/web/support/wallet/bill/api';
|
import { checkBalancePayResult } from '@/web/support/wallet/bill/api';
|
||||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
@@ -24,62 +23,64 @@ const QRCodePayModal = ({
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const dom = document.getElementById('payQRCode');
|
const dom = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dom && window.QRCode) {
|
let timer: NodeJS.Timeout;
|
||||||
new window.QRCode(dom, {
|
const drawCode = () => {
|
||||||
text: codeUrl,
|
if (dom.current && window.QRCode && !dom.current.innerHTML) {
|
||||||
width: 128,
|
new window.QRCode(dom.current, {
|
||||||
height: 128,
|
text: codeUrl,
|
||||||
colorDark: '#000000',
|
width: 128,
|
||||||
colorLight: '#ffffff',
|
height: 128,
|
||||||
correctLevel: window.QRCode.CorrectLevel.H
|
colorDark: '#000000',
|
||||||
});
|
colorLight: '#ffffff',
|
||||||
}
|
correctLevel: window.QRCode.CorrectLevel.H
|
||||||
}, [dom]);
|
});
|
||||||
|
|
||||||
useQuery(
|
|
||||||
[billId],
|
|
||||||
() => {
|
|
||||||
if (!billId) return null;
|
|
||||||
return checkBalancePayResult(billId);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
enabled: !!billId,
|
|
||||||
refetchInterval: 3000,
|
|
||||||
onSuccess: async (res) => {
|
|
||||||
if (!res) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await onSuccess?.();
|
|
||||||
toast({
|
|
||||||
title: res,
|
|
||||||
status: 'success'
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
toast({
|
|
||||||
title: getErrText(error),
|
|
||||||
status: 'error'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
router.reload();
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
);
|
const check = async () => {
|
||||||
|
try {
|
||||||
|
const res = await checkBalancePayResult(billId);
|
||||||
|
if (res) {
|
||||||
|
try {
|
||||||
|
await onSuccess?.();
|
||||||
|
toast({
|
||||||
|
title: res,
|
||||||
|
status: 'success'
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
router.reload();
|
||||||
|
}, 1000);
|
||||||
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: getErrText(error),
|
||||||
|
status: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
|
||||||
|
drawCode();
|
||||||
|
|
||||||
|
timer = setTimeout(check, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
check();
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [billId, onSuccess, toast]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
|
<MyModal isOpen title={t('common:user.Pay')} iconSrc="/imgs/modal/pay.svg">
|
||||||
<ModalBody textAlign={'center'} py={6} whiteSpace={'pre'}>
|
<ModalBody textAlign={'center'} py={6} whiteSpace={'pre-wrap'}>
|
||||||
{tip && (
|
{tip && (
|
||||||
<Box fontSize={'sm'} whiteSpace={'pre'} mb={3}>
|
<Box fontSize={'sm'} whiteSpace={'pre'} mb={3}>
|
||||||
{tip}
|
{tip}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
<Box id={'payQRCode'} display={'inline-block'} h={'128px'}></Box>
|
<Box ref={dom} id={'payQRCode'} display={'inline-block'} h={'128px'}></Box>
|
||||||
<Box mt={3} textAlign={'center'}>
|
<Box mt={3} textAlign={'center'}>
|
||||||
{t('common:pay.wechat', { price: readPrice })}
|
{t('common:pay.wechat', { price: readPrice })}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import { getPromotionInitData, getPromotionRecords } from '@/web/support/activit
|
|||||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||||
|
|
||||||
import { useCopyData } from '@/web/common/hooks/useCopyData';
|
import { useCopyData } from '@/web/common/hooks/useCopyData';
|
||||||
import type { PromotionRecordType } from '@/global/support/api/userRes.d';
|
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
||||||
import { useLoading } from '@fastgpt/web/hooks/useLoading';
|
import { useLoading } from '@fastgpt/web/hooks/useLoading';
|
||||||
@@ -40,7 +39,7 @@ const Promotion = () => {
|
|||||||
total,
|
total,
|
||||||
pageSize,
|
pageSize,
|
||||||
Pagination
|
Pagination
|
||||||
} = usePagination<PromotionRecordType>({
|
} = usePagination({
|
||||||
api: getPromotionRecords,
|
api: getPromotionRecords,
|
||||||
pageSize: 20
|
pageSize: 20
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const BillTable = () => {
|
|||||||
Pagination,
|
Pagination,
|
||||||
getData,
|
getData,
|
||||||
total
|
total
|
||||||
} = usePagination<BillSchemaType>({
|
} = usePagination({
|
||||||
api: getBills,
|
api: getBills,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
params: {
|
params: {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const InvoiceTable = () => {
|
|||||||
Pagination,
|
Pagination,
|
||||||
getData,
|
getData,
|
||||||
total
|
total
|
||||||
} = usePagination<InvoiceSchemaType>({
|
} = usePagination({
|
||||||
api: getInvoiceRecords,
|
api: getInvoiceRecords,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
defaultRequest: false
|
defaultRequest: false
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
data: {
|
data: {
|
||||||
feConfigs: global.feConfigs,
|
feConfigs: global.feConfigs,
|
||||||
subPlans: global.subPlans,
|
subPlans: global.subPlans,
|
||||||
llmModels: global.llmModels,
|
llmModels: global.llmModels.map((model) => ({
|
||||||
|
...model,
|
||||||
|
customCQPrompt: '',
|
||||||
|
customExtractPrompt: '',
|
||||||
|
defaultSystemChatPrompt: ''
|
||||||
|
})),
|
||||||
vectorModels: global.vectorModels,
|
vectorModels: global.vectorModels,
|
||||||
reRankModels:
|
reRankModels:
|
||||||
global.reRankModels?.map((item) => ({
|
global.reRankModels?.map((item) => ({
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { readFromSecondary } from '@fastgpt/service/common/mongo/utils';
|
|||||||
|
|
||||||
async function handler(
|
async function handler(
|
||||||
req: NextApiRequest,
|
req: NextApiRequest,
|
||||||
res: NextApiResponse
|
_res: NextApiResponse
|
||||||
): Promise<PagingData<AppLogsListItemType>> {
|
): Promise<PagingData<AppLogsListItemType>> {
|
||||||
const {
|
const {
|
||||||
pageNum = 1,
|
pageNum = 1,
|
||||||
@@ -131,7 +131,9 @@ async function handler(
|
|||||||
userGoodFeedbackCount: 1,
|
userGoodFeedbackCount: 1,
|
||||||
userBadFeedbackCount: 1,
|
userBadFeedbackCount: 1,
|
||||||
customFeedbacksCount: 1,
|
customFeedbacksCount: 1,
|
||||||
markCount: 1
|
markCount: 1,
|
||||||
|
outLinkUid: 1,
|
||||||
|
tmbId: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import {
|
|||||||
import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
import { StoreNodeItemType } from '@fastgpt/global/core/workflow/type/node';
|
||||||
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
||||||
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
messages: ChatCompletionMessageParam[];
|
messages: ChatCompletionMessageParam[];
|
||||||
@@ -120,7 +121,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
chatConfig,
|
chatConfig,
|
||||||
histories: chatMessages,
|
histories: chatMessages,
|
||||||
stream: true,
|
stream: true,
|
||||||
maxRunTimes: 200,
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES,
|
||||||
workflowStreamResponse: workflowResponseWrite
|
workflowStreamResponse: workflowResponseWrite
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,7 @@ async function handler(req: NextApiRequest): Promise<DatasetSimpleItemType[]> {
|
|||||||
|
|
||||||
const [myDatasets, rpList] = await Promise.all([
|
const [myDatasets, rpList] = await Promise.all([
|
||||||
MongoDataset.find({
|
MongoDataset.find({
|
||||||
teamId,
|
teamId
|
||||||
type: {
|
|
||||||
$ne: DatasetTypeEnum.folder
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.sort({
|
.sort({
|
||||||
updateTime: -1
|
updateTime: -1
|
||||||
@@ -45,9 +42,29 @@ async function handler(req: NextApiRequest): Promise<DatasetSimpleItemType[]> {
|
|||||||
|
|
||||||
const filterDatasets = myDatasets
|
const filterDatasets = myDatasets
|
||||||
.map((dataset) => {
|
.map((dataset) => {
|
||||||
const perVal = rpList.find(
|
const perVal = (() => {
|
||||||
(item) => String(item.resourceId) === String(dataset._id)
|
const perVal = rpList.find(
|
||||||
)?.permission;
|
(item) => String(item.resourceId) === String(dataset._id)
|
||||||
|
)?.permission;
|
||||||
|
if (perVal) {
|
||||||
|
return perVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataset.inheritPermission && dataset.parentId) {
|
||||||
|
const parentDataset = myDatasets.find(
|
||||||
|
(item) => String(item._id) === String(dataset.parentId)
|
||||||
|
);
|
||||||
|
if (parentDataset) {
|
||||||
|
const parentPerVal =
|
||||||
|
rpList.find((item) => String(item.resourceId) === String(parentDataset._id))
|
||||||
|
?.permission ?? parentDataset.defaultPermission;
|
||||||
|
if (parentPerVal) {
|
||||||
|
return parentPerVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
const Per = new DatasetPermission({
|
const Per = new DatasetPermission({
|
||||||
per: perVal ?? dataset.defaultPermission,
|
per: perVal ?? dataset.defaultPermission,
|
||||||
isOwner: String(dataset.tmbId) === tmbId || tmbPer.isOwner
|
isOwner: String(dataset.tmbId) === tmbId || tmbPer.isOwner
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { PostWorkflowDebugProps, PostWorkflowDebugResponse } from '@/global/core
|
|||||||
import { NextAPI } from '@/service/middleware/entry';
|
import { NextAPI } from '@/service/middleware/entry';
|
||||||
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||||
import { defaultApp } from '@/web/core/app/constants';
|
import { defaultApp } from '@/web/core/app/constants';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
|
|
||||||
async function handler(
|
async function handler(
|
||||||
req: NextApiRequest,
|
req: NextApiRequest,
|
||||||
@@ -57,7 +58,7 @@ async function handler(
|
|||||||
chatConfig: defaultApp.chatConfig,
|
chatConfig: defaultApp.chatConfig,
|
||||||
histories: [],
|
histories: [],
|
||||||
stream: false,
|
stream: false,
|
||||||
maxRunTimes: 200
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES
|
||||||
});
|
});
|
||||||
|
|
||||||
pushChatUsage({
|
pushChatUsage({
|
||||||
|
|||||||
@@ -4,13 +4,25 @@ import { ManagePermissionVal } from '@fastgpt/global/support/permission/constant
|
|||||||
import type { ApiRequestProps } from '@fastgpt/service/type/next';
|
import type { ApiRequestProps } from '@fastgpt/service/type/next';
|
||||||
import { NextAPI } from '@/service/middleware/entry';
|
import { NextAPI } from '@/service/middleware/entry';
|
||||||
import { OutLinkSchema } from '@fastgpt/global/support/outLink/type';
|
import { OutLinkSchema } from '@fastgpt/global/support/outLink/type';
|
||||||
export type OutLinkListQuery = {
|
|
||||||
appId: string;
|
export const ApiMetadata = {
|
||||||
type: string;
|
name: '获取应用内所有 Outlink',
|
||||||
|
author: 'Finley',
|
||||||
|
version: '0.1.0'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Outlink
|
||||||
|
export type OutLinkListQuery = {
|
||||||
|
appId: string; // 应用 ID
|
||||||
|
type: string; // 类型
|
||||||
|
};
|
||||||
|
|
||||||
export type OutLinkListBody = {};
|
export type OutLinkListBody = {};
|
||||||
|
|
||||||
|
// 响应: 应用内全部 Outlink
|
||||||
export type OutLinkListResponse = OutLinkSchema[];
|
export type OutLinkListResponse = OutLinkSchema[];
|
||||||
|
|
||||||
|
// 查询应用内全部 Outlink
|
||||||
async function handler(
|
async function handler(
|
||||||
req: ApiRequestProps<OutLinkListBody, OutLinkListQuery>
|
req: ApiRequestProps<OutLinkListBody, OutLinkListQuery>
|
||||||
): Promise<OutLinkListResponse> {
|
): Promise<OutLinkListResponse> {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { connectToDatabase } from '@/service/mongo';
|
|||||||
import { getUserDetail } from '@fastgpt/service/support/user/controller';
|
import { getUserDetail } from '@fastgpt/service/support/user/controller';
|
||||||
import type { PostLoginProps } from '@fastgpt/global/support/user/api.d';
|
import type { PostLoginProps } from '@fastgpt/global/support/user/api.d';
|
||||||
import { UserStatusEnum } from '@fastgpt/global/support/user/constant';
|
import { UserStatusEnum } from '@fastgpt/global/support/user/constant';
|
||||||
import { checkTeamAiPointsAndLock } from '@/service/events/utils';
|
|
||||||
|
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
try {
|
try {
|
||||||
@@ -50,7 +49,11 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
|||||||
lastLoginTmbId: userDetail.team.tmbId
|
lastLoginTmbId: userDetail.team.tmbId
|
||||||
});
|
});
|
||||||
|
|
||||||
const token = createJWT(userDetail);
|
const token = createJWT({
|
||||||
|
...userDetail,
|
||||||
|
isRoot: username === 'root'
|
||||||
|
});
|
||||||
|
|
||||||
setCookie(res, token);
|
setCookie(res, token);
|
||||||
|
|
||||||
jsonRes(res, {
|
jsonRes(res, {
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import { getSystemTime } from '@fastgpt/global/common/time/timezone';
|
|||||||
import { rewriteNodeOutputByHistories } from '@fastgpt/global/core/workflow/runtime/utils';
|
import { rewriteNodeOutputByHistories } from '@fastgpt/global/core/workflow/runtime/utils';
|
||||||
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
import { getWorkflowResponseWrite } from '@fastgpt/service/core/workflow/dispatch/utils';
|
||||||
import { getPluginRunUserQuery } from '@fastgpt/service/core/workflow/utils';
|
import { getPluginRunUserQuery } from '@fastgpt/service/core/workflow/utils';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
|
|
||||||
type FastGptWebChatProps = {
|
type FastGptWebChatProps = {
|
||||||
chatId?: string; // undefined: get histories from messages, '': new chat, 'xxxxx': get histories from db
|
chatId?: string; // undefined: get histories from messages, '': new chat, 'xxxxx': get histories from db
|
||||||
@@ -264,7 +265,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
chatConfig,
|
chatConfig,
|
||||||
histories: newHistories,
|
histories: newHistories,
|
||||||
stream,
|
stream,
|
||||||
maxRunTimes: 200,
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES,
|
||||||
workflowStreamResponse: workflowResponseWrite
|
workflowStreamResponse: workflowResponseWrite
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,12 @@ import {
|
|||||||
ModalBody,
|
ModalBody,
|
||||||
HStack
|
HStack
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
|
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { getAppChatLogs } from '@/web/core/app/api';
|
import { getAppChatLogs } from '@/web/core/app/api';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { ChatSourceMap } from '@fastgpt/global/core/chat/constants';
|
import { ChatSourceMap } from '@fastgpt/global/core/chat/constants';
|
||||||
import { AppLogsListItemType } from '@/types/app';
|
|
||||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
|
||||||
import MyModal from '@fastgpt/web/components/common/MyModal';
|
import MyModal from '@fastgpt/web/components/common/MyModal';
|
||||||
import { addDays } from 'date-fns';
|
import { addDays } from 'date-fns';
|
||||||
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
||||||
@@ -32,6 +31,8 @@ import { cardStyles } from '../constants';
|
|||||||
|
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
import { useSystem } from '@fastgpt/web/hooks/useSystem';
|
||||||
|
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||||
|
import Tag from '@fastgpt/web/components/common/Tag';
|
||||||
const DetailLogsModal = dynamic(() => import('./DetailLogsModal'));
|
const DetailLogsModal = dynamic(() => import('./DetailLogsModal'));
|
||||||
|
|
||||||
const Logs = () => {
|
const Logs = () => {
|
||||||
@@ -40,6 +41,7 @@ const Logs = () => {
|
|||||||
const { isPc } = useSystem();
|
const { isPc } = useSystem();
|
||||||
|
|
||||||
const appId = useContextSelector(AppContext, (v) => v.appId);
|
const appId = useContextSelector(AppContext, (v) => v.appId);
|
||||||
|
const { teamMembers } = useUserStore();
|
||||||
|
|
||||||
const [dateRange, setDateRange] = useState<DateRangeType>({
|
const [dateRange, setDateRange] = useState<DateRangeType>({
|
||||||
from: addDays(new Date(), -7),
|
from: addDays(new Date(), -7),
|
||||||
@@ -58,7 +60,7 @@ const Logs = () => {
|
|||||||
Pagination,
|
Pagination,
|
||||||
getData,
|
getData,
|
||||||
pageNum
|
pageNum
|
||||||
} = usePagination<AppLogsListItemType>({
|
} = usePagination({
|
||||||
api: getAppChatLogs,
|
api: getAppChatLogs,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
params: {
|
params: {
|
||||||
@@ -107,11 +109,12 @@ const Logs = () => {
|
|||||||
<Thead>
|
<Thead>
|
||||||
<Tr>
|
<Tr>
|
||||||
<Th>{t('common:core.app.logs.Source And Time')}</Th>
|
<Th>{t('common:core.app.logs.Source And Time')}</Th>
|
||||||
<Th>{appT('logs_title')}</Th>
|
<Th>{t('app:logs_chat_user')}</Th>
|
||||||
<Th>{appT('logs_message_total')}</Th>
|
<Th>{t('app:logs_title')}</Th>
|
||||||
<Th>{appT('feedback_count')}</Th>
|
<Th>{t('app:logs_message_total')}</Th>
|
||||||
|
<Th>{t('app:feedback_count')}</Th>
|
||||||
<Th>{t('common:core.app.feedback.Custom feedback')}</Th>
|
<Th>{t('common:core.app.feedback.Custom feedback')}</Th>
|
||||||
<Th>{appT('mark_count')}</Th>
|
<Th>{t('app:mark_count')}</Th>
|
||||||
</Tr>
|
</Tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
<Tbody fontSize={'xs'}>
|
<Tbody fontSize={'xs'}>
|
||||||
@@ -127,6 +130,23 @@ const Logs = () => {
|
|||||||
<Box>{t(ChatSourceMap[item.source]?.name || ('UnKnow' as any))}</Box>
|
<Box>{t(ChatSourceMap[item.source]?.name || ('UnKnow' as any))}</Box>
|
||||||
<Box color={'myGray.500'}>{dayjs(item.time).format('YYYY/MM/DD HH:mm')}</Box>
|
<Box color={'myGray.500'}>{dayjs(item.time).format('YYYY/MM/DD HH:mm')}</Box>
|
||||||
</Td>
|
</Td>
|
||||||
|
<Td>
|
||||||
|
<Box>
|
||||||
|
{item.source === 'share' ? (
|
||||||
|
item.outLinkUid
|
||||||
|
) : (
|
||||||
|
<Tag key={item._id} type={'fill'} colorSchema="white">
|
||||||
|
<Avatar
|
||||||
|
src={teamMembers.find((v) => v.tmbId === item.tmbId)?.avatar}
|
||||||
|
w="1.25rem"
|
||||||
|
/>
|
||||||
|
<Box fontSize={'sm'} ml={1}>
|
||||||
|
{teamMembers.find((v) => v.tmbId === item.tmbId)?.memberName}
|
||||||
|
</Box>
|
||||||
|
</Tag>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Td>
|
||||||
<Td className="textEllipsis" maxW={'250px'}>
|
<Td className="textEllipsis" maxW={'250px'}>
|
||||||
{item.title}
|
{item.title}
|
||||||
</Td>
|
</Td>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
HStack
|
HStack
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { SmallAddIcon } from '@chakra-ui/icons';
|
import { SmallAddIcon } from '@chakra-ui/icons';
|
||||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
|
||||||
import type { AppSimpleEditFormType } from '@fastgpt/global/core/app/type.d';
|
import type { AppSimpleEditFormType } from '@fastgpt/global/core/app/type.d';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
@@ -79,7 +78,6 @@ const EditForm = ({
|
|||||||
const { appDetail } = useContextSelector(AppContext, (v) => v);
|
const { appDetail } = useContextSelector(AppContext, (v) => v);
|
||||||
|
|
||||||
const { allDatasets } = useDatasetStore();
|
const { allDatasets } = useDatasetStore();
|
||||||
const { llmModelList } = useSystemStore();
|
|
||||||
const [, startTst] = useTransition();
|
const [, startTst] = useTransition();
|
||||||
|
|
||||||
const selectDatasets = useMemo(
|
const selectDatasets = useMemo(
|
||||||
@@ -506,6 +504,8 @@ const EditForm = ({
|
|||||||
...e
|
...e
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
console.dir(e);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -37,20 +37,20 @@ const NodeDatasetConcat = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
const quoteList = useMemo(() => inputs.filter((item) => item.canEdit), [inputs]);
|
const quoteList = useMemo(() => inputs.filter((item) => item.canEdit), [inputs]);
|
||||||
|
|
||||||
const tokenLimit = useMemo(() => {
|
const tokenLimit = useMemo(() => {
|
||||||
let maxTokens = 3000;
|
let maxTokens = 13000;
|
||||||
|
|
||||||
nodeList.forEach((item) => {
|
nodeList.forEach((item) => {
|
||||||
if (item.flowNodeType === FlowNodeTypeEnum.chatNode) {
|
if ([FlowNodeTypeEnum.chatNode, FlowNodeTypeEnum.tools].includes(item.flowNodeType)) {
|
||||||
const model =
|
const model =
|
||||||
item.inputs.find((item) => item.key === NodeInputKeyEnum.aiModel)?.value || '';
|
item.inputs.find((item) => item.key === NodeInputKeyEnum.aiModel)?.value || '';
|
||||||
const quoteMaxToken = getWebLLMModel(model)?.quoteMaxToken || 3000;
|
const quoteMaxToken = getWebLLMModel(model)?.quoteMaxToken || 13000;
|
||||||
|
|
||||||
maxTokens = Math.max(maxTokens, quoteMaxToken);
|
maxTokens = Math.max(maxTokens, quoteMaxToken);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return maxTokens;
|
return maxTokens;
|
||||||
}, [llmModelList, nodeList]);
|
}, [nodeList, llmModelList]);
|
||||||
|
|
||||||
const CustomComponent = useMemo(() => {
|
const CustomComponent = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
@@ -183,7 +183,7 @@ function Reference({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Flex alignItems={'center'} mb={1}>
|
<Flex alignItems={'center'} mb={1}>
|
||||||
<FormLabel required={inputChildren.required}>{inputChildren.label}</FormLabel>
|
<FormLabel required={inputChildren.required}>{t(inputChildren.label as any)}</FormLabel>
|
||||||
{/* value */}
|
{/* value */}
|
||||||
<ValueTypeLabel valueType={inputChildren.valueType} valueDesc={inputChildren.valueDesc} />
|
<ValueTypeLabel valueType={inputChildren.valueType} valueDesc={inputChildren.valueDesc} />
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const NodePluginConfig = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
debug: true,
|
debug: true,
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ const NodePluginInput = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
minW={'300px'}
|
minW={'300px'}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ const NodePluginOutput = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
debug: true,
|
debug: true,
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const NodeUserGuide = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
debug: true,
|
debug: true,
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ const NodeStart = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
|
|||||||
minW={'240px'}
|
minW={'240px'}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
menuForbid={{
|
menuForbid={{
|
||||||
rename: true,
|
|
||||||
copy: true,
|
copy: true,
|
||||||
delete: true
|
delete: true
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -11,88 +11,98 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
||||||
const edges = useContextSelector(WorkflowContext, (v) => v.edges);
|
const edges = useContextSelector(WorkflowContext, (v) => v.edges);
|
||||||
|
|
||||||
const node = useMemo(() => nodeList.find((node) => node.nodeId === nodeId), [nodeList, nodeId]);
|
const { showSourceHandle, RightHandle, LeftHandlee, TopHandlee, BottomHandlee } = useMemo(() => {
|
||||||
|
const node = nodeList.find((node) => node.nodeId === nodeId);
|
||||||
|
|
||||||
/* not node/not connecting node, hidden */
|
/* not node/not connecting node, hidden */
|
||||||
const showSourceHandle = useMemo(() => {
|
const showSourceHandle = (() => {
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
if (connectingEdge && connectingEdge.nodeId !== nodeId) return false;
|
if (connectingEdge && connectingEdge.nodeId !== nodeId) return false;
|
||||||
return true;
|
return true;
|
||||||
}, [connectingEdge, node, nodeId]);
|
})();
|
||||||
|
|
||||||
const RightHandle = useMemo(() => {
|
const RightHandle = (() => {
|
||||||
const handleId = getHandleId(nodeId, 'source', Position.Right);
|
const handleId = getHandleId(nodeId, 'source', Position.Right);
|
||||||
const rightTargetConnected = edges.some(
|
const rightTargetConnected = edges.some(
|
||||||
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Right)
|
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Right)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!node || !node?.sourceHandle?.right || rightTargetConnected) return null;
|
if (!node || !node?.sourceHandle?.right || rightTargetConnected) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SourceHandle
|
<SourceHandle
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
handleId={handleId}
|
handleId={handleId}
|
||||||
position={Position.Right}
|
position={Position.Right}
|
||||||
translate={[2, 0]}
|
translate={[2, 0]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
const LeftHandlee = useMemo(() => {
|
const LeftHandlee = (() => {
|
||||||
const leftTargetConnected = edges.some(
|
const leftTargetConnected = edges.some(
|
||||||
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Left)
|
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Left)
|
||||||
);
|
);
|
||||||
if (!node || !node?.sourceHandle?.left || leftTargetConnected) return null;
|
if (!node || !node?.sourceHandle?.left || leftTargetConnected) return null;
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'source', Position.Left);
|
const handleId = getHandleId(nodeId, 'source', Position.Left);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SourceHandle
|
<SourceHandle
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
handleId={handleId}
|
handleId={handleId}
|
||||||
position={Position.Left}
|
position={Position.Left}
|
||||||
translate={[-6, 0]}
|
translate={[-6, 0]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
const TopHandlee = useMemo(() => {
|
const TopHandlee = (() => {
|
||||||
if (
|
if (
|
||||||
edges.some(
|
edges.some(
|
||||||
(edge) => edge.target === nodeId && edge.targetHandle === NodeOutputKeyEnum.selectedTools
|
(edge) => edge.target === nodeId && edge.targetHandle === NodeOutputKeyEnum.selectedTools
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
return null;
|
||||||
return null;
|
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'source', Position.Top);
|
const handleId = getHandleId(nodeId, 'source', Position.Top);
|
||||||
const topTargetConnected = edges.some(
|
const topTargetConnected = edges.some(
|
||||||
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Top)
|
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Top)
|
||||||
);
|
);
|
||||||
if (!node || !node?.sourceHandle?.top || topTargetConnected) return null;
|
if (!node || !node?.sourceHandle?.top || topTargetConnected) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SourceHandle
|
<SourceHandle
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
handleId={handleId}
|
handleId={handleId}
|
||||||
position={Position.Top}
|
position={Position.Top}
|
||||||
translate={[0, -2]}
|
translate={[0, -2]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
const BottomHandlee = useMemo(() => {
|
const BottomHandlee = (() => {
|
||||||
const handleId = getHandleId(nodeId, 'source', Position.Bottom);
|
const handleId = getHandleId(nodeId, 'source', Position.Bottom);
|
||||||
const targetConnected = edges.some(
|
const targetConnected = edges.some(
|
||||||
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Bottom)
|
(edge) => edge.targetHandle === getHandleId(nodeId, 'target', Position.Bottom)
|
||||||
);
|
);
|
||||||
if (!node || !node?.sourceHandle?.bottom || targetConnected) return null;
|
if (!node || !node?.sourceHandle?.bottom || targetConnected) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SourceHandle
|
<SourceHandle
|
||||||
nodeId={nodeId}
|
nodeId={nodeId}
|
||||||
handleId={handleId}
|
handleId={handleId}
|
||||||
position={Position.Bottom}
|
position={Position.Bottom}
|
||||||
translate={[0, 2]}
|
translate={[0, 2]}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [edges, node, nodeId]);
|
})();
|
||||||
|
|
||||||
|
return {
|
||||||
|
showSourceHandle,
|
||||||
|
RightHandle,
|
||||||
|
LeftHandlee,
|
||||||
|
TopHandlee,
|
||||||
|
BottomHandlee
|
||||||
|
};
|
||||||
|
}, [connectingEdge, edges, nodeId, nodeList]);
|
||||||
|
|
||||||
return showSourceHandle ? (
|
return showSourceHandle ? (
|
||||||
<>
|
<>
|
||||||
@@ -104,74 +114,96 @@ export const ConnectionSourceHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
) : null;
|
) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
export const ConnectionTargetHandle = React.memo(function ConnectionTargetHandle({
|
||||||
|
nodeId
|
||||||
|
}: {
|
||||||
|
nodeId: string;
|
||||||
|
}) {
|
||||||
const connectingEdge = useContextSelector(WorkflowContext, (ctx) => ctx.connectingEdge);
|
const connectingEdge = useContextSelector(WorkflowContext, (ctx) => ctx.connectingEdge);
|
||||||
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
const nodeList = useContextSelector(WorkflowContext, (v) => v.nodeList);
|
||||||
|
const edges = useContextSelector(WorkflowContext, (v) => v.edges);
|
||||||
|
|
||||||
const node = useMemo(() => nodeList.find((node) => node.nodeId === nodeId), [nodeList, nodeId]);
|
const { showHandle, LeftHandle, rightHandle, topHandle, bottomHandle } = useMemo(() => {
|
||||||
|
const node = nodeList.find((node) => node.nodeId === nodeId);
|
||||||
|
const connectingNode = nodeList.find((node) => node.nodeId === connectingEdge?.nodeId);
|
||||||
|
|
||||||
const showHandle = useMemo(() => {
|
const sourceEdges = edges.filter((edge) => edge.target === connectingNode?.nodeId);
|
||||||
if (!node) return false;
|
const connectingNodeSourceNodeIds = sourceEdges.map((edge) => edge.source);
|
||||||
if (connectingEdge && connectingEdge.nodeId === nodeId) return false;
|
|
||||||
return true;
|
|
||||||
}, [connectingEdge, node, nodeId]);
|
|
||||||
|
|
||||||
const LeftHandle = useMemo(() => {
|
const showHandle = (() => {
|
||||||
if (!node || !node?.targetHandle?.left) return null;
|
if (!node) return false;
|
||||||
|
// Unable to connect oneself
|
||||||
|
if (connectingEdge && connectingEdge.nodeId === nodeId) return false;
|
||||||
|
// Unable to connect to the source node
|
||||||
|
if (connectingNodeSourceNodeIds.includes(nodeId)) return false;
|
||||||
|
return true;
|
||||||
|
})();
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Left);
|
const LeftHandle = (() => {
|
||||||
|
if (!node || !node?.targetHandle?.left) return null;
|
||||||
|
|
||||||
return (
|
const handleId = getHandleId(nodeId, 'target', Position.Left);
|
||||||
<TargetHandle
|
|
||||||
nodeId={nodeId}
|
|
||||||
handleId={handleId}
|
|
||||||
position={Position.Left}
|
|
||||||
translate={[-2, 0]}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}, [node, nodeId]);
|
|
||||||
const rightHandle = useMemo(() => {
|
|
||||||
if (!node || !node?.targetHandle?.right) return null;
|
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Right);
|
return (
|
||||||
|
<TargetHandle
|
||||||
|
nodeId={nodeId}
|
||||||
|
handleId={handleId}
|
||||||
|
position={Position.Left}
|
||||||
|
translate={[-2, 0]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
const rightHandle = (() => {
|
||||||
|
if (!node || !node?.targetHandle?.right) return null;
|
||||||
|
|
||||||
return (
|
const handleId = getHandleId(nodeId, 'target', Position.Right);
|
||||||
<TargetHandle
|
|
||||||
nodeId={nodeId}
|
|
||||||
handleId={handleId}
|
|
||||||
position={Position.Right}
|
|
||||||
translate={[2, 0]}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}, [node, nodeId]);
|
|
||||||
const topHandle = useMemo(() => {
|
|
||||||
if (!node || !node?.targetHandle?.top) return null;
|
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Top);
|
return (
|
||||||
|
<TargetHandle
|
||||||
|
nodeId={nodeId}
|
||||||
|
handleId={handleId}
|
||||||
|
position={Position.Right}
|
||||||
|
translate={[2, 0]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
const topHandle = (() => {
|
||||||
|
if (!node || !node?.targetHandle?.top) return null;
|
||||||
|
|
||||||
return (
|
const handleId = getHandleId(nodeId, 'target', Position.Top);
|
||||||
<TargetHandle
|
|
||||||
nodeId={nodeId}
|
|
||||||
handleId={handleId}
|
|
||||||
position={Position.Top}
|
|
||||||
translate={[0, -2]}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}, [node, nodeId]);
|
|
||||||
const bottomHandle = useMemo(() => {
|
|
||||||
if (!node || !node?.targetHandle?.bottom) return null;
|
|
||||||
|
|
||||||
const handleId = getHandleId(nodeId, 'target', Position.Bottom);
|
return (
|
||||||
|
<TargetHandle
|
||||||
|
nodeId={nodeId}
|
||||||
|
handleId={handleId}
|
||||||
|
position={Position.Top}
|
||||||
|
translate={[0, -2]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
const bottomHandle = (() => {
|
||||||
|
if (!node || !node?.targetHandle?.bottom) return null;
|
||||||
|
|
||||||
return (
|
const handleId = getHandleId(nodeId, 'target', Position.Bottom);
|
||||||
<TargetHandle
|
|
||||||
nodeId={nodeId}
|
return (
|
||||||
handleId={handleId}
|
<TargetHandle
|
||||||
position={Position.Bottom}
|
nodeId={nodeId}
|
||||||
translate={[0, 2]}
|
handleId={handleId}
|
||||||
/>
|
position={Position.Bottom}
|
||||||
);
|
translate={[0, 2]}
|
||||||
}, [node, nodeId]);
|
/>
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
|
||||||
|
return {
|
||||||
|
showHandle,
|
||||||
|
LeftHandle,
|
||||||
|
rightHandle,
|
||||||
|
topHandle,
|
||||||
|
bottomHandle
|
||||||
|
};
|
||||||
|
}, [connectingEdge, edges, nodeId, nodeList]);
|
||||||
|
|
||||||
return showHandle ? (
|
return showHandle ? (
|
||||||
<>
|
<>
|
||||||
@@ -181,7 +213,7 @@ export const ConnectionTargetHandle = ({ nodeId }: { nodeId: string }) => {
|
|||||||
{bottomHandle}
|
{bottomHandle}
|
||||||
</>
|
</>
|
||||||
) : null;
|
) : null;
|
||||||
};
|
});
|
||||||
|
|
||||||
export default function Dom() {
|
export default function Dom() {
|
||||||
return <></>;
|
return <></>;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ type Props = FlowNodeItemType & {
|
|||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
menuForbid?: {
|
menuForbid?: {
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
rename?: boolean;
|
|
||||||
copy?: boolean;
|
copy?: boolean;
|
||||||
delete?: boolean;
|
delete?: boolean;
|
||||||
};
|
};
|
||||||
@@ -154,37 +153,35 @@ const NodeCard = (props: Props) => {
|
|||||||
<Box ml={3} fontSize={'md'} fontWeight={'medium'}>
|
<Box ml={3} fontSize={'md'} fontWeight={'medium'}>
|
||||||
{t(name as any)}
|
{t(name as any)}
|
||||||
</Box>
|
</Box>
|
||||||
{!menuForbid?.rename && (
|
<MyIcon
|
||||||
<MyIcon
|
className="controller-rename"
|
||||||
className="controller-rename"
|
display={'none'}
|
||||||
display={'none'}
|
name={'edit'}
|
||||||
name={'edit'}
|
w={'14px'}
|
||||||
w={'14px'}
|
cursor={'pointer'}
|
||||||
cursor={'pointer'}
|
ml={1}
|
||||||
ml={1}
|
color={'myGray.500'}
|
||||||
color={'myGray.500'}
|
_hover={{ color: 'primary.600' }}
|
||||||
_hover={{ color: 'primary.600' }}
|
onClick={() => {
|
||||||
onClick={() => {
|
onOpenCustomTitleModal({
|
||||||
onOpenCustomTitleModal({
|
defaultVal: name,
|
||||||
defaultVal: name,
|
onSuccess: (e) => {
|
||||||
onSuccess: (e) => {
|
if (!e) {
|
||||||
if (!e) {
|
return toast({
|
||||||
return toast({
|
title: t('app:modules.Title is required'),
|
||||||
title: t('app:modules.Title is required'),
|
status: 'warning'
|
||||||
status: 'warning'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
onChangeNode({
|
|
||||||
nodeId,
|
|
||||||
type: 'attr',
|
|
||||||
key: 'name',
|
|
||||||
value: e
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
onChangeNode({
|
||||||
}}
|
nodeId,
|
||||||
/>
|
type: 'attr',
|
||||||
)}
|
key: 'name',
|
||||||
|
value: e
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Box flex={1} />
|
<Box flex={1} />
|
||||||
{hasNewVersion && (
|
{hasNewVersion && (
|
||||||
<MyTooltip label={t('app:app.modules.click to update')}>
|
<MyTooltip label={t('app:app.modules.click to update')}>
|
||||||
@@ -248,6 +245,14 @@ const NodeCard = (props: Props) => {
|
|||||||
onChangeNode,
|
onChangeNode,
|
||||||
toast
|
toast
|
||||||
]);
|
]);
|
||||||
|
const RenderHandle = useMemo(() => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ConnectionSourceHandle nodeId={nodeId} />
|
||||||
|
<ConnectionTargetHandle nodeId={nodeId} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}, [nodeId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -283,8 +288,7 @@ const NodeCard = (props: Props) => {
|
|||||||
<NodeDebugResponse nodeId={nodeId} debugResult={debugResult} />
|
<NodeDebugResponse nodeId={nodeId} debugResult={debugResult} />
|
||||||
{Header}
|
{Header}
|
||||||
{children}
|
{children}
|
||||||
<ConnectionSourceHandle nodeId={nodeId} />
|
{RenderHandle}
|
||||||
<ConnectionTargetHandle nodeId={nodeId} />
|
|
||||||
|
|
||||||
<EditTitleModal maxLength={20} />
|
<EditTitleModal maxLength={20} />
|
||||||
</Box>
|
</Box>
|
||||||
@@ -342,12 +346,13 @@ const MenuRender = React.memo(function MenuRender({
|
|||||||
outputs: template.outputs,
|
outputs: template.outputs,
|
||||||
version: template.version
|
version: template.version
|
||||||
},
|
},
|
||||||
selected: true
|
selected: true,
|
||||||
|
t
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[computedNewNodeName, setNodes]
|
[computedNewNodeName, setNodes, t]
|
||||||
);
|
);
|
||||||
const onDelNode = useCallback(
|
const onDelNode = useCallback(
|
||||||
(nodeId: string) => {
|
(nodeId: string) => {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ const JsonEditor = ({ inputs = [], item, nodeId }: RenderInputProps) => {
|
|||||||
<JSONEditor
|
<JSONEditor
|
||||||
bg={'white'}
|
bg={'white'}
|
||||||
borderRadius={'sm'}
|
borderRadius={'sm'}
|
||||||
placeholder={item.placeholder}
|
placeholder={t(item.placeholder as any)}
|
||||||
resize
|
resize
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@@ -65,7 +65,7 @@ const JsonEditor = ({ inputs = [], item, nodeId }: RenderInputProps) => {
|
|||||||
variables={variables}
|
variables={variables}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [item.placeholder, update, value, variables]);
|
}, [item.placeholder, t, update, value, variables]);
|
||||||
|
|
||||||
return Render;
|
return Render;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,20 +31,20 @@ const SelectDatasetParam = ({ inputs = [], nodeId }: RenderInputProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const tokenLimit = useMemo(() => {
|
const tokenLimit = useMemo(() => {
|
||||||
let maxTokens = 3000;
|
let maxTokens = 13000;
|
||||||
|
|
||||||
nodeList.forEach((item) => {
|
nodeList.forEach((item) => {
|
||||||
if (item.flowNodeType === FlowNodeTypeEnum.chatNode) {
|
if ([FlowNodeTypeEnum.chatNode, FlowNodeTypeEnum.tools].includes(item.flowNodeType)) {
|
||||||
const model =
|
const model =
|
||||||
item.inputs.find((item) => item.key === NodeInputKeyEnum.aiModel)?.value || '';
|
item.inputs.find((item) => item.key === NodeInputKeyEnum.aiModel)?.value || '';
|
||||||
const quoteMaxToken = getWebLLMModel(model)?.quoteMaxToken || 3000;
|
const quoteMaxToken = getWebLLMModel(model)?.quoteMaxToken || 13000;
|
||||||
|
|
||||||
maxTokens = Math.max(maxTokens, quoteMaxToken);
|
maxTokens = Math.max(maxTokens, quoteMaxToken);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return maxTokens;
|
return maxTokens;
|
||||||
}, [llmModelList, nodeList]);
|
}, [nodeList, llmModelList]);
|
||||||
|
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||||
|
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ const WorkflowContextProvider = ({
|
|||||||
return resetSnapshot(past[0]);
|
return resetSnapshot(past[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
setNodes(e.nodes?.map((item) => storeNode2FlowNode({ item })) || []);
|
setNodes(e.nodes?.map((item) => storeNode2FlowNode({ item, t })) || []);
|
||||||
setEdges(e.edges?.map((item) => storeEdgesRenderEdge({ edge: item })) || []);
|
setEdges(e.edges?.map((item) => storeEdgesRenderEdge({ edge: item })) || []);
|
||||||
|
|
||||||
const chatConfig = e.chatConfig;
|
const chatConfig = e.chatConfig;
|
||||||
@@ -553,7 +553,7 @@ const WorkflowContextProvider = ({
|
|||||||
// If it is the initial data, save the initial snapshot
|
// If it is the initial data, save the initial snapshot
|
||||||
if (isInit) {
|
if (isInit) {
|
||||||
saveSnapshot({
|
saveSnapshot({
|
||||||
pastNodes: e.nodes?.map((item) => storeNode2FlowNode({ item })) || [],
|
pastNodes: e.nodes?.map((item) => storeNode2FlowNode({ item, t })) || [],
|
||||||
pastEdges: e.edges?.map((item) => storeEdgesRenderEdge({ edge: item })) || [],
|
pastEdges: e.edges?.map((item) => storeEdgesRenderEdge({ edge: item })) || [],
|
||||||
customTitle: t(`app:app.version_initial`),
|
customTitle: t(`app:app.version_initial`),
|
||||||
chatConfig: appDetail.chatConfig,
|
chatConfig: appDetail.chatConfig,
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ const TeamCloud = () => {
|
|||||||
if (!versionDetail) return;
|
if (!versionDetail) return;
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
nodes: versionDetail.nodes?.map((item) => storeNode2FlowNode({ item })),
|
nodes: versionDetail.nodes?.map((item) => storeNode2FlowNode({ item, t })),
|
||||||
edges: versionDetail.edges?.map((item) => storeEdgesRenderEdge({ edge: item })),
|
edges: versionDetail.edges?.map((item) => storeEdgesRenderEdge({ edge: item })),
|
||||||
title: versionItem.versionName,
|
title: versionItem.versionName,
|
||||||
chatConfig: versionDetail.chatConfig
|
chatConfig: versionDetail.chatConfig
|
||||||
|
|||||||
@@ -130,7 +130,6 @@ const Chat = ({
|
|||||||
const completionChatId = chatId || getNanoid();
|
const completionChatId = chatId || getNanoid();
|
||||||
// Just send a user prompt
|
// Just send a user prompt
|
||||||
const histories = messages.slice(-1);
|
const histories = messages.slice(-1);
|
||||||
|
|
||||||
const { responseText, responseData } = await streamFetch({
|
const { responseText, responseData } = await streamFetch({
|
||||||
data: {
|
data: {
|
||||||
messages: histories,
|
messages: histories,
|
||||||
@@ -146,10 +145,8 @@ const Chat = ({
|
|||||||
const newTitle = getChatTitleFromChatMessage(GPTMessages2Chats(histories)[0]);
|
const newTitle = getChatTitleFromChatMessage(GPTMessages2Chats(histories)[0]);
|
||||||
|
|
||||||
// new chat
|
// new chat
|
||||||
if (completionChatId !== chatId) {
|
if (completionChatId !== chatId && controller.signal.reason !== 'leave') {
|
||||||
if (controller.signal.reason !== 'leave') {
|
onChangeChatId(completionChatId, true);
|
||||||
onChangeChatId(completionChatId, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
loadHistories();
|
loadHistories();
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,11 @@
|
|||||||
import React, { useState, useRef, useMemo, useCallback } from 'react';
|
import React, { useState, useRef, useMemo } from 'react';
|
||||||
import {
|
import { Box, Card, IconButton, Flex, Button, useTheme } from '@chakra-ui/react';
|
||||||
Box,
|
|
||||||
Card,
|
|
||||||
IconButton,
|
|
||||||
Flex,
|
|
||||||
Grid,
|
|
||||||
Button,
|
|
||||||
useTheme,
|
|
||||||
useDisclosure,
|
|
||||||
HStack
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import {
|
import {
|
||||||
getDatasetDataList,
|
getDatasetDataList,
|
||||||
delOneDatasetDataById,
|
delOneDatasetDataById,
|
||||||
getDatasetCollectionById,
|
getDatasetCollectionById,
|
||||||
putDatasetDataById
|
putDatasetDataById
|
||||||
} from '@/web/core/dataset/api';
|
} from '@/web/core/dataset/api';
|
||||||
import { DeleteIcon } from '@chakra-ui/icons';
|
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||||
@@ -27,16 +16,8 @@ import MyIcon from '@fastgpt/web/components/common/Icon';
|
|||||||
import MyInput from '@/components/MyInput';
|
import MyInput from '@/components/MyInput';
|
||||||
import InputDataModal from '../components/InputDataModal';
|
import InputDataModal from '../components/InputDataModal';
|
||||||
import RawSourceBox from '@/components/core/dataset/RawSourceBox';
|
import RawSourceBox from '@/components/core/dataset/RawSourceBox';
|
||||||
import type { DatasetDataListItemType } from '@/global/core/dataset/type.d';
|
|
||||||
import { TabEnum } from '..';
|
|
||||||
import { DatasetCollectionTypeMap, TrainingTypeMap } from '@fastgpt/global/core/dataset/constants';
|
|
||||||
import { formatTime2YMDHM } from '@fastgpt/global/common/string/time';
|
|
||||||
import { formatFileSize } from '@fastgpt/global/common/file/tools';
|
|
||||||
import { getCollectionSourceAndOpen } from '@/web/core/dataset/hooks/readCollectionSource';
|
|
||||||
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
|
||||||
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
import { usePagination } from '@fastgpt/web/hooks/usePagination';
|
||||||
import { getCollectionSourceData } from '@fastgpt/global/core/dataset/collection/utils';
|
import { getCollectionSourceData } from '@fastgpt/global/core/dataset/collection/utils';
|
||||||
import { useI18n } from '@/web/context/I18n';
|
|
||||||
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
|
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
|
||||||
import { DatasetPageContext } from '@/web/core/dataset/context/datasetPageContext';
|
import { DatasetPageContext } from '@/web/core/dataset/context/datasetPageContext';
|
||||||
import { useContextSelector } from 'use-context-selector';
|
import { useContextSelector } from 'use-context-selector';
|
||||||
@@ -78,7 +59,7 @@ const DataCard = () => {
|
|||||||
pageNum,
|
pageNum,
|
||||||
pageSize,
|
pageSize,
|
||||||
isLoading: isRequesting
|
isLoading: isRequesting
|
||||||
} = usePagination<DatasetDataListItemType>({
|
} = usePagination({
|
||||||
api: getDatasetDataList,
|
api: getDatasetDataList,
|
||||||
pageSize: 24,
|
pageSize: 24,
|
||||||
defaultRequest: false,
|
defaultRequest: false,
|
||||||
@@ -125,7 +106,7 @@ const DataCard = () => {
|
|||||||
|
|
||||||
const canWrite = useMemo(() => datasetDetail.permission.hasWritePer, [datasetDetail]);
|
const canWrite = useMemo(() => datasetDetail.permission.hasWritePer, [datasetDetail]);
|
||||||
|
|
||||||
const { run: onUpdate, loading } = useRequest2(putDatasetDataById, {
|
const { loading } = useRequest2(putDatasetDataById, {
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
getData(pageNum);
|
getData(pageNum);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useCallback, useEffect, useRef } from 'react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||||
import type { ResLogin } from '@/global/support/api/userRes.d';
|
import type { ResLogin } from '@/global/support/api/userRes.d';
|
||||||
@@ -12,6 +12,8 @@ import { serviceSideProps } from '@/web/common/utils/i18n';
|
|||||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
|
|
||||||
|
let isOauthLogging = false;
|
||||||
|
|
||||||
const provider = () => {
|
const provider = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { loginStore } = useSystemStore();
|
const { loginStore } = useSystemStore();
|
||||||
@@ -30,11 +32,7 @@ const provider = () => {
|
|||||||
setLastChatId('');
|
setLastChatId('');
|
||||||
setLastChatAppId('');
|
setLastChatAppId('');
|
||||||
|
|
||||||
setTimeout(() => {
|
router.push(loginStore?.lastRoute ? decodeURIComponent(loginStore?.lastRoute) : '/app/list');
|
||||||
router.push(
|
|
||||||
loginStore?.lastRoute ? decodeURIComponent(loginStore?.lastRoute) : '/app/list'
|
|
||||||
);
|
|
||||||
}, 100);
|
|
||||||
},
|
},
|
||||||
[setLastChatId, setLastChatAppId, setUserInfo, router, loginStore?.lastRoute]
|
[setLastChatId, setLastChatAppId, setUserInfo, router, loginStore?.lastRoute]
|
||||||
);
|
);
|
||||||
@@ -73,7 +71,7 @@ const provider = () => {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[loginStore, loginSuccess, router, toast]
|
[loginStore, loginSuccess, router, t, toast]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -86,24 +84,30 @@ const provider = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!code || !loginStore || !state) return;
|
if (!code || !loginStore?.state || !state) return;
|
||||||
|
|
||||||
clearToken();
|
if (isOauthLogging) return;
|
||||||
router.prefetch('/app/list');
|
|
||||||
|
|
||||||
if (state !== loginStore?.state) {
|
isOauthLogging = true;
|
||||||
toast({
|
|
||||||
status: 'warning',
|
(async () => {
|
||||||
title: t('common:support.user.login.security_failed')
|
await clearToken();
|
||||||
});
|
router.prefetch('/app/list');
|
||||||
setTimeout(() => {
|
|
||||||
router.replace('/login');
|
if (state !== loginStore?.state) {
|
||||||
}, 1000);
|
toast({
|
||||||
return;
|
status: 'warning',
|
||||||
} else {
|
title: t('common:support.user.login.security_failed')
|
||||||
authCode(code);
|
});
|
||||||
}
|
setTimeout(() => {
|
||||||
}, []);
|
router.replace('/login');
|
||||||
|
}, 1000);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
authCode(code);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, [authCode, code, error, loginStore, loginStore?.state, router, state, t, toast]);
|
||||||
|
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback, useEffect, useMemo } from 'react';
|
import React, { useCallback, useEffect } from 'react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import type { ResLogin } from '@/global/support/api/userRes.d';
|
import type { ResLogin } from '@/global/support/api/userRes.d';
|
||||||
import { useChatStore } from '@/web/core/chat/context/storeChat';
|
import { useChatStore } from '@/web/core/chat/context/storeChat';
|
||||||
@@ -7,8 +7,11 @@ import { clearToken, setToken } from '@/web/support/user/auth';
|
|||||||
import { ssoLogin } from '@/web/support/user/api';
|
import { ssoLogin } from '@/web/support/user/api';
|
||||||
import Loading from '@fastgpt/web/components/common/MyLoading';
|
import Loading from '@fastgpt/web/components/common/MyLoading';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
|
||||||
import { serviceSideProps } from '@/web/common/utils/i18n';
|
import { serviceSideProps } from '@/web/common/utils/i18n';
|
||||||
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||||
|
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||||
|
|
||||||
|
let isOauthLogging = false;
|
||||||
|
|
||||||
const provider = () => {
|
const provider = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -16,6 +19,7 @@ const provider = () => {
|
|||||||
const { setUserInfo } = useUserStore();
|
const { setUserInfo } = useUserStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { query } = router;
|
const { query } = router;
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
const loginSuccess = useCallback(
|
const loginSuccess = useCallback(
|
||||||
(res: ResLogin) => {
|
(res: ResLogin) => {
|
||||||
@@ -30,17 +34,44 @@ const provider = () => {
|
|||||||
[setLastChatId, setLastChatAppId, setUserInfo, router]
|
[setLastChatId, setLastChatAppId, setUserInfo, router]
|
||||||
);
|
);
|
||||||
|
|
||||||
const { run: handleSSO } = useRequest2(() => ssoLogin(query), {
|
const handleSSO = useCallback(async () => {
|
||||||
onSuccess: loginSuccess,
|
try {
|
||||||
errorToast: t('common:support.user.login.error')
|
const res = await ssoLogin(query);
|
||||||
});
|
|
||||||
|
if (!res) {
|
||||||
|
toast({
|
||||||
|
status: 'warning',
|
||||||
|
title: t('common:support.user.login.error')
|
||||||
|
});
|
||||||
|
return setTimeout(() => {
|
||||||
|
router.replace('/login');
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
loginSuccess(res);
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
status: 'warning',
|
||||||
|
title: getErrText(error, t('common:support.user.login.error'))
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
router.replace('/login');
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}, [loginSuccess, query, router, t, toast]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (query && Object.keys(query).length > 0) {
|
if (query && Object.keys(query).length > 0) {
|
||||||
clearToken();
|
if (isOauthLogging) return;
|
||||||
handleSSO();
|
|
||||||
|
isOauthLogging = true;
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await clearToken();
|
||||||
|
handleSSO();
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
}, []);
|
}, [handleSSO, query]);
|
||||||
|
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
|
import { UsageSourceEnum } from '@fastgpt/global/support/wallet/usage/constants';
|
||||||
import { addLog } from '@fastgpt/service/common/system/log';
|
import { addLog } from '@fastgpt/service/common/system/log';
|
||||||
import { MongoApp } from '@fastgpt/service/core/app/schema';
|
import { MongoApp } from '@fastgpt/service/core/app/schema';
|
||||||
|
import { WORKFLOW_MAX_RUN_TIMES } from '@fastgpt/service/core/workflow/constants';
|
||||||
import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch';
|
import { dispatchWorkFlow } from '@fastgpt/service/core/workflow/dispatch';
|
||||||
|
|
||||||
export const getScheduleTriggerApp = async () => {
|
export const getScheduleTriggerApp = async () => {
|
||||||
@@ -55,7 +56,7 @@ export const getScheduleTriggerApp = async () => {
|
|||||||
chatConfig: defaultApp.chatConfig,
|
chatConfig: defaultApp.chatConfig,
|
||||||
histories: [],
|
histories: [],
|
||||||
stream: false,
|
stream: false,
|
||||||
maxRunTimes: 200
|
maxRunTimes: WORKFLOW_MAX_RUN_TIMES
|
||||||
});
|
});
|
||||||
pushChatUsage({
|
pushChatUsage({
|
||||||
appName: app.name,
|
appName: app.name,
|
||||||
|
|||||||
2
projects/app/src/types/app.d.ts
vendored
@@ -43,4 +43,6 @@ export type AppLogsListItemType = {
|
|||||||
userBadFeedbackCount: number;
|
userBadFeedbackCount: number;
|
||||||
customFeedbacksCount: number;
|
customFeedbacksCount: number;
|
||||||
markCount: number;
|
markCount: number;
|
||||||
|
outLinkUid?: string;
|
||||||
|
tmbId: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import type { GetAppChatLogsParams } from '@/global/core/api/appReq.d';
|
|||||||
import { AppUpdateParams, AppChangeOwnerBody } from '@/global/core/app/api';
|
import { AppUpdateParams, AppChangeOwnerBody } from '@/global/core/app/api';
|
||||||
import type { CreateAppBody } from '@/pages/api/core/app/create';
|
import type { CreateAppBody } from '@/pages/api/core/app/create';
|
||||||
import type { ListAppBody } from '@/pages/api/core/app/list';
|
import type { ListAppBody } from '@/pages/api/core/app/list';
|
||||||
|
import { AppLogsListItemType } from '@/types/app';
|
||||||
|
import { PagingData } from '@/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模型列表
|
* 获取模型列表
|
||||||
@@ -36,7 +38,8 @@ export const putAppById = (id: string, data: AppUpdateParams) =>
|
|||||||
PUT(`/core/app/update?appId=${id}`, data);
|
PUT(`/core/app/update?appId=${id}`, data);
|
||||||
|
|
||||||
// =================== chat logs
|
// =================== chat logs
|
||||||
export const getAppChatLogs = (data: GetAppChatLogsParams) => POST(`/core/app/getChatLogs`, data);
|
export const getAppChatLogs = (data: GetAppChatLogsParams) =>
|
||||||
|
POST<PagingData<AppLogsListItemType>>(`/core/app/getChatLogs`, data);
|
||||||
|
|
||||||
export const resumeInheritPer = (appId: string) =>
|
export const resumeInheritPer = (appId: string) =>
|
||||||
GET(`/core/app/resumeInheritPermission`, { appId });
|
GET(`/core/app/resumeInheritPermission`, { appId });
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ import type { CreateDatasetParams, InsertOneDatasetDataProps } from '@/global/co
|
|||||||
import type { DatasetCollectionItemType } from '@fastgpt/global/core/dataset/type';
|
import type { DatasetCollectionItemType } from '@fastgpt/global/core/dataset/type';
|
||||||
import { DatasetCollectionSyncResultEnum } from '@fastgpt/global/core/dataset/constants';
|
import { DatasetCollectionSyncResultEnum } from '@fastgpt/global/core/dataset/constants';
|
||||||
import type { DatasetDataItemType } from '@fastgpt/global/core/dataset/type';
|
import type { DatasetDataItemType } from '@fastgpt/global/core/dataset/type';
|
||||||
import type { DatasetCollectionsListItemType } from '@/global/core/dataset/type.d';
|
import type {
|
||||||
|
DatasetCollectionsListItemType,
|
||||||
|
DatasetDataListItemType
|
||||||
|
} from '@/global/core/dataset/type.d';
|
||||||
import { PagingData } from '@/types';
|
import { PagingData } from '@/types';
|
||||||
import type { getDatasetTrainingQueueResponse } from '@/pages/api/core/dataset/training/getDatasetTrainingQueue';
|
import type { getDatasetTrainingQueueResponse } from '@/pages/api/core/dataset/training/getDatasetTrainingQueue';
|
||||||
import type { rebuildEmbeddingBody } from '@/pages/api/core/dataset/training/rebuildEmbedding';
|
import type { rebuildEmbeddingBody } from '@/pages/api/core/dataset/training/rebuildEmbedding';
|
||||||
@@ -153,7 +156,7 @@ export const getScrollCollectionList = (data: GetScrollCollectionsProps) =>
|
|||||||
/* =============================== data ==================================== */
|
/* =============================== data ==================================== */
|
||||||
/* get dataset list */
|
/* get dataset list */
|
||||||
export const getDatasetDataList = (data: GetDatasetDataListProps) =>
|
export const getDatasetDataList = (data: GetDatasetDataListProps) =>
|
||||||
POST(`/core/dataset/data/list`, data);
|
POST<PagingData<DatasetDataListItemType>>(`/core/dataset/data/list`, data);
|
||||||
|
|
||||||
export const getDatasetDataItemById = (id: string) =>
|
export const getDatasetDataItemById = (id: string) =>
|
||||||
GET<DatasetDataItemType>(`/core/dataset/data/detail`, { id });
|
GET<DatasetDataItemType>(`/core/dataset/data/detail`, { id });
|
||||||
|
|||||||
@@ -62,10 +62,12 @@ export const nodeTemplate2FlowNode = ({
|
|||||||
};
|
};
|
||||||
export const storeNode2FlowNode = ({
|
export const storeNode2FlowNode = ({
|
||||||
item: storeNode,
|
item: storeNode,
|
||||||
selected = false
|
selected = false,
|
||||||
|
t
|
||||||
}: {
|
}: {
|
||||||
item: StoreNodeItemType;
|
item: StoreNodeItemType;
|
||||||
selected?: boolean;
|
selected?: boolean;
|
||||||
|
t: TFunction;
|
||||||
}): Node<FlowNodeItemType> => {
|
}): Node<FlowNodeItemType> => {
|
||||||
// init some static data
|
// init some static data
|
||||||
const template =
|
const template =
|
||||||
@@ -99,6 +101,9 @@ export const storeNode2FlowNode = ({
|
|||||||
...storeInput,
|
...storeInput,
|
||||||
...templateInput,
|
...templateInput,
|
||||||
|
|
||||||
|
debugLabel: t(templateInput.debugLabel ?? (storeInput.debugLabel as any)),
|
||||||
|
toolDescription: t(templateInput.toolDescription ?? (storeInput.toolDescription as any)),
|
||||||
|
|
||||||
selectedTypeIndex: storeInput.selectedTypeIndex ?? templateInput.selectedTypeIndex,
|
selectedTypeIndex: storeInput.selectedTypeIndex ?? templateInput.selectedTypeIndex,
|
||||||
value: storeInput.value ?? templateInput.value,
|
value: storeInput.value ?? templateInput.value,
|
||||||
label: storeInput.label ?? templateInput.label
|
label: storeInput.label ?? templateInput.label
|
||||||
@@ -126,6 +131,8 @@ export const storeNode2FlowNode = ({
|
|||||||
...storeOutput,
|
...storeOutput,
|
||||||
...templateOutput,
|
...templateOutput,
|
||||||
|
|
||||||
|
description: t(templateOutput.description ?? (storeOutput.description as any)),
|
||||||
|
|
||||||
id: storeOutput.id ?? templateOutput.id,
|
id: storeOutput.id ?? templateOutput.id,
|
||||||
label: storeOutput.label ?? templateOutput.label,
|
label: storeOutput.label ?? templateOutput.label,
|
||||||
value: storeOutput.value ?? templateOutput.value
|
value: storeOutput.value ?? templateOutput.value
|
||||||
|
|||||||