Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.8.6 fix #1970

Merged
merged 9 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docSite/content/zh-cn/docs/development/upgrading/486.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ weight: 818

### 2. 修改镜像

- fastgpt 镜像 tag 修改成 v4.8.6-alpha
- fastgpt-sandbox 镜像 tag 修改成 v4.8.6-alpha
- 商业版镜像 tag 修改成 v4.8.6-alpha
- fastgpt 镜像 tag 修改成 v4.8.6-alpha2
- fastgpt-sandbox 镜像 tag 修改成 v4.8.6-alpha2
- 商业版镜像 tag 修改成 v4.8.6-alpha2

### 3. 执行初始化

Expand All @@ -39,6 +39,7 @@ curl --location --request POST 'https://{{host}}/api/admin/initv486' \
4. 新增 - 移动文本加工和自定义反馈到基础节点中
5. 优化 - Read file 默认选中从节点,实现 MongoDB 读写分离,减轻主节点压力
6. 优化 - 知识库导入接口,返回值对齐
7. 修复 - 工作流中团队插件加载异常
8. 修复 - 知识库集合目录导航失效
9. 修复 - 通过 API 调用 chat 接口,传递 System 异常
7. 优化 - Mongo model 重复加载
8. 修复 - 工作流中团队插件加载异常
9. 修复 - 知识库集合目录导航失效
10. 修复 - 通过 API 调用 chat 接口,传递 System 异常
7 changes: 6 additions & 1 deletion packages/global/core/workflow/template/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ export const Output_Template_AddOutput: FlowNodeOutputItemType = {
key: NodeOutputKeyEnum.addOutputParam,
type: FlowNodeOutputTypeEnum.dynamic,
valueType: WorkflowIOValueTypeEnum.dynamic,
label: ''
label: '',
customFieldConfig: {
selectValueTypeList: Object.values(WorkflowIOValueTypeEnum),
showDescription: false,
showDefaultValue: false
}
};
7 changes: 1 addition & 6 deletions packages/global/core/workflow/template/system/http468.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,7 @@ export const HttpNode468: FlowNodeTemplateType = {
],
outputs: [
{
...Output_Template_AddOutput,
customFieldConfig: {
selectValueTypeList: Object.values(WorkflowIOValueTypeEnum),
showDescription: false,
showDefaultValue: true
}
...Output_Template_AddOutput
},
{
id: NodeOutputKeyEnum.error,
Expand Down
28 changes: 27 additions & 1 deletion packages/global/core/workflow/template/system/sandbox/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,32 @@ export const CodeNode: FlowNodeTemplateType = {
showDefaultValue: true
}
},
{
renderTypeList: [FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.string,
canEdit: true,
key: 'data1',
label: 'data1',
customInputConfig: {
selectValueTypeList: Object.values(WorkflowIOValueTypeEnum),
showDescription: false,
showDefaultValue: true
},
required: true
},
{
renderTypeList: [FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.string,
canEdit: true,
key: 'data2',
label: 'data2',
customInputConfig: {
selectValueTypeList: Object.values(WorkflowIOValueTypeEnum),
showDescription: false,
showDefaultValue: true
},
required: true
},
{
key: NodeInputKeyEnum.codeType,
renderTypeList: [FlowNodeInputTypeEnum.hidden],
Expand All @@ -52,7 +78,7 @@ export const CodeNode: FlowNodeTemplateType = {
outputs: [
{
...Output_Template_AddOutput,
description: '将代码中 return 的对象作为输出,传递给后续的节点'
description: '将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key'
},
{
id: NodeOutputKeyEnum.rawResponse,
Expand Down
6 changes: 3 additions & 3 deletions packages/service/common/mongo/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { addLog } from '../../common/system/log';
import mongoose, { Model } from 'mongoose';

export default mongoose;
export * from 'mongoose';

export const connectionMongo = (() => {
if (!global.mongodb) {
global.mongodb = mongoose;
Expand All @@ -9,9 +12,6 @@ export const connectionMongo = (() => {
return global.mongodb;
})();

export default mongoose;
export * from 'mongoose';

const addCommonMiddleware = (schema: mongoose.Schema) => {
const operations = [
/^find/,
Expand Down
20 changes: 10 additions & 10 deletions packages/service/common/system/log.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import dayjs from 'dayjs';
import chalk from 'chalk';
import { LogLevelEnum } from './log/constant';
// import { MongoLog } from './log/schema';
import connectionMongo from '../mongo/index';
import { connectionMongo } from '../mongo/index';
import { getMongoLog } from './log/schema';

const logMap = {
[LogLevelEnum.debug]: {
Expand Down Expand Up @@ -52,14 +52,14 @@ export const addLog = {
level === LogLevelEnum.error && console.error(obj);

// store
// if (level >= STORE_LOG_LEVEL && connectionMongo.connection.readyState === 1) {
// // store log
// MongoLog.create({
// text: msg,
// level,
// metadata: obj
// });
// }
if (level >= STORE_LOG_LEVEL && connectionMongo.connection.readyState === 1) {
// store log
getMongoLog().create({
text: msg,
level,
metadata: obj
});
}
},
debug(msg: string, obj?: Record<string, any>) {
this.log(LogLevelEnum.debug, msg, obj);
Expand Down
40 changes: 21 additions & 19 deletions packages/service/common/system/log/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ import { LogLevelEnum } from './constant';

export const LogCollectionName = 'system_logs';

const SystemLogSchema = new Schema({
text: {
type: String,
required: true
},
level: {
type: String,
required: true,
enum: Object.values(LogLevelEnum)
},
time: {
type: Date,
default: () => new Date()
},
metadata: Object
});
export const getMongoLog = () => {
const SystemLogSchema = new Schema({
text: {
type: String,
required: true
},
level: {
type: String,
required: true,
enum: Object.values(LogLevelEnum)
},
time: {
type: Date,
default: () => new Date()
},
metadata: Object
});

SystemLogSchema.index({ time: 1 }, { expires: '15d' });
SystemLogSchema.index({ level: 1 });
SystemLogSchema.index({ time: 1 }, { expires: '15d' });
SystemLogSchema.index({ level: 1 });

export const MongoLog = getMongoModel<SystemLogType>(LogCollectionName, SystemLogSchema);
return getMongoModel<SystemLogType>(LogCollectionName, SystemLogSchema);
};
2 changes: 1 addition & 1 deletion packages/web/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"module": {
"Combine Modules": "Combine Modules",
"Confirm Sync": "Using the latest template will overwrite the existing one and may result in the loss of some previous configuration information. Please confirm.",
"Confirm Sync": "The template will be updated to the latest template configuration. Fields that do not exist in the template will be deleted (including all custom fields). You are advised to make a copy of the node and then update the original node version.",
"Custom Title Tip": "This title will be displayed during the conversation",
"My Modules": "My Modules",
"No Modules": "No plugins yet~",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/i18n/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@
"Debug": "Debug",
"Debug Node": "Debug mode",
"Failed": "Execution failed",
"Not intro": "This node has no introduction~\\",
"Not intro": "This node has no introduction~",
"Run from here": "Run from here",
"Run result": "Run result",
"Running": "Running",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/i18n/en/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Tool input": "Tool",
"code": {
"Reset template": "Reset template",
"Reset template confirm": "Are you sure to restore the code template? Be careful to save the current code."
"Reset template confirm": "Are you sure to restore the code template? All input and output to template values will be reset, please be careful to save the current code."
},
"ifelse": {
"Input value": "Input",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/i18n/zh/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"module": {
"Combine Modules": "组合模块",
"Confirm Sync": "将会使用最新模板进行覆盖,可能会丢失一些旧的配置信息,请确认",
"Confirm Sync": "将会更新至最新的模板配置,不存在模板中的字段将会被删除(包括所有自定义字段),建议您先复制一份节点,再更新原来节点的版本。",
"Custom Title Tip": "该标题名字会展示在对话过程中",
"My Modules": "",
"No Modules": "没找到插件",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/i18n/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@
"Debug": "调试",
"Debug Node": "Debug 模式",
"Failed": "运行失败",
"Not intro": "这个节点没有介绍~\\",
"Not intro": "这个节点没有介绍~",
"Run from here": "从这里开始运行",
"Run result": "",
"Running": "运行中",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/i18n/zh/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Tool input": "工具参数",
"code": {
"Reset template": "还原模板",
"Reset template confirm": "确认还原代码模板?请注意保存当前代码。"
"Reset template confirm": "确认还原代码模板?将会重置所有输入和输出至模板值,请注意保存当前代码。"
},
"ifelse": {
"Input value": "输入值",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const SelectOneResource = ({
return loading ? (
<Loading fixed={false} />
) : (
<Box maxH={maxH} overflow={'auto'}>
<Box maxH={maxH} h={'100%'} overflow={'auto'}>
<Render list={concatRoot} />
</Box>
);
Expand Down
31 changes: 16 additions & 15 deletions projects/app/src/pages/app/detail/components/InfoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,26 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => {
const avatar = getValues('avatar');

// submit config
const { mutate: saveSubmitSuccess, isLoading: btnLoading } = useRequest({
mutationFn: async (data: AppSchema) => {
const { runAsync: saveSubmitSuccess, loading: btnLoading } = useRequest2(
async (data: AppSchema) => {
await updateAppDetail({
name: data.name,
avatar: data.avatar,
intro: data.intro,
defaultPermission: data.defaultPermission
});
},
onSuccess() {
onClose();
toast({
title: t('common.Update Success'),
status: 'success'
});
reloadApp();
},
errorToast: t('common.Update Failed')
});
{
onSuccess() {
toast({
title: t('common.Update Success'),
status: 'success'
});
reloadApp();
},
errorToast: t('common.Update Failed')
}
);

const saveSubmitError = useCallback(() => {
// deep search message
Expand All @@ -101,8 +102,8 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => {
}, [errors, t, toast]);

const saveUpdateModel = useCallback(
() => handleSubmit((data) => saveSubmitSuccess(data), saveSubmitError)(),
[handleSubmit, saveSubmitError, saveSubmitSuccess]
() => handleSubmit((data) => saveSubmitSuccess(data).then(onClose), saveSubmitError)(),
[handleSubmit, onClose, saveSubmitError, saveSubmitSuccess]
);

const onSelectFile = useCallback(
Expand Down Expand Up @@ -210,7 +211,7 @@ const InfoModal = ({ onClose }: { onClose: () => void }) => {
isInheritPermission={appDetail.inheritPermission}
onChange={(v) => {
setValue('defaultPermission', v);
handleSubmit((data) => saveSubmitSuccess(data), saveSubmitError)();
return handleSubmit((data) => saveSubmitSuccess(data), saveSubmitError)();
}}
hasParent={!!appDetail.parentId}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ const RenderList = React.memo(function RenderList({
{t(template.name)}
</Box>
</Flex>
<Box mt={2}>{t(template.intro || 'core.workflow.Not intro')}</Box>
<Box mt={2} color={'myGray.500'}>
{t(template.intro) || t('core.workflow.Not intro')}
</Box>
</Box>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@ import CodeEditor from '@fastgpt/web/components/common/Textarea/CodeEditor';
import { Box, Flex } from '@chakra-ui/react';
import { useI18n } from '@/web/context/I18n';
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
import { JS_TEMPLATE } from '@fastgpt/global/core/workflow/template/system/sandbox/constants';
import { getLatestNodeTemplate } from '@/web/core/workflow/utils';
import { CodeNode } from '@fastgpt/global/core/workflow/template/system/sandbox';

const NodeCode = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
const { t } = useTranslation();
const { workflowT } = useI18n();
const { nodeId, inputs, outputs } = data;
const splitToolInputs = useContextSelector(WorkflowContext, (ctx) => ctx.splitToolInputs);
const onChangeNode = useContextSelector(WorkflowContext, (v) => v.onChangeNode);
const onResetNode = useContextSelector(WorkflowContext, (v) => v.onResetNode);

const { isTool, commonInputs } = splitToolInputs(inputs, nodeId);
const { ConfirmModal, openConfirm } = useConfirm({
content: workflowT('code.Reset template confirm')
Expand All @@ -41,14 +44,9 @@ const NodeCode = ({ data, selected }: NodeProps<FlowNodeItemType>) => {
color={'primary.500'}
fontSize={'xs'}
onClick={openConfirm(() => {
onChangeNode({
nodeId,
type: 'updateInput',
key: item.key,
value: {
...item,
value: JS_TEMPLATE
}
onResetNode({
id: nodeId,
node: getLatestNodeTemplate(data, CodeNode)
});
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const defaultInput: FlowNodeInputItemType = {
renderTypeList: [FlowNodeInputTypeEnum.reference], // Can only choose one here
selectedTypeIndex: 0,
valueType: WorkflowIOValueTypeEnum.string,
canEdit: true,
key: '',
label: ''
};
Expand Down
Loading
Loading