2024-10-12 16:29:46 +08:00
|
|
|
import React from 'react'
|
2024-11-02 13:59:02 +08:00
|
|
|
import useSWR from 'swr'
|
2024-10-12 16:29:46 +08:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2024-11-02 13:59:02 +08:00
|
|
|
import { usePluginPageContext } from '@/app/components/plugins/plugin-page/context'
|
|
|
|
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'
|
2024-10-12 16:29:46 +08:00
|
|
|
|
|
|
|
const ModelList = () => {
|
|
|
|
const { t } = useTranslation()
|
2024-11-02 13:59:02 +08:00
|
|
|
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
|
2024-10-12 16:29:46 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='px-4 py-2'>
|
2024-11-02 13:59:02 +08:00
|
|
|
<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>
|
2024-10-12 16:29:46 +08:00
|
|
|
<div className='h-8 flex items-center'>
|
2024-11-02 13:59:02 +08:00
|
|
|
{res.data.map(model => (
|
|
|
|
<div key={model.model} className='h-6 py-1 flex items-center'>
|
|
|
|
<ModelIcon
|
|
|
|
className='shrink-0 mr-2'
|
|
|
|
provider={currentPluginDetail.declaration.model}
|
|
|
|
modelName={model.model}
|
|
|
|
/>
|
|
|
|
<ModelName
|
|
|
|
className='grow text-text-secondary system-md-regular'
|
|
|
|
modelItem={model}
|
|
|
|
showModelType
|
|
|
|
showMode
|
|
|
|
showContextSize
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
))}
|
2024-10-12 16:29:46 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ModelList
|