|
|
|
@ -30,14 +30,30 @@ import ConfigCredential from '@/app/components/tools/setting/build-in/config-cre
|
|
|
|
import { updateBuiltInToolCredential } from '@/service/tools'
|
|
|
|
import { updateBuiltInToolCredential } from '@/service/tools'
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
import cn from '@/utils/classnames'
|
|
|
|
import ToolPicker from '@/app/components/workflow/block-selector/tool-picker'
|
|
|
|
import ToolPicker from '@/app/components/workflow/block-selector/tool-picker'
|
|
|
|
import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types'
|
|
|
|
import type { ToolDefaultValue, ToolValue } from '@/app/components/workflow/block-selector/types'
|
|
|
|
import { canFindTool } from '@/utils'
|
|
|
|
import { canFindTool } from '@/utils'
|
|
|
|
|
|
|
|
import { useAllBuiltInTools, useAllCustomTools, useAllMCPTools, useAllWorkflowTools } from '@/service/use-tools'
|
|
|
|
|
|
|
|
import type { ToolWithProvider } from '@/app/components/workflow/types'
|
|
|
|
|
|
|
|
|
|
|
|
type AgentToolWithMoreInfo = AgentTool & { icon: any; collection?: Collection } | null
|
|
|
|
type AgentToolWithMoreInfo = AgentTool & { icon: any; collection?: Collection } | null
|
|
|
|
const AgentTools: FC = () => {
|
|
|
|
const AgentTools: FC = () => {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const [isShowChooseTool, setIsShowChooseTool] = useState(false)
|
|
|
|
const [isShowChooseTool, setIsShowChooseTool] = useState(false)
|
|
|
|
const { modelConfig, setModelConfig, collectionList } = useContext(ConfigContext)
|
|
|
|
const { modelConfig, setModelConfig } = useContext(ConfigContext)
|
|
|
|
|
|
|
|
const { data: buildInTools } = useAllBuiltInTools()
|
|
|
|
|
|
|
|
const { data: customTools } = useAllCustomTools()
|
|
|
|
|
|
|
|
const { data: workflowTools } = useAllWorkflowTools()
|
|
|
|
|
|
|
|
const { data: mcpTools } = useAllMCPTools()
|
|
|
|
|
|
|
|
const collectionList = useMemo(() => {
|
|
|
|
|
|
|
|
const allTools = [
|
|
|
|
|
|
|
|
...(buildInTools || []),
|
|
|
|
|
|
|
|
...(customTools || []),
|
|
|
|
|
|
|
|
...(workflowTools || []),
|
|
|
|
|
|
|
|
...(mcpTools || []),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
return allTools
|
|
|
|
|
|
|
|
}, [buildInTools, customTools, workflowTools, mcpTools])
|
|
|
|
|
|
|
|
|
|
|
|
const formattingChangedDispatcher = useFormattingChangedDispatcher()
|
|
|
|
const formattingChangedDispatcher = useFormattingChangedDispatcher()
|
|
|
|
|
|
|
|
|
|
|
|
const [currentTool, setCurrentTool] = useState<AgentToolWithMoreInfo>(null)
|
|
|
|
const [currentTool, setCurrentTool] = useState<AgentToolWithMoreInfo>(null)
|
|
|
|
@ -132,7 +148,7 @@ const AgentTools: FC = () => {
|
|
|
|
disabled={false}
|
|
|
|
disabled={false}
|
|
|
|
supportAddCustomTool
|
|
|
|
supportAddCustomTool
|
|
|
|
onSelect={handleSelectTool}
|
|
|
|
onSelect={handleSelectTool}
|
|
|
|
selectedTools={tools}
|
|
|
|
selectedTools={tools as unknown as ToolValue[]}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
@ -150,7 +166,7 @@ const AgentTools: FC = () => {
|
|
|
|
<div className='flex w-0 grow items-center'>
|
|
|
|
<div className='flex w-0 grow items-center'>
|
|
|
|
{item.isDeleted && <DefaultToolIcon className='h-5 w-5' />}
|
|
|
|
{item.isDeleted && <DefaultToolIcon className='h-5 w-5' />}
|
|
|
|
{!item.isDeleted && (
|
|
|
|
{!item.isDeleted && (
|
|
|
|
<div className={cn((item.notAuthor || !item.enabled) && 'opacity-50')}>
|
|
|
|
<div className={cn((item.notAuthor || !item.enabled) && 'shrink-0 opacity-50')}>
|
|
|
|
{typeof item.icon === 'string' && <div className='h-5 w-5 rounded-md bg-cover bg-center' style={{ backgroundImage: `url(${item.icon})` }} />}
|
|
|
|
{typeof item.icon === 'string' && <div className='h-5 w-5 rounded-md bg-cover bg-center' style={{ backgroundImage: `url(${item.icon})` }} />}
|
|
|
|
{typeof item.icon !== 'string' && <AppIcon className='rounded-md' size='xs' icon={item.icon?.content} background={item.icon?.background} />}
|
|
|
|
{typeof item.icon !== 'string' && <AppIcon className='rounded-md' size='xs' icon={item.icon?.content} background={item.icon?.background} />}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@ -274,8 +290,7 @@ const AgentTools: FC = () => {
|
|
|
|
<SettingBuiltInTool
|
|
|
|
<SettingBuiltInTool
|
|
|
|
toolName={currentTool?.tool_name as string}
|
|
|
|
toolName={currentTool?.tool_name as string}
|
|
|
|
setting={currentTool?.tool_parameters}
|
|
|
|
setting={currentTool?.tool_parameters}
|
|
|
|
collection={currentTool?.collection as Collection}
|
|
|
|
collection={currentTool?.collection as ToolWithProvider}
|
|
|
|
isBuiltIn={currentTool?.collection?.type === CollectionType.builtIn}
|
|
|
|
|
|
|
|
isModel={currentTool?.collection?.type === CollectionType.model}
|
|
|
|
isModel={currentTool?.collection?.type === CollectionType.model}
|
|
|
|
onSave={handleToolSettingChange}
|
|
|
|
onSave={handleToolSettingChange}
|
|
|
|
onHide={() => setIsShowSettingTool(false)}
|
|
|
|
onHide={() => setIsShowSettingTool(false)}
|
|
|
|
|