feat: add api-based extension & external data tool & moderation (#1459)

This commit is contained in:
zxhlyh
2023-11-06 19:36:32 +08:00
committed by GitHub
parent db43ed6f41
commit 32747641e4
84 changed files with 3327 additions and 167 deletions

View File

@@ -12,6 +12,7 @@ import type { Feedbacktype } from '@/app/components/app/chat/type'
import Loading from '@/app/components/base/loading'
import type { PromptConfig } from '@/models/debug'
import type { InstalledApp } from '@/models/explore'
import type { ModerationService } from '@/models/common'
export type IResultProps = {
isCallBatchAPI: boolean
isPC: boolean
@@ -29,6 +30,8 @@ export type IResultProps = {
handleSaveMessage: (messageId: string) => void
taskId?: number
onCompleted: (completionRes: string, taskId?: number, success?: boolean) => void
enableModeration?: boolean
moderationService?: (text: string) => ReturnType<ModerationService>
}
const Result: FC<IResultProps> = ({
@@ -127,7 +130,7 @@ const Result: FC<IResultProps> = ({
})
setCompletionRes('')
const res: string[] = []
let res: string[] = []
let tempMessageId = ''
if (!isPC)
@@ -160,6 +163,10 @@ const Result: FC<IResultProps> = ({
onCompleted(getCompletionRes(), taskId, true)
clearInterval(runId)
},
onMessageReplace: (messageReplace) => {
res = [messageReplace.answer]
setCompletionRes(res.join(''))
},
onError() {
if (isTimeout)
return