mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-02 05:54:44 +00:00
feat(agent): support aborting agent execution in local and temporal modes
This commit is contained in:
@@ -43,6 +43,7 @@ interface ChatbotState {
|
||||
projectId: string,
|
||||
contextAssetId?: string,
|
||||
) => Promise<void>
|
||||
abortActiveSession: (teamId: string) => Promise<void>
|
||||
}
|
||||
|
||||
export const useChatbotStore = create<ChatbotState>((set) => ({
|
||||
@@ -303,4 +304,23 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
|
||||
set({ isStreaming: false })
|
||||
}
|
||||
},
|
||||
|
||||
abortActiveSession: async (teamId) => {
|
||||
const { currentSessionId, isStreaming } = useChatbotStore.getState()
|
||||
if (!currentSessionId || !isStreaming) return
|
||||
|
||||
try {
|
||||
const res = await client.api.teams[':teamId'].chat.sessions[':sessionId'].abort.$post({
|
||||
param: { teamId, sessionId: currentSessionId },
|
||||
})
|
||||
if (res.ok) {
|
||||
toast.success('Agent execution stopped')
|
||||
} else {
|
||||
throw new Error('Failed to abort agent execution')
|
||||
}
|
||||
} catch (err) {
|
||||
const errMsg = err instanceof Error ? err.message : 'Failed to abort execution'
|
||||
toast.error(errMsg)
|
||||
}
|
||||
},
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user