feat: custom feedback plugin (#1365)

This commit is contained in:
Archer
2024-05-06 11:01:50 +08:00
committed by GitHub
parent b500631a4d
commit d057ba29f0
3 changed files with 164 additions and 282 deletions

View File

@@ -69,21 +69,25 @@ const callbackMap: Record<`${FlowNodeTypeEnum}`, Function> = {
[FlowNodeTypeEnum.globalVariable]: () => Promise.resolve()
};
/* running */
export async function dispatchWorkFlow({
res,
runtimeNodes = [],
runtimeEdges = [],
histories = [],
variables = {},
user,
stream = false,
detail = false,
...props
}: ChatDispatchProps & {
type Props = ChatDispatchProps & {
runtimeNodes: RuntimeNodeItemType[];
runtimeEdges: RuntimeEdgeItemType[];
}): Promise<DispatchFlowResponse> {
};
/* running */
export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowResponse> {
let {
res,
runtimeNodes = [],
runtimeEdges = [],
histories = [],
variables = {},
user,
stream = false,
detail = false,
...props
} = data;
// set sse response headers
if (stream && res) {
res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
@@ -93,7 +97,7 @@ export async function dispatchWorkFlow({
}
variables = {
...getSystemVariable({ timezone: user.timezone }),
...getSystemVariable(data),
...variables
};
@@ -384,9 +388,19 @@ export function responseStatus({
}
/* get system variable */
export function getSystemVariable({ timezone }: { timezone: string }) {
export function getSystemVariable({
user,
appId,
chatId,
responseChatItemId,
histories = []
}: Props) {
return {
cTime: getSystemTime(timezone)
appId,
chatId,
responseChatItemId,
histories,
cTime: getSystemTime(user.timezone)
};
}