import type { FC } from 'react' import type { InputValueTypes, Task, TextGenerationRunControl } from './types' import type { PromptConfig } from '@/models/debug' import type { SiteInfo } from '@/models/share' import type { AppSourceType } from '@/service/share' import type { VisionFile, VisionSettings } from '@/types/app' import { useTranslation } from 'react-i18next' import Loading from '@/app/components/base/loading' import Res from '@/app/components/share/text-generation/result' import { cn } from '@/utils/classnames' import ResDownload from './run-batch/res-download' import { TaskStatus } from './types' type TextGenerationResultPanelProps = { allFailedTaskList: Task[] allSuccessTaskList: Task[] allTaskList: Task[] appId: string appSourceType: AppSourceType completionFiles: VisionFile[] controlRetry: number controlSend: number controlStopResponding: number exportRes: Record[] handleCompleted: (completionRes: string, taskId?: number, isSuccess?: boolean) => void handleRetryAllFailedTask: () => void handleSaveMessage: (messageId: string) => Promise inputs: Record isCallBatchAPI: boolean isPC: boolean isShowResultPanel: boolean isWorkflow: boolean moreLikeThisEnabled: boolean noPendingTask: boolean onHideResultPanel: () => void onRunControlChange: (control: TextGenerationRunControl | null) => void onRunStart: () => void onShowResultPanel: () => void promptConfig: PromptConfig resultExisted: boolean showTaskList: Task[] siteInfo: SiteInfo textToSpeechEnabled: boolean visionConfig: VisionSettings } const TextGenerationResultPanel: FC = ({ allFailedTaskList, allSuccessTaskList, allTaskList, appId, appSourceType, completionFiles, controlRetry, controlSend, controlStopResponding, exportRes, handleCompleted, handleRetryAllFailedTask, handleSaveMessage, inputs, isCallBatchAPI, isPC, isShowResultPanel, isWorkflow, moreLikeThisEnabled, noPendingTask, onHideResultPanel, onRunControlChange, onRunStart, onShowResultPanel, promptConfig, resultExisted, showTaskList, siteInfo, textToSpeechEnabled, visionConfig, }) => { const { t } = useTranslation() const renderResult = (task?: Task) => ( ) return (
{!isPC && (
{ if (isShowResultPanel) onHideResultPanel() else onShowResultPanel() }} >
)}
{isCallBatchAPI && (
{t('generation.executions', { ns: 'share', num: allTaskList.length })}
{allSuccessTaskList.length > 0 && ( )}
)}
{isCallBatchAPI ? showTaskList.map(task => renderResult(task)) : renderResult()} {!noPendingTask && (
)}
{isCallBatchAPI && allFailedTaskList.length > 0 && (
{t('generation.batchFailed.info', { ns: 'share', num: allFailedTaskList.length })}
{t('generation.batchFailed.retry', { ns: 'share' })}
)}
) } export default TextGenerationResultPanel