mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00
V4.9.5 feature (#4520)
* readme * Add queue log * Test interactive (#4509) * Support nested node interaction (#4503) * feat: Add a new InteractiveContext type and update InteractiveBasicType, adding an optional context property to support more complex interaction state management. * feat: Enhance workflow interactivity by adding InteractiveContext support and updating dispatch logic to manage nested contexts and entry nodes more effectively. * feat: Refactor dispatchWorkFlow to utilize InteractiveContext for improved context management * feat: Enhance entry node resolution by adding validation for entryNodeIds and recursive search in InteractiveContext * feat: Remove workflowDepth from InteractiveContext and update recovery logic to utilize parentContext for improved context management * feat: Update getWorkflowEntryNodeIds to use lastInteractive for improved context handling in runtime nodes * feat: Add lastInteractive support to enhance context management across workflow components * feat: Enhance interactive workflow by adding stopForInteractive flag and improving memory edge validation in runtime logic * feat: Refactor InteractiveContext by removing interactiveAppId and updating runtime edge handling in dispatchRunApp for improved context management * feat: Simplify runtime node and edge initialization in dispatchRunApp by using ternary operators for improved readability and maintainability * feat: Improve memory edge validation in initWorkflowEdgeStatus by adding detailed comments for better understanding of subset checks and recursive context searching * feat: Remove commented-out current level information from InteractiveContext for cleaner code and improved readability * feat: Simplify stopForInteractive check in dispatchWorkFlow for improved code clarity and maintainability * feat: Remove stopForInteractive handling and related references for improved code clarity and maintainability * feat: Add interactive response handling in dispatchRunAppNode for enhanced workflow interactivity * feat: Add context property to InteractiveBasicType and InteractiveNodeType for improved interactivity management * feat: remove comments * feat: Remove the node property from ChatDispatchProps to simplify type definitions * feat: Remove workflowInteractiveResponse from dispatchRunAppNode for cleaner code * feat: Refactor interactive value handling in chat history processing for improved clarity * feat: Simplify initWorkflowEdgeStatus logic for better readability and maintainability * feat: Add workflowInteractiveResponse to dispatchWorkFlow for enhanced functionality * feat: Enhance interactive response handling with nested children support * feat: Remove commented-out code for interactive node handling to improve clarity * feat: remove InteractiveContext type * feat: Refactor UserSelectInteractive and UserInputInteractive params for improved structure and clarity * feat: remove * feat: The front end supports extracting the deepest interaction parameters to enhance interaction processing * feat: The front end supports extracting the deepest interaction parameters to enhance interaction processing * fix: handle undefined interactive values in runtimeEdges and runtimeNodes initialization * fix: handle undefined interactive values in runtimeNodes and runtimeEdges initialization * fix: update runtimeNodes and runtimeEdges initialization to use last interactive value * fix: remove unused imports and replace getLastInteractiveValue with lastInteractive in runtimeEdges initialization * fix: import WorkflowInteractiveResponseType and handle lastInteractive as undefined in chatTest * feat: implement extractDeepestInteractive function and refactor usage in AIResponseBox and ChatBox utils * fix: refactor initWorkflowEdgeStatus and getWorkflowEntryNodeIds calls in dispatchRunAppNode for recovery handling * fix: ensure lastInteractive is handled consistently as undefined in runtimeEdges and runtimeNodes initialization * fix: update dispatchFormInput and dispatchUserSelect to use lastInteractive consistently * fix: update condition checks in dispatchFormInput and dispatchUserSelect to ensure lastInteractive type is validated correctly * fix: refactor dispatchRunAppNode to replace isRecovery with childrenInteractive for improved clarity in runtimeNodes and runtimeEdges initialization * refactor: streamline runtimeNodes and runtimeEdges initialization in dispatchRunAppNode for improved readability and maintainability * fix: update rewriteNodeOutputByHistories function to accept runtimeNodes and interactive as parameters for improved clarity * fix: simplify interactiveResponse assignment in dispatchWorkFlow for improved clarity * fix: update entryNodeIds check in getWorkflowEntryNodeIds to ensure it's an array for improved reliability * remove some invalid code --------- Co-authored-by: Theresa <63280168+sd0ric4@users.noreply.github.com> * update doc * update log * fix: update debug workflow to conditionally include nextStepSkipNodes… (#4511) * fix: update debug workflow to conditionally include nextStepSkipNodes based on lastInteractive for improved debugging accuracy * fix : type error * remove invalid code * fix: QA queue * fix: interactive * Test log (#4519) * add log (#4504) * add log * update log i18n * update log * delete template * add i18NT * add team operation log --------- Co-authored-by: gggaaallleee <91131304+gggaaallleee@users.noreply.github.com> * remove search * update doc --------- Co-authored-by: Theresa <63280168+sd0ric4@users.noreply.github.com> Co-authored-by: gggaaallleee <91131304+gggaaallleee@users.noreply.github.com>
This commit is contained in:
26
packages/service/support/operationLog/addOperationLog.ts
Normal file
26
packages/service/support/operationLog/addOperationLog.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { MongoOperationLog } from './schema';
|
||||
import { OperationLogEventEnum } from '@fastgpt/global/support/operationLog/constants';
|
||||
import { TemplateParamsMap } from './constants';
|
||||
import { retryFn } from '../../../global/common/system/utils';
|
||||
|
||||
export function addOperationLog<T extends OperationLogEventEnum>({
|
||||
teamId,
|
||||
tmbId,
|
||||
event,
|
||||
params
|
||||
}: {
|
||||
tmbId: string;
|
||||
teamId: string;
|
||||
event: T;
|
||||
params?: TemplateParamsMap[T];
|
||||
}) {
|
||||
console.log('Insert log');
|
||||
retryFn(() =>
|
||||
MongoOperationLog.create({
|
||||
tmbId: tmbId,
|
||||
teamId: teamId,
|
||||
event,
|
||||
metadata: params
|
||||
})
|
||||
);
|
||||
}
|
85
packages/service/support/operationLog/constants.ts
Normal file
85
packages/service/support/operationLog/constants.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import { OperationLogEventEnum } from '@fastgpt/global/support/operationLog/constants';
|
||||
import { i18nT } from '../../../web/i18n/utils';
|
||||
|
||||
export const operationLogI18nMap = {
|
||||
[OperationLogEventEnum.LOGIN]: {
|
||||
content: i18nT('account_team:log_login'),
|
||||
typeLabel: i18nT('account_team:login')
|
||||
},
|
||||
[OperationLogEventEnum.CREATE_INVITATION_LINK]: {
|
||||
content: i18nT('account_team:log_create_invitation_link'),
|
||||
typeLabel: i18nT('account_team:create_invitation_link')
|
||||
},
|
||||
[OperationLogEventEnum.JOIN_TEAM]: {
|
||||
content: i18nT('account_team:log_join_team'),
|
||||
typeLabel: i18nT('account_team:join_team')
|
||||
},
|
||||
[OperationLogEventEnum.CHANGE_MEMBER_NAME]: {
|
||||
content: i18nT('account_team:log_change_member_name'),
|
||||
typeLabel: i18nT('account_team:change_member_name')
|
||||
},
|
||||
[OperationLogEventEnum.KICK_OUT_TEAM]: {
|
||||
content: i18nT('account_team:log_kick_out_team'),
|
||||
typeLabel: i18nT('account_team:kick_out_team')
|
||||
},
|
||||
[OperationLogEventEnum.CREATE_DEPARTMENT]: {
|
||||
content: i18nT('account_team:log_create_department'),
|
||||
typeLabel: i18nT('account_team:create_department')
|
||||
},
|
||||
[OperationLogEventEnum.CHANGE_DEPARTMENT]: {
|
||||
content: i18nT('account_team:log_change_department'),
|
||||
typeLabel: i18nT('account_team:change_department_name')
|
||||
},
|
||||
[OperationLogEventEnum.DELETE_DEPARTMENT]: {
|
||||
content: i18nT('account_team:log_delete_department'),
|
||||
typeLabel: i18nT('account_team:delete_department')
|
||||
},
|
||||
[OperationLogEventEnum.RELOCATE_DEPARTMENT]: {
|
||||
content: i18nT('account_team:log_relocate_department'),
|
||||
typeLabel: i18nT('account_team:relocate_department')
|
||||
},
|
||||
[OperationLogEventEnum.CREATE_GROUP]: {
|
||||
content: i18nT('account_team:log_create_group'),
|
||||
typeLabel: i18nT('account_team:create_group')
|
||||
},
|
||||
[OperationLogEventEnum.DELETE_GROUP]: {
|
||||
content: i18nT('account_team:log_delete_group'),
|
||||
typeLabel: i18nT('account_team:delete_group')
|
||||
},
|
||||
[OperationLogEventEnum.ASSIGN_PERMISSION]: {
|
||||
content: i18nT('account_team:log_assign_permission'),
|
||||
typeLabel: i18nT('account_team:assign_permission')
|
||||
}
|
||||
} as const;
|
||||
|
||||
export type TemplateParamsMap = {
|
||||
[OperationLogEventEnum.LOGIN]: { name?: string };
|
||||
[OperationLogEventEnum.CREATE_INVITATION_LINK]: { name?: string; link: string };
|
||||
[OperationLogEventEnum.JOIN_TEAM]: { name?: string; link: string };
|
||||
[OperationLogEventEnum.CHANGE_MEMBER_NAME]: {
|
||||
name?: string;
|
||||
memberName: string;
|
||||
newName: string;
|
||||
};
|
||||
[OperationLogEventEnum.KICK_OUT_TEAM]: {
|
||||
name?: string;
|
||||
memberName: string;
|
||||
};
|
||||
[OperationLogEventEnum.CREATE_DEPARTMENT]: { name?: string; departmentName: string };
|
||||
[OperationLogEventEnum.CHANGE_DEPARTMENT]: {
|
||||
name?: string;
|
||||
departmentName: string;
|
||||
};
|
||||
[OperationLogEventEnum.DELETE_DEPARTMENT]: { name?: string; departmentName: string };
|
||||
[OperationLogEventEnum.RELOCATE_DEPARTMENT]: {
|
||||
name?: string;
|
||||
departmentName: string;
|
||||
};
|
||||
[OperationLogEventEnum.CREATE_GROUP]: { name?: string; groupName: string };
|
||||
[OperationLogEventEnum.DELETE_GROUP]: { name?: string; groupName: string };
|
||||
[OperationLogEventEnum.ASSIGN_PERMISSION]: {
|
||||
name?: string;
|
||||
objectName: string;
|
||||
permission: string;
|
||||
};
|
||||
};
|
40
packages/service/support/operationLog/schema.ts
Normal file
40
packages/service/support/operationLog/schema.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Schema, getMongoLogModel } from '../../common/mongo';
|
||||
import type { OperationLogSchema } from '@fastgpt/global/support/operationLog/type';
|
||||
import { OperationLogEventEnum } from '@fastgpt/global/support/operationLog/constants';
|
||||
import {
|
||||
TeamCollectionName,
|
||||
TeamMemberCollectionName
|
||||
} from '@fastgpt/global/support/user/team/constant';
|
||||
|
||||
export const OperationLogCollectionName = 'operationLog';
|
||||
|
||||
const OperationLogSchema = new Schema({
|
||||
tmbId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: TeamMemberCollectionName,
|
||||
required: true
|
||||
},
|
||||
teamId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: TeamCollectionName,
|
||||
required: true
|
||||
},
|
||||
timestamp: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
},
|
||||
event: {
|
||||
type: String,
|
||||
enum: Object.values(OperationLogEventEnum),
|
||||
required: true
|
||||
},
|
||||
metadata: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
});
|
||||
|
||||
export const MongoOperationLog = getMongoLogModel<OperationLogSchema>(
|
||||
OperationLogCollectionName,
|
||||
OperationLogSchema
|
||||
);
|
@@ -104,8 +104,11 @@ export async function addSourceMember<T extends { tmbId: string }>({
|
||||
const tmb = tmbList.find((tmb) => String(tmb._id) === String(item.tmbId));
|
||||
if (!tmb) return;
|
||||
|
||||
// @ts-ignore
|
||||
const formatItem = typeof item.toObject === 'function' ? item.toObject() : item;
|
||||
|
||||
return {
|
||||
...item,
|
||||
...formatItem,
|
||||
sourceMember: { name: tmb.name, avatar: tmb.avatar, status: tmb.status }
|
||||
};
|
||||
})
|
||||
|
Reference in New Issue
Block a user