* fix: full text search match query

* perf: mongo schema import, Avoid duplicate import

* feat: mongo log store

* doc

* fix: sandbox outputs

* perf: desc color

* fix: node init

* perf code

* perf: chat header
This commit is contained in:
Archer
2024-07-10 15:52:39 +08:00
committed by GitHub
parent f548e24e7d
commit e2ae571d15
21 changed files with 184 additions and 137 deletions

View File

@@ -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
}
};

View File

@@ -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,

View File

@@ -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],
@@ -52,7 +78,7 @@ export const CodeNode: FlowNodeTemplateType = {
outputs: [
{
...Output_Template_AddOutput,
description: '将代码中 return 的对象作为输出,传递给后续的节点'
description: '将代码中 return 的对象作为输出,传递给后续的节点。变量名需要对应 return 的 key'
},
{
id: NodeOutputKeyEnum.rawResponse,

View File

@@ -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;
@@ -9,9 +12,6 @@ export const connectionMongo = (() => {
return global.mongodb;
})();
export default mongoose;
export * from 'mongoose';
const addCommonMiddleware = (schema: mongoose.Schema) => {
const operations = [
/^find/,

View File

@@ -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]: {
@@ -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);

View File

@@ -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);
};

View File

@@ -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~",

View File

@@ -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",

View File

@@ -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",

View File

@@ -56,7 +56,7 @@
},
"module": {
"Combine Modules": "组合模块",
"Confirm Sync": "将会使用最新模板进行覆盖,可能会丢失一些旧的配置信息,请确认",
"Confirm Sync": "将会更新至最新模板配置,不存在模板中的字段将会被删除(包括所有自定义字段),建议您先复制一份节点,再更新原来节点的版本。",
"Custom Title Tip": "该标题名字会展示在对话过程中",
"My Modules": "",
"No Modules": "没找到插件",

View File

@@ -1077,7 +1077,7 @@
"Debug": "调试",
"Debug Node": "Debug 模式",
"Failed": "运行失败",
"Not intro": "这个节点没有介绍~\\",
"Not intro": "这个节点没有介绍~",
"Run from here": "从这里开始运行",
"Run result": "",
"Running": "运行中",

View File

@@ -16,7 +16,7 @@
"Tool input": "工具参数",
"code": {
"Reset template": "还原模板",
"Reset template confirm": "确认还原代码模板?请注意保存当前代码。"
"Reset template confirm": "确认还原代码模板?将会重置所有输入和输出至模板值,请注意保存当前代码。"
},
"ifelse": {
"Input value": "输入值",