mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-08 18:36:53 +08:00
feat: stop response call api (#340)
This commit is contained in:
@@ -23,7 +23,8 @@ const baseOptions = {
|
||||
}
|
||||
|
||||
export type IOnDataMoreInfo = {
|
||||
conversationId: string | undefined
|
||||
conversationId?: string
|
||||
taskId?: string
|
||||
messageId: string
|
||||
errorMessage?: string
|
||||
}
|
||||
@@ -101,6 +102,7 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
|
||||
// can not use format here. Because message is splited.
|
||||
onData(unicodeToChar(bufferObj.answer), isFirstMessage, {
|
||||
conversationId: bufferObj.conversation_id,
|
||||
taskId: bufferObj.task_id,
|
||||
messageId: bufferObj.id,
|
||||
})
|
||||
isFirstMessage = false
|
||||
|
||||
@@ -15,6 +15,10 @@ export const sendChatMessage = async (appId: string, body: Record<string, any>,
|
||||
}, { onData, onCompleted, onError, getAbortController })
|
||||
}
|
||||
|
||||
export const stopChatMessageResponding = async (appId: string, taskId: string) => {
|
||||
return post(`apps/${appId}/chat-messages/${taskId}/stop`)
|
||||
}
|
||||
|
||||
export const sendCompletionMessage = async (appId: string, body: Record<string, any>, { onData, onCompleted, onError }: {
|
||||
onData: IOnData
|
||||
onCompleted: IOnCompleted
|
||||
|
||||
@@ -34,6 +34,10 @@ export const sendChatMessage = async (body: Record<string, any>, { onData, onCom
|
||||
}, { onData, onCompleted, isPublicAPI: !isInstalledApp, onError, getAbortController })
|
||||
}
|
||||
|
||||
export const stopChatMessageResponding = async (appId: string, taskId: string, isInstalledApp: boolean, installedAppId = '') => {
|
||||
return getAction('post', isInstalledApp)(getUrl(`chat-messages/${taskId}/stop`, isInstalledApp, installedAppId))
|
||||
}
|
||||
|
||||
export const sendCompletionMessage = async (body: Record<string, any>, { onData, onCompleted, onError }: {
|
||||
onData: IOnData
|
||||
onCompleted: IOnCompleted
|
||||
|
||||
Reference in New Issue
Block a user