import React, { useMemo, useState } from 'react'; import { Box, useTheme, Flex, Image } from '@chakra-ui/react'; import type { ChatHistoryItemResType } from '@fastgpt/global/core/chat/api.d'; import { useTranslation } from 'react-i18next'; import { ModuleTemplatesFlat } from '@/constants/flow/ModuleTemplate'; import Tabs from '../Tabs'; import MyModal from '../MyModal'; import MyTooltip from '../MyTooltip'; import { QuestionOutlineIcon } from '@chakra-ui/icons'; import { formatPrice } from '@fastgpt/global/support/wallet/bill/tools'; function Row({ label, value }: { label: string; value?: string | number | React.ReactNode }) { const theme = useTheme(); return value !== undefined && value !== '' && value !== 'undefined' ? ( {label}: {value} ) : null; } const WholeResponseModal = ({ response, onClose }: { response: ChatHistoryItemResType[]; onClose: () => void; }) => { const theme = useTheme(); const { t } = useTranslation(); const list = useMemo( () => response.map((item, i) => ({ label: ( item.moduleType === template.flowType)?.logo } alt={''} w={['14px', '16px']} /> {item.moduleName} ), id: `${i}` })), [response] ); const [currentTab, setCurrentTab] = useState(`0`); const activeModule = useMemo(() => response[Number(currentTab)], [currentTab, response]); return ( {t('chat.Complete Response')} } > {activeModule?.price !== undefined && ( )} {/* ai chat */} { try { JSON.stringify(activeModule.quoteList, null, 2); } catch (error) { return ''; } })()} /> { if (!activeModule?.historyPreview) return ''; return ( <> {activeModule.historyPreview.map((item, i) => ( {item.obj} {item.value} ))} ); })()} /> {/* dataset search */} {/* classify question */} { if (!activeModule?.cqList) return ''; return ( {activeModule.cqList.map((item) => ( {item.value} ))} ); })()} /> {/* extract */} { try { return JSON.stringify(activeModule?.extractResult, null, 2); } catch (error) { return ''; } })()} /> {/* http */} { try { return JSON.stringify(activeModule?.body, null, 2); } catch (error) { return ''; } })()} /> { try { return JSON.stringify(activeModule?.httpResult, null, 2); } catch (error) { return ''; } })()} /> {/* plugin */} { try { return JSON.stringify(activeModule?.pluginOutput, null, 2); } catch (error) { return ''; } })()} /> ); }; export default WholeResponseModal;