fix: Change unsupported provider error to return undefined (#10257)

Change unsupported provider error to return undefined

Replace thrown error with empty object return and update function
signature to allow undefined return type for unsupported providers
This commit is contained in:
SuYao 2025-09-19 18:48:40 +08:00 committed by GitHub
parent a8cd2e2eac
commit 5d8e706c0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,7 +44,7 @@ function mapMaxResultToOpenAIContextSize(maxResults: number): OpenAISearchConfig
export function buildProviderBuiltinWebSearchConfig(
providerId: BaseProviderId,
webSearchConfig: CherryWebSearchConfig
): WebSearchPluginConfig {
): WebSearchPluginConfig | undefined {
switch (providerId) {
case 'openai': {
return {
@ -99,7 +99,7 @@ export function buildProviderBuiltinWebSearchConfig(
}
}
default: {
throw new Error(`Unsupported provider: ${providerId}`)
return {}
}
}
}