mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-04 20:00:00 +08:00
fix: adding multiple keys to the zhipu model service is not detected properly (#10583)
This commit is contained in:
parent
62774b34d3
commit
2399db4944
@ -10,6 +10,7 @@ interface ShowParams {
|
||||
providerId: string
|
||||
title?: string
|
||||
showHealthCheck?: boolean
|
||||
providerType?: 'llm' | 'webSearch' | 'preprocess'
|
||||
}
|
||||
|
||||
interface Props extends ShowParams {
|
||||
@ -19,7 +20,7 @@ interface Props extends ShowParams {
|
||||
/**
|
||||
* API Key 列表弹窗容器组件
|
||||
*/
|
||||
const PopupContainer: React.FC<Props> = ({ providerId, title, resolve, showHealthCheck = true }) => {
|
||||
const PopupContainer: React.FC<Props> = ({ providerId, title, resolve, showHealthCheck = true, providerType }) => {
|
||||
const [open, setOpen] = useState(true)
|
||||
const { t } = useTranslation()
|
||||
|
||||
@ -32,14 +33,20 @@ const PopupContainer: React.FC<Props> = ({ providerId, title, resolve, showHealt
|
||||
}
|
||||
|
||||
const ListComponent = useMemo(() => {
|
||||
if (isWebSearchProviderId(providerId)) {
|
||||
return <WebSearchApiKeyList providerId={providerId} showHealthCheck={showHealthCheck} />
|
||||
const type =
|
||||
providerType ||
|
||||
(isWebSearchProviderId(providerId) ? 'webSearch' : isPreprocessProviderId(providerId) ? 'preprocess' : 'llm')
|
||||
|
||||
switch (type) {
|
||||
case 'webSearch':
|
||||
return <WebSearchApiKeyList providerId={providerId as any} showHealthCheck={showHealthCheck} />
|
||||
case 'preprocess':
|
||||
return <DocPreprocessApiKeyList providerId={providerId as any} showHealthCheck={showHealthCheck} />
|
||||
case 'llm':
|
||||
default:
|
||||
return <LlmApiKeyList providerId={providerId} showHealthCheck={showHealthCheck} />
|
||||
}
|
||||
if (isPreprocessProviderId(providerId)) {
|
||||
return <DocPreprocessApiKeyList providerId={providerId} showHealthCheck={showHealthCheck} />
|
||||
}
|
||||
return <LlmApiKeyList providerId={providerId} showHealthCheck={showHealthCheck} />
|
||||
}, [providerId, showHealthCheck])
|
||||
}, [providerId, showHealthCheck, providerType])
|
||||
|
||||
return (
|
||||
<Modal
|
||||
|
||||
@ -172,15 +172,22 @@ const ProviderSetting: FC<Props> = ({ providerId }) => {
|
||||
const onUpdateApiVersion = () => updateProvider({ apiVersion })
|
||||
|
||||
const openApiKeyList = async () => {
|
||||
if (localApiKey !== provider.apiKey) {
|
||||
updateProvider({ apiKey: formatApiKeys(localApiKey) })
|
||||
await new Promise((resolve) => setTimeout(resolve, 0))
|
||||
}
|
||||
|
||||
await ApiKeyListPopup.show({
|
||||
providerId: provider.id,
|
||||
title: `${fancyProviderName} ${t('settings.provider.api.key.list.title')}`
|
||||
title: `${fancyProviderName} ${t('settings.provider.api.key.list.title')}`,
|
||||
providerType: 'llm'
|
||||
})
|
||||
}
|
||||
|
||||
const onCheckApi = async () => {
|
||||
const formattedLocalKey = formatApiKeys(localApiKey)
|
||||
// 如果存在多个密钥,直接打开管理窗口
|
||||
if (provider.apiKey.includes(',')) {
|
||||
if (formattedLocalKey.includes(',')) {
|
||||
await openApiKeyList()
|
||||
return
|
||||
}
|
||||
@ -204,7 +211,7 @@ const ProviderSetting: FC<Props> = ({ providerId }) => {
|
||||
|
||||
try {
|
||||
setApiKeyConnectivity((prev) => ({ ...prev, checking: true, status: HealthStatus.NOT_CHECKED }))
|
||||
await checkApi({ ...provider, apiHost }, model)
|
||||
await checkApi({ ...provider, apiHost, apiKey: formattedLocalKey }, model)
|
||||
|
||||
window.toast.success({
|
||||
timeout: 2000,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user