diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsx index c5e1b582a5..a8a6d640ff 100644 --- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx +++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx @@ -392,14 +392,14 @@ export const useEmbeddedChatbot = () => { }, [mutateAppConversationData, handleConversationIdInfoChange]) const handleFeedback = useCallback(async (messageId: string, feedback: Feedback) => { - await updateFeedback({ url: `/messages/${messageId}/feedbacks`, body: { rating: feedback.rating, content: feedback.content } }, isInstalledApp, appId) + await updateFeedback({ url: `/messages/${messageId}/feedbacks`, body: { rating: feedback.rating, content: feedback.content } }, appSourceType, appId) notify({ type: 'success', message: t('common.api.success') }) - }, [isInstalledApp, appId, t, notify]) + }, [appSourceType, appId, t, notify]) return { appInfoError, appInfoLoading: appInfoLoading || (systemFeatures.webapp_auth.enabled && isCheckingPermission), - userCanAccess: systemFeatures.webapp_auth.enabled ? userCanAccessResult?.result : true, + userCanAccess: systemFeatures.webapp_auth.enabled ? (userCanAccessResult as { result: boolean })?.result : true, isInstalledApp, allowResetChat, appId, diff --git a/web/service/debug.ts b/web/service/debug.ts index fab2910c5e..61057c591f 100644 --- a/web/service/debug.ts +++ b/web/service/debug.ts @@ -1,5 +1,5 @@ import { get, post, ssePost } from './base' -import type { IOnCompleted, IOnData, IOnError, IOnFile, IOnMessageEnd, IOnMessageReplace, IOnThought } from './base' +import type { IOnCompleted, IOnData, IOnError, IOnMessageReplace } from './base' import type { ChatPromptConfig, CompletionPromptConfig } from '@/models/debug' import type { ModelModeType } from '@/types/app' import type { ModelParameterRule } from '@/app/components/header/account-setting/model-provider-page/declarations' @@ -24,24 +24,6 @@ export type CodeGenRes = { error?: string } -export const sendChatMessage = async (appId: string, body: Record, { onData, onCompleted, onThought, onFile, onError, getAbortController, onMessageEnd, onMessageReplace }: { - onData: IOnData - onCompleted: IOnCompleted - onFile: IOnFile - onThought: IOnThought - onMessageEnd: IOnMessageEnd - onMessageReplace: IOnMessageReplace - onError: IOnError - getAbortController?: (abortController: AbortController) => void -}) => { - return ssePost(`apps/${appId}/chat-messages`, { - body: { - ...body, - response_mode: 'streaming', - }, - }, { onData, onCompleted, onThought, onFile, onError, getAbortController, onMessageEnd, onMessageReplace }) -} - export const stopChatMessageResponding = async (appId: string, taskId: string) => { return post(`apps/${appId}/chat-messages/${taskId}/stop`) } diff --git a/web/service/share.ts b/web/service/share.ts index 792d5e80d3..41cf92a625 100644 --- a/web/service/share.ts +++ b/web/service/share.ts @@ -2,22 +2,17 @@ import type { IOnCompleted, IOnData, IOnError, - IOnFile, IOnIterationFinished, IOnIterationNext, IOnIterationStarted, IOnLoopFinished, IOnLoopNext, IOnLoopStarted, - IOnMessageEnd, IOnMessageReplace, IOnNodeFinished, IOnNodeStarted, - IOnTTSChunk, - IOnTTSEnd, IOnTextChunk, IOnTextReplace, - IOnThought, IOnWorkflowFinished, IOnWorkflowStarted, } from './base' @@ -70,26 +65,6 @@ export function getUrl(url: string, appSourceType: AppSourceType, appId: string) return hasPrefix ? `${apiPrefix[appSourceType]}/${appId}/${url.startsWith('/') ? url.slice(1) : url}` : url } -export const sendChatMessage = async (body: Record, { onData, onCompleted, onThought, onFile, onError, getAbortController, onMessageEnd, onMessageReplace, onTTSChunk, onTTSEnd }: { - onData: IOnData - onCompleted: IOnCompleted - onFile: IOnFile - onThought: IOnThought - onError: IOnError - onMessageEnd?: IOnMessageEnd - onMessageReplace?: IOnMessageReplace - getAbortController?: (abortController: AbortController) => void - onTTSChunk?: IOnTTSChunk - onTTSEnd?: IOnTTSEnd -}, appSourceType: AppSourceType, installedAppId = '') => { - return ssePost(getUrl('chat-messages', appSourceType, installedAppId), { - body: { - ...body, - response_mode: 'streaming', - }, - }, { onData, onCompleted, onThought, onFile, isPublicAPI: !getIsPublicAPI(appSourceType), onError, getAbortController, onMessageEnd, onMessageReplace, onTTSChunk, onTTSEnd }) -} - export const stopChatMessageResponding = async (appId: string, taskId: string, appSourceType: AppSourceType, installedAppId = '') => { return getAction('post', appSourceType)(getUrl(`chat-messages/${taskId}/stop`, appSourceType, installedAppId)) } @@ -296,10 +271,6 @@ export const audioToText = (url: string, appSourceType: AppSourceType, body: For return (getAction('post', appSourceType))(url, { body }, { bodyStringify: false, deleteContentType: true }) as Promise<{ text: string }> } -export const textToAudio = (url: string, appSourceType: AppSourceType, body: FormData) => { - return (getAction('post', appSourceType))(url, { body }, { bodyStringify: false, deleteContentType: true }) as Promise<{ data: string }> -} - export const textToAudioStream = (url: string, appSourceType: AppSourceType, header: { content_type: string }, body: { streaming: boolean; voice?: string; message_id?: string; text?: string | null | undefined }) => { return (getAction('post', appSourceType))(url, { body, header }, { needAllResponseContent: true }) }