'use client' import type { FC } from 'react' import React from 'react' import cn from 'classnames' import { useBoolean, useClickAway } from 'ahooks' import s from './style.module.css' import ModelIcon from '@/app/components/app/configuration/config-model/model-icon' import { Google, WebReader, Wikipedia } from '@/app/components/base/icons/src/public/plugins' import ConfigDetail from '@/app/components/explore/universal-chat/config-view/detail' export type ISummaryProps = { modelId: string plugins: Record dataSets: any[] } const getColorInfo = (modelId: string) => { if (modelId === 'gpt-4') return s.gpt4 if (modelId === 'claude-2') return s.claude return s.gpt3 } const getPlugIcon = (pluginId: string) => { const className = 'w-4 h-4' switch (pluginId) { case 'google_search': return case 'web_reader': return case 'wikipedia': return default: return null } } const Summary: FC = ({ modelId, plugins, dataSets, }) => { // current_datetime is not configable and do not have icon const pluginIds = Object.keys(plugins).filter(key => plugins[key] && key !== 'current_datetime') const [isShowConfig, { setFalse: hideConfig, toggle: toggleShowConfig }] = useBoolean(false) const configContentRef = React.useRef(null) useClickAway(() => { hideConfig() }, configContentRef) return (
{modelId}
{ pluginIds.length > 0 && (
{pluginIds.map(pluginId => (
{getPlugIcon(pluginId)}
))}
) }
{isShowConfig && ( )}
) } export default React.memo(Summary)