mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 19:06:51 +08:00
chore: perfect type definition (#940)
This commit is contained in:
@@ -8,7 +8,7 @@ import Button from '@/app/components/base/button'
|
||||
|
||||
type CardProps = {
|
||||
providerType: ProviderEnum
|
||||
models: any[]
|
||||
models: Model[]
|
||||
onOpenModal: (v: any) => void
|
||||
onOperate: (v: Record<string, any>) => void
|
||||
}
|
||||
@@ -33,7 +33,7 @@ const Card: FC<CardProps> = ({
|
||||
return (
|
||||
<div className='px-3 pb-3'>
|
||||
{
|
||||
models.map((model: Model) => (
|
||||
models.map(model => (
|
||||
<div key={`${model.model_name}-${model.model_type}`} className='flex mb-1 px-3 py-2 bg-white rounded-lg shadow-xs last:mb-0'>
|
||||
<div className='grow'>
|
||||
<div className='flex items-center mb-0.5 h-[18px] text-[13px] font-medium text-gray-700'>
|
||||
|
||||
@@ -15,6 +15,7 @@ import ModelIcon from '@/app/components/app/configuration/config-model/model-ico
|
||||
import ModelName, { supportI18nModelName } from '@/app/components/app/configuration/config-model/model-name'
|
||||
import ProviderName from '@/app/components/app/configuration/config-model/provider-name'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
|
||||
type Props = {
|
||||
value: {
|
||||
providerName: ProviderEnum
|
||||
@@ -28,6 +29,16 @@ type Props = {
|
||||
triggerIconSmall?: boolean
|
||||
}
|
||||
|
||||
type ModelOption = {
|
||||
type: 'model'
|
||||
value: string
|
||||
providerName: ProviderEnum
|
||||
modelDisplayName: string
|
||||
} | {
|
||||
type: 'provider'
|
||||
value: ProviderEnum
|
||||
}
|
||||
|
||||
const ModelSelector: FC<Props> = ({
|
||||
value,
|
||||
modelType,
|
||||
@@ -69,9 +80,9 @@ const ModelSelector: FC<Props> = ({
|
||||
|
||||
const hasRemoved = value && !modelList.find(({ model_name }) => model_name === value.modelName)
|
||||
|
||||
const modelOptions: any[] = (() => {
|
||||
const modelOptions: ModelOption[] = (() => {
|
||||
const providers = _.uniq(filteredModelList.map(item => item.model_provider.provider_name))
|
||||
const res: any[] = []
|
||||
const res: ModelOption[] = []
|
||||
providers.forEach((providerName) => {
|
||||
res.push({
|
||||
type: 'provider',
|
||||
@@ -162,7 +173,7 @@ const ModelSelector: FC<Props> = ({
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
modelOptions.map((model: any) => {
|
||||
modelOptions.map((model) => {
|
||||
if (model.type === 'provider') {
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -10,7 +10,7 @@ const PluginPage = () => {
|
||||
const { t } = useTranslation()
|
||||
const { data: plugins, mutate } = useSWR('/workspaces/current/tool-providers', fetchPluginProviders)
|
||||
|
||||
const Plugin_MAP: Record<string, any> = {
|
||||
const Plugin_MAP: Record<string, (plugin: PluginProvider) => JSX.Element> = {
|
||||
serpapi: (plugin: PluginProvider) => <SerpapiPlugin key='serpapi' plugin={plugin} onUpdate={() => mutate()} />,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user