mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
web app support workflow
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import type { IOnCompleted, IOnData, IOnError, IOnFile, IOnMessageEnd, IOnMessageReplace, IOnThought } from './base'
|
||||
import type { IOnCompleted, IOnData, IOnError, IOnFile, IOnMessageEnd, IOnMessageReplace, IOnTextChunk, IOnTextReplace, IOnThought, IOnWorkflowFinished, IOnWorkflowStarted } from './base'
|
||||
import {
|
||||
del as consoleDel, get as consoleGet, patch as consolePatch, post as consolePost,
|
||||
delPublic as del, getPublic as get, patchPublic as patch, postPublic as post, ssePost,
|
||||
@ -65,6 +65,32 @@ export const sendCompletionMessage = async (body: Record<string, any>, { onData,
|
||||
}, { onData, onCompleted, isPublicAPI: !isInstalledApp, onError, onMessageReplace })
|
||||
}
|
||||
|
||||
export const sendWorkflowMessage = async (
|
||||
body: Record<string, any>,
|
||||
{
|
||||
onTextChunk,
|
||||
onWorkflowStarted,
|
||||
onTextReplace,
|
||||
onWorkflowFinished,
|
||||
onError,
|
||||
}: {
|
||||
onTextChunk: IOnTextChunk
|
||||
onWorkflowStarted: IOnWorkflowStarted
|
||||
onWorkflowFinished: IOnWorkflowFinished
|
||||
onTextReplace: IOnTextReplace
|
||||
onError: IOnError
|
||||
},
|
||||
isInstalledApp: boolean,
|
||||
installedAppId = '',
|
||||
) => {
|
||||
return ssePost(getUrl('workflows/run', isInstalledApp, installedAppId), {
|
||||
body: {
|
||||
...body,
|
||||
response_mode: 'streaming',
|
||||
},
|
||||
}, { onTextChunk, onWorkflowStarted, onWorkflowFinished, isPublicAPI: !isInstalledApp, onError, onTextReplace })
|
||||
}
|
||||
|
||||
export const fetchAppInfo = async () => {
|
||||
return get('/site') as Promise<AppData>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user