diff --git a/web/app/components/app/text-generate/item/index.tsx b/web/app/components/app/text-generate/item/index.tsx index 5b12e9a669..9654e86558 100644 --- a/web/app/components/app/text-generate/item/index.tsx +++ b/web/app/components/app/text-generate/item/index.tsx @@ -52,7 +52,7 @@ export type IGenerationItemProps = { onFeedback?: (feedback: FeedbackType) => void onSave?: (messageId: string) => void isMobile?: boolean - isInstalledApp: boolean + appSourceType: AppSourceType installedAppId?: string taskId?: string controlClearMoreLikeThis?: number @@ -86,7 +86,7 @@ const GenerationItem: FC = ({ onSave, depth = 1, isMobile, - isInstalledApp, + appSourceType, installedAppId, taskId, controlClearMoreLikeThis, @@ -111,8 +111,6 @@ const GenerationItem: FC = ({ const setCurrentLogItem = useAppStore(s => s.setCurrentLogItem) const setShowPromptLogModal = useAppStore(s => s.setShowPromptLogModal) - const appSourceType = isInstalledApp ? AppSourceType.installedApp : AppSourceType.webApp - const handleFeedback = async (childFeedback: FeedbackType) => { await updateFeedback({ url: `/messages/${childMessageId}/feedbacks`, body: { rating: childFeedback.rating } }, appSourceType, installedAppId) setChildFeedback(childFeedback) @@ -132,7 +130,7 @@ const GenerationItem: FC = ({ onSave, isShowTextToSpeech, isMobile, - isInstalledApp, + appSourceType, installedAppId, controlClearMoreLikeThis, isWorkflow, @@ -294,7 +292,7 @@ const GenerationItem: FC = ({ {!isWorkflow && {content?.length} {t('common.unit.char')}} {/* action buttons */}
- {!isInWebApp && !isInstalledApp && !isResponding && ( + {!isInWebApp && (appSourceType !== AppSourceType.installedApp) && !isResponding && (
diff --git a/web/app/components/share/text-generation/index.tsx b/web/app/components/share/text-generation/index.tsx index 4a8f37a61e..f5bf04697e 100644 --- a/web/app/components/share/text-generation/index.tsx +++ b/web/app/components/share/text-generation/index.tsx @@ -401,8 +401,8 @@ const TextGeneration: FC = ({ isCallBatchAPI={isCallBatchAPI} isPC={isPC} isMobile={!isPC} - isInstalledApp={isInstalledApp} - installedAppInfo={installedAppInfo} + appSourceType={isInstalledApp ? AppSourceType.installedApp : AppSourceType.webApp} + appId={installedAppInfo?.id} isError={task?.status === TaskStatus.failed} promptConfig={promptConfig} moreLikeThisEnabled={!!moreLikeThisConfig?.enabled} diff --git a/web/app/components/share/text-generation/result/index.tsx b/web/app/components/share/text-generation/result/index.tsx index f9d206db2b..b3b4cb03ba 100644 --- a/web/app/components/share/text-generation/result/index.tsx +++ b/web/app/components/share/text-generation/result/index.tsx @@ -7,11 +7,11 @@ import produce from 'immer' import TextGenerationRes from '@/app/components/app/text-generate/item' import NoData from '@/app/components/share/text-generation/no-data' import Toast from '@/app/components/base/toast' -import { AppSourceType, sendCompletionMessage, sendWorkflowMessage, updateFeedback } from '@/service/share' +import type { AppSourceType } from '@/service/share' +import { sendCompletionMessage, sendWorkflowMessage, updateFeedback } from '@/service/share' import type { FeedbackType } from '@/app/components/base/chat/chat/type' import Loading from '@/app/components/base/loading' import type { PromptConfig } from '@/models/debug' -import type { InstalledApp } from '@/models/explore' import { TransferMethod, type VisionFile, type VisionSettings } from '@/types/app' import { NodeRunningStatus, WorkflowRunningStatus } from '@/app/components/workflow/types' import type { WorkflowProcess } from '@/app/components/base/chat/types' @@ -28,8 +28,8 @@ export type IResultProps = { isCallBatchAPI: boolean isPC: boolean isMobile: boolean - isInstalledApp: boolean - installedAppInfo?: InstalledApp + appSourceType: AppSourceType + appId?: string isError: boolean isShowTextToSpeech: boolean promptConfig: PromptConfig | null @@ -53,8 +53,8 @@ const Result: FC = ({ isCallBatchAPI, isPC, isMobile, - isInstalledApp, - installedAppInfo, + appSourceType, + appId, isError, isShowTextToSpeech, promptConfig, @@ -72,7 +72,6 @@ const Result: FC = ({ siteInfo, onRunStart, }) => { - const appSourceType = isInstalledApp ? AppSourceType.installedApp : AppSourceType.webApp const [isResponding, { setTrue: setRespondingTrue, setFalse: setRespondingFalse }] = useBoolean(false) useEffect(() => { if (controlStopResponding) @@ -103,7 +102,7 @@ const Result: FC = ({ }) const handleFeedback = async (feedback: FeedbackType) => { - await updateFeedback({ url: `/messages/${messageId}/feedbacks`, body: { rating: feedback.rating, content: feedback.content } }, appSourceType, installedAppInfo?.id) + await updateFeedback({ url: `/messages/${messageId}/feedbacks`, body: { rating: feedback.rating, content: feedback.content } }, appSourceType, appId) setFeedback(feedback) } @@ -360,7 +359,7 @@ const Result: FC = ({ }, }, appSourceType, - installedAppInfo?.id, + appId, ) } else { @@ -393,7 +392,7 @@ const Result: FC = ({ onCompleted(getCompletionRes(), taskId, false) isEnd = true }, - }, appSourceType, installedAppInfo?.id) + }, appSourceType, appId) } } @@ -424,8 +423,8 @@ const Result: FC = ({ feedback={feedback} onSave={handleSaveMessage} isMobile={isMobile} - isInstalledApp={isInstalledApp} - installedAppId={installedAppInfo?.id} + appSourceType={appSourceType} + installedAppId={appId} isLoading={isCallBatchAPI ? (!completionRes && isResponding) : false} taskId={isCallBatchAPI ? ((taskId as number) < 10 ? `0${taskId}` : `${taskId}`) : undefined} controlClearMoreLikeThis={controlClearMoreLikeThis} diff --git a/web/app/components/try/app/text-generation.tsx b/web/app/components/try/app/text-generation.tsx index 5b967d083a..1485cfac6f 100644 --- a/web/app/components/try/app/text-generation.tsx +++ b/web/app/components/try/app/text-generation.tsx @@ -20,18 +20,19 @@ import Res from '@/app/components/share/text-generation/result' import type { Task } from '../../share/text-generation/types' import { TaskStatus } from '../../share/text-generation/types' import { noop } from 'lodash' +import { AppSourceType } from '@/service/share' type Props = { appId: string - isWorkflow?: boolean className?: string } const TextGeneration: FC = ({ - isWorkflow = false, + appId, className, }) => { // const { t } = useTranslation() + const isWorkflow = true // wait for detail app info to decide // app.mode === 'completion' | 'workflow' const media = useBreakpoints() const isPC = media === MediaType.pc @@ -54,7 +55,6 @@ const TextGeneration: FC = ({ const [moreLikeThisConfig, setMoreLikeThisConfig] = useState(null) const [textToSpeechConfig, setTextToSpeechConfig] = useState(null) const [controlSend, setControlSend] = useState(0) - const [controlStopResponding, setControlStopResponding] = useState(0) const [visionConfig, setVisionConfig] = useState({ enabled: false, number_limits: 2, @@ -62,10 +62,7 @@ const TextGeneration: FC = ({ transfer_methods: [TransferMethod.local_file], }) const [completionFiles, setCompletionFiles] = useState([]) - const [controlRetry, setControlRetry] = useState(0) const [isShowResultPanel, { setTrue: doShowResultPanel, setFalse: hideResultPanel }] = useBoolean(false) -// to temp fix lint - console.log(setControlStopResponding, setControlRetry) const showResultPanel = () => { // fix: useClickAway hideResSidebar will close sidebar setTimeout(() => { @@ -125,15 +122,13 @@ const TextGeneration: FC = ({ isCallBatchAPI={false} isPC={isPC} isMobile={!isPC} - isInstalledApp={false} - installedAppInfo={{}} + appSourceType={AppSourceType.webApp} // todo for call the api + appId={appId} isError={task?.status === TaskStatus.failed} promptConfig={promptConfig} moreLikeThisEnabled={!!moreLikeThisConfig?.enabled} inputs={inputs} controlSend={controlSend} - controlRetry={task?.status === TaskStatus.failed ? controlRetry : 0} - controlStopResponding={controlStopResponding} onShowRes={showResultPanel} handleSaveMessage={noop} taskId={task?.id} diff --git a/web/service/share.ts b/web/service/share.ts index dabddfdd4c..a940af98c5 100644 --- a/web/service/share.ts +++ b/web/service/share.ts @@ -113,9 +113,9 @@ export const sendWorkflowMessage = async ( onTextReplace: IOnTextReplace }, appSourceType: AppSourceType, - installedAppId = '', + appId = '', ) => { - return ssePost(getUrl('workflows/run', appSourceType, installedAppId), { + return ssePost(getUrl('workflows/run', appSourceType, appId), { body: { ...body, response_mode: 'streaming',