import { Accordion } from "@/components/bs-ui/accordion"; import { SearchInput } from "@/components/bs-ui/input"; import { Sheet, SheetContent, SheetTitle, SheetTrigger } from "@/components/bs-ui/sheet"; import { getAssistantToolsApi } from "@/controllers/API/assistant"; import ToolItem from "@/pages/SkillPage/components/ToolItem"; import { useTranslation } from "react-i18next"; import { PersonIcon, StarFilledIcon } from "@radix-ui/react-icons"; import { useEffect, useMemo, useState } from "react"; import { Button } from "@/components/bs-ui/button"; import sousuo from "../../../assets/npc/sousuo.png"; import gongjuAdd from "../../../assets/npc/gongjuAdd.png"; import gongjuIcon from "../../../assets/npc/gongjuIcon.png"; import gongjuIcon1 from "../../../assets/npc/gongjuIcon1.png"; export default function ToolsSheet({ select, onSelect, children }) { const { t } = useTranslation() const [type, setType] = useState('default') // default custom const [keyword, setKeyword] = useState('') const [allData, setAllData] = useState([]) useEffect(() => { getAssistantToolsApi(type).then(res => { setAllData(res) setKeyword('') }) }, [type]) const options = useMemo(() => { return allData.filter(el => el.name.toLowerCase().includes(keyword.toLowerCase()) || el.description.toLowerCase().includes(keyword.toLowerCase()) ) }, [keyword, allData]) return ( !open && setKeyword('')}> {children}
e.stopPropagation()}>
{t('build.addTool')}
setKeyword(e.target.value)} type="text" />
{/* setKeyword(e.target.value)} /> */} {/* */}
window.open("/build/tools")}> 自定义工具
setType('default')} > {/* */} {type === "default" ? : } 内置工具
setType('custom')} > {type === "custom" ? : } {/* */} 自定义工具
{ options.length ? options.map(el => ( )) :
{t('build.empty')}
}
); };