'use client' import type { FC } from 'react' import React, { useState } from 'react' import { useTranslation } from 'react-i18next' import { RiArrowDownSLine, RiLoader2Line, } from '@remixicon/react' import type { ToolInfoInThought } from '../type' import Panel from './panel' import cn from '@/utils/classnames' import { CheckCircle } from '@/app/components/base/icons/src/vender/solid/general' import { DataSet as DataSetIcon } from '@/app/components/base/icons/src/public/thought' import type { Emoji } from '@/app/components/tools/types' import AppIcon from '@/app/components/base/app-icon' type Props = { payload: ToolInfoInThought allToolIcons?: Record } const getIcon = (toolName: string, allToolIcons: Record) => { if (toolName.startsWith('dataset_')) return const icon = allToolIcons[toolName] if (!icon) return null return ( typeof icon === 'string' ? (
) : ( )) } const Tool: FC = ({ payload, allToolIcons = {}, }) => { const { t } = useTranslation() const { name, label, input, isFinished, output } = payload const toolName = name.startsWith('dataset_') ? t('dataset.knowledge') : name const toolLabel = name.startsWith('dataset_') ? t('dataset.knowledge') : label const [isShowDetail, setIsShowDetail] = useState(false) const icon = getIcon(name, allToolIcons) as any return (
setIsShowDetail(!isShowDetail)} > {!isFinished && ( )} {isFinished && !isShowDetail && ( )} {isFinished && isShowDetail && ( icon )} {t(`tools.thought.${isFinished ? 'used' : 'using'}`)} {toolLabel}
{isShowDetail && (
{output && ( )}
)}
) } export default React.memo(Tool)