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