fix: adding multiple keys to the zhipu model service is not detected properly (#10583)

This commit is contained in:
Tristan Zhang 2025-10-09 20:40:46 +08:00 committed by GitHub
parent 62774b34d3
commit 2399db4944
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 11 deletions

View File

@ -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

View File

@ -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,