perf: ai proxy (#4265)

* sync collection

* remove lock

* perf: ai proxy
This commit is contained in:
Archer
2025-03-21 14:03:54 +08:00
committed by archer
parent 9918133426
commit 2c73e9dc12
2 changed files with 20 additions and 10 deletions

View File

@@ -1,4 +1,10 @@
import { deleteChannel, getChannelList, putChannel, putChannelStatus } from '@/web/core/ai/channel';
import {
deleteChannel,
getChannelList,
getChannelProviders,
putChannel,
putChannelStatus
} from '@/web/core/ai/channel';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import React, { useState } from 'react';
import {
@@ -50,6 +56,10 @@ const ChannelTable = ({ Tab }: { Tab: React.ReactNode }) => {
manual: false
});
const { data: channelProviders = {} } = useRequest2(getChannelProviders, {
manual: false
});
const [editChannel, setEditChannel] = useState<ChannelInfoType>();
const { runAsync: updateChannel, loading: loadingUpdateChannel } = useRequest2(putChannel, {
@@ -111,7 +121,10 @@ const ChannelTable = ({ Tab }: { Tab: React.ReactNode }) => {
</Thead>
<Tbody>
{channelList.map((item) => {
const providerData = aiproxyIdMap[item.type];
const providerData = aiproxyIdMap[item.type] || {
label: channelProviders[item.type]?.name || 'Invalid provider',
provider: 'Other'
};
const provider = getModelProvider(providerData?.provider);
return (
@@ -119,14 +132,10 @@ const ChannelTable = ({ Tab }: { Tab: React.ReactNode }) => {
<Td>{item.id}</Td>
<Td>{item.name}</Td>
<Td>
{providerData ? (
<HStack>
<MyIcon name={provider?.avatar as any} w={'1rem'} />
<Box>{t(providerData?.label as any)}</Box>
</HStack>
) : (
'Invalid provider'
)}
<HStack>
<MyIcon name={provider?.avatar as any} w={'1rem'} />
<Box>{t(providerData?.label as any)}</Box>
</HStack>
</Td>
<Td>
<MyTag