mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-12 04:16:54 +08:00
feat: add api-based extension & external data tool & moderation (#1459)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { IOnCompleted, IOnData, IOnError, IOnMessageEnd } from './base'
|
||||
import type { IOnCompleted, IOnData, IOnError, IOnMessageEnd, IOnMessageReplace } from './base'
|
||||
import { get, post, ssePost } from './base'
|
||||
import type { ChatPromptConfig, CompletionPromptConfig } from '@/models/debug'
|
||||
import type { ModelModeType } from '@/types/app'
|
||||
@@ -9,10 +9,11 @@ export type AutomaticRes = {
|
||||
opening_statement: string
|
||||
}
|
||||
|
||||
export const sendChatMessage = async (appId: string, body: Record<string, any>, { onData, onCompleted, onError, getAbortController, onMessageEnd }: {
|
||||
export const sendChatMessage = async (appId: string, body: Record<string, any>, { onData, onCompleted, onError, getAbortController, onMessageEnd, onMessageReplace }: {
|
||||
onData: IOnData
|
||||
onCompleted: IOnCompleted
|
||||
onMessageEnd: IOnMessageEnd
|
||||
onMessageReplace: IOnMessageReplace
|
||||
onError: IOnError
|
||||
getAbortController?: (abortController: AbortController) => void
|
||||
}) => {
|
||||
@@ -21,24 +22,25 @@ export const sendChatMessage = async (appId: string, body: Record<string, any>,
|
||||
...body,
|
||||
response_mode: 'streaming',
|
||||
},
|
||||
}, { onData, onCompleted, onError, getAbortController, onMessageEnd })
|
||||
}, { onData, onCompleted, onError, getAbortController, onMessageEnd, onMessageReplace })
|
||||
}
|
||||
|
||||
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 }: {
|
||||
export const sendCompletionMessage = async (appId: string, body: Record<string, any>, { onData, onCompleted, onError, onMessageReplace }: {
|
||||
onData: IOnData
|
||||
onCompleted: IOnCompleted
|
||||
onError: IOnError
|
||||
onMessageReplace: IOnMessageReplace
|
||||
}) => {
|
||||
return ssePost(`apps/${appId}/completion-messages`, {
|
||||
body: {
|
||||
...body,
|
||||
response_mode: 'streaming',
|
||||
},
|
||||
}, { onData, onCompleted, onError })
|
||||
}, { onData, onCompleted, onError, onMessageReplace })
|
||||
}
|
||||
|
||||
export const fetchSuggestedQuestions = (appId: string, messageId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user