Kaynağa Gözat

fix: agent tools setting (#14097)

tags/1.0.0
zxhlyh 8 ay önce
ebeveyn
işleme
09fc4bba61
No account linked to committer's email address

+ 3
- 3
web/app/components/app/configuration/config/agent/agent-tools/index.tsx Dosyayı Görüntüle

import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback' import { AlertTriangle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import { DefaultToolIcon } from '@/app/components/base/icons/src/public/other' import { DefaultToolIcon } from '@/app/components/base/icons/src/public/other'
// import AddToolModal from '@/app/components/tools/add-tool-modal'
import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials' import ConfigCredential from '@/app/components/tools/setting/build-in/config-credentials'
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 } from '@/app/components/workflow/block-selector/types'
import { canFindTool } from '@/utils'


type AgentToolWithMoreInfo = AgentTool & { icon: any; collection?: Collection } | null type AgentToolWithMoreInfo = AgentTool & { icon: any; collection?: Collection } | null
const AgentTools: FC = () => { const AgentTools: FC = () => {
const [currentTool, setCurrentTool] = useState<AgentToolWithMoreInfo>(null) const [currentTool, setCurrentTool] = useState<AgentToolWithMoreInfo>(null)
const currentCollection = useMemo(() => { const currentCollection = useMemo(() => {
if (!currentTool) return null if (!currentTool) return null
const collection = collectionList.find(collection => collection.id.split('/').pop() === currentTool?.provider_id.split('/').pop() && collection.type === currentTool?.provider_type)
const collection = collectionList.find(collection => canFindTool(collection.id, currentTool?.provider_id) && collection.type === currentTool?.provider_type)
return collection return collection
}, [currentTool, collectionList]) }, [currentTool, collectionList])
const [isShowSettingTool, setIsShowSettingTool] = useState(false) const [isShowSettingTool, setIsShowSettingTool] = useState(false)
const tools = (modelConfig?.agentConfig?.tools as AgentTool[] || []).map((item) => { const tools = (modelConfig?.agentConfig?.tools as AgentTool[] || []).map((item) => {
const collection = collectionList.find( const collection = collectionList.find(
collection => collection =>
collection.id.split('/').pop() === item.provider_id.split('/').pop()
canFindTool(collection.id, item.provider_id)
&& collection.type === item.provider_type, && collection.type === item.provider_type,
) )
const icon = collection?.icon const icon = collection?.icon

Loading…
İptal
Kaydet