|
|
|
@ -26,6 +26,7 @@ import cn from '@/utils/classnames'
|
|
|
|
import { useProviderContext } from '@/context/provider-context'
|
|
|
|
import { useProviderContext } from '@/context/provider-context'
|
|
|
|
import { RiEqualizer2Line } from '@remixicon/react'
|
|
|
|
import { RiEqualizer2Line } from '@remixicon/react'
|
|
|
|
import { fetchPluginInfoFromMarketPlace } from '@/service/plugins'
|
|
|
|
import { fetchPluginInfoFromMarketPlace } from '@/service/plugins'
|
|
|
|
|
|
|
|
import { fetchModelProviderModelList } from '@/service/common'
|
|
|
|
|
|
|
|
|
|
|
|
export type AgentModelTriggerProps = {
|
|
|
|
export type AgentModelTriggerProps = {
|
|
|
|
open?: boolean
|
|
|
|
open?: boolean
|
|
|
|
@ -67,6 +68,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
|
|
|
|
const [pluginInfo, setPluginInfo] = useState<PluginInfoFromMarketPlace | null>(null)
|
|
|
|
const [pluginInfo, setPluginInfo] = useState<PluginInfoFromMarketPlace | null>(null)
|
|
|
|
const [isPluginChecked, setIsPluginChecked] = useState(false)
|
|
|
|
const [isPluginChecked, setIsPluginChecked] = useState(false)
|
|
|
|
const [installed, setInstalled] = useState(false)
|
|
|
|
const [installed, setInstalled] = useState(false)
|
|
|
|
|
|
|
|
const [inModelList, setInModelList] = useState(false)
|
|
|
|
const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
|
|
|
|
const invalidateInstalledPluginList = useInvalidateInstalledPluginList()
|
|
|
|
const handleOpenModal = useModelModalHandler()
|
|
|
|
const handleOpenModal = useModelModalHandler()
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
@ -77,6 +79,9 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
|
|
|
|
const name = parts[1]
|
|
|
|
const name = parts[1]
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const pluginInfo = await fetchPluginInfoFromMarketPlace({ org, name })
|
|
|
|
const pluginInfo = await fetchPluginInfoFromMarketPlace({ org, name })
|
|
|
|
|
|
|
|
const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${providerName}/models`)
|
|
|
|
|
|
|
|
if (modelId && modelsData.data.find(item => item.model === modelId))
|
|
|
|
|
|
|
|
setInModelList(true)
|
|
|
|
if (pluginInfo.data.plugin.category === PluginType.model)
|
|
|
|
if (pluginInfo.data.plugin.category === PluginType.model)
|
|
|
|
setPluginInfo(pluginInfo.data.plugin)
|
|
|
|
setPluginInfo(pluginInfo.data.plugin)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -89,7 +94,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
|
|
|
|
setIsPluginChecked(true)
|
|
|
|
setIsPluginChecked(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})()
|
|
|
|
})()
|
|
|
|
}, [providerName, modelProvider])
|
|
|
|
}, [providerName, modelProvider, modelId])
|
|
|
|
|
|
|
|
|
|
|
|
if (modelId && !isPluginChecked)
|
|
|
|
if (modelId && !isPluginChecked)
|
|
|
|
return null
|
|
|
|
return null
|
|
|
|
@ -107,6 +112,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
|
|
|
|
provider={currentProvider || modelProvider}
|
|
|
|
provider={currentProvider || modelProvider}
|
|
|
|
modelName={currentModel?.model || modelId}
|
|
|
|
modelName={currentModel?.model || modelId}
|
|
|
|
isDeprecated={hasDeprecated}
|
|
|
|
isDeprecated={hasDeprecated}
|
|
|
|
|
|
|
|
isInModelList={inModelList}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<ModelDisplay
|
|
|
|
<ModelDisplay
|
|
|
|
currentModel={currentModel}
|
|
|
|
currentModel={currentModel}
|
|
|
|
@ -121,6 +127,7 @@ const AgentModelTrigger: FC<AgentModelTriggerProps> = ({
|
|
|
|
<StatusIndicators
|
|
|
|
<StatusIndicators
|
|
|
|
needsConfiguration={needsConfiguration}
|
|
|
|
needsConfiguration={needsConfiguration}
|
|
|
|
modelProvider={!!modelProvider}
|
|
|
|
modelProvider={!!modelProvider}
|
|
|
|
|
|
|
|
inModelList={inModelList}
|
|
|
|
disabled={!!disabled}
|
|
|
|
disabled={!!disabled}
|
|
|
|
pluginInfo={pluginInfo}
|
|
|
|
pluginInfo={pluginInfo}
|
|
|
|
t={t}
|
|
|
|
t={t}
|
|
|
|
|