model list in plugin detail

This commit is contained in:
JzoNg 2024-11-02 13:59:02 +08:00
parent 04fdb4af0f
commit a387cfbc9a

View File

@ -1,28 +1,43 @@
import React from 'react' import React from 'react'
import useSWR from 'swr'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
// import ModelIcon from '@/app/components/header/account-setting/model-provider-page/model-icon' import { usePluginPageContext } from '@/app/components/plugins/plugin-page/context'
// import ModelName from '@/app/components/header/account-setting/model-provider-page/model-name' import ModelIcon from '@/app/components/header/account-setting/model-provider-page/model-icon'
import ModelName from '@/app/components/header/account-setting/model-provider-page/model-name'
import { fetchModelProviderModelList } from '@/service/common'
const ModelList = () => { const ModelList = () => {
const { t } = useTranslation() const { t } = useTranslation()
const currentPluginDetail = usePluginPageContext(v => v.currentPluginDetail)
const { data: res } = useSWR(
`/workspaces/current/model-providers/${currentPluginDetail.plugin_id}/${currentPluginDetail.name}/models`,
fetchModelProviderModelList,
)
if (!res)
return null
return ( return (
<div className='px-4 py-2'> <div className='px-4 py-2'>
<div className='mb-1 h-6 flex items-center text-text-secondary system-sm-semibold-uppercase'>{t('plugin.detailPanel.modelNum', { num: 3 })}</div> <div className='mb-1 h-6 flex items-center text-text-secondary system-sm-semibold-uppercase'>{t('plugin.detailPanel.modelNum', { num: res.data.length })}</div>
<div className='h-8 flex items-center'> <div className='h-8 flex items-center'>
{/* <ModelIcon {res.data.map(model => (
<div key={model.model} className='h-6 py-1 flex items-center'>
<ModelIcon
className='shrink-0 mr-2' className='shrink-0 mr-2'
provider={provider} provider={currentPluginDetail.declaration.model}
modelName={model.model} modelName={model.model}
/> />
<ModelName <ModelName
className='grow text-sm font-normal text-gray-900' className='grow text-text-secondary system-md-regular'
modelItem={model} modelItem={model}
showModelType showModelType
showMode showMode
showContextSize showContextSize
> />
</ModelName> */} </div>
))}
</div> </div>
</div> </div>
) )