import { CopyButton, Icon, Markdown } from '@bentwnghk/ui'; import { createStyles } from 'antd-style'; import { AnimatePresence, motion } from 'framer-motion'; import { AtomIcon, ChevronDown, ChevronRight } from 'lucide-react'; import { rgba } from 'polished'; import { CSSProperties, memo, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { Flexbox } from 'react-layout-kit'; import { CitationItem } from '@/types/message'; const useStyles = createStyles(({ css, token, isDarkMode }) => ({ container: css` width: fit-content; padding-block: 4px; padding-inline: 8px; border-radius: 6px; color: ${token.colorTextTertiary}; &:hover { background: ${isDarkMode ? token.colorFillQuaternary : token.colorFillTertiary}; } `, expand: css` background: ${isDarkMode ? token.colorFillQuaternary : token.colorFillTertiary} !important; `, shinyText: css` color: ${rgba(token.colorText, 0.45)}; background: linear-gradient( 120deg, ${rgba(token.colorTextBase, 0)} 40%, ${token.colorTextSecondary} 50%, ${rgba(token.colorTextBase, 0)} 60% ); background-clip: text; background-size: 200% 100%; animation: shine 1.5s linear infinite; @keyframes shine { 0% { background-position: 100%; } 100% { background-position: -100%; } } `, title: css` overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; font-size: 12px; text-overflow: ellipsis; `, })); interface ThinkingProps { citations?: CitationItem[]; content?: string; duration?: number; style?: CSSProperties; thinking?: boolean; } const Thinking = memo(({ content, duration, thinking, style, citations }) => { const { t } = useTranslation(['components', 'common']); const { styles, cx } = useStyles(); const [showDetail, setShowDetail] = useState(false); useEffect(() => { setShowDetail(!!thinking); }, [thinking]); return ( { setShowDetail(!showDetail); }} style={{ cursor: 'pointer' }} > {thinking ? ( {t('Thinking.thinking')} ) : ( {!duration ? t('Thinking.thoughtWithDuration') : t('Thinking.thought', { duration: ((duration || 0) / 1000).toFixed(1) })} )} {showDetail && content && (
{ event.stopPropagation(); }} >
)}
{showDetail && ( {typeof content === 'string' ? ( {content} ) : ( content )} )}
); }); export default Thinking;