Commit d057ba29 by Archer Committed by GitHub

feat: custom feedback plugin (#1365)

parent b500631a
...@@ -69,21 +69,25 @@ const callbackMap: Record<`${FlowNodeTypeEnum}`, Function> = { ...@@ -69,21 +69,25 @@ const callbackMap: Record<`${FlowNodeTypeEnum}`, Function> = {
[FlowNodeTypeEnum.globalVariable]: () => Promise.resolve() [FlowNodeTypeEnum.globalVariable]: () => Promise.resolve()
}; };
/* running */ type Props = ChatDispatchProps & {
export async function dispatchWorkFlow({
res,
runtimeNodes = [],
runtimeEdges = [],
histories = [],
variables = {},
user,
stream = false,
detail = false,
...props
}: ChatDispatchProps & {
runtimeNodes: RuntimeNodeItemType[]; runtimeNodes: RuntimeNodeItemType[];
runtimeEdges: RuntimeEdgeItemType[]; 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 // set sse response headers
if (stream && res) { if (stream && res) {
res.setHeader('Content-Type', 'text/event-stream;charset=utf-8'); res.setHeader('Content-Type', 'text/event-stream;charset=utf-8');
...@@ -93,7 +97,7 @@ export async function dispatchWorkFlow({ ...@@ -93,7 +97,7 @@ export async function dispatchWorkFlow({
} }
variables = { variables = {
...getSystemVariable({ timezone: user.timezone }), ...getSystemVariable(data),
...variables ...variables
}; };
...@@ -384,9 +388,19 @@ export function responseStatus({ ...@@ -384,9 +388,19 @@ export function responseStatus({
} }
/* get system variable */ /* get system variable */
export function getSystemVariable({ timezone }: { timezone: string }) { export function getSystemVariable({
user,
appId,
chatId,
responseChatItemId,
histories = []
}: Props) {
return { return {
cTime: getSystemTime(timezone) appId,
chatId,
responseChatItemId,
histories,
cTime: getSystemTime(user.timezone)
}; };
} }
......
...@@ -42,7 +42,6 @@ export const pushChatUsage = ({ ...@@ -42,7 +42,6 @@ export const pushChatUsage = ({
addLog.info(`finish completions`, { addLog.info(`finish completions`, {
source, source,
teamId, teamId,
tmbId,
totalPoints totalPoints
}); });
return { totalPoints }; return { totalPoints };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment