fix: add provider check in isMandatoryWebSearchModel (#9398)

* fix: add provider check in isMandatoryWebSearchModel

* Fix: Add provider check in isMandatoryWebSearchModel

The isMandatoryWebSearchModel function was throwing an error when the provider was undefined. This change adds a check to ensure the provider exists before accessing its properties, similar to how it's handled in isWebSearchModel.

The position of the check has also been moved to be between the provider and modelId initializations for better code flow.

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
one
2025-08-22 09:09:21 +08:00
committed by GitHub
parent 44b2d09e63
commit cd1b0e01a0

View File

@@ -3014,6 +3014,11 @@ export function isMandatoryWebSearchModel(model: Model): boolean {
}
const provider = getProviderByModel(model)
if (!provider) {
return false
}
const modelId = getLowerBaseModelName(model.id)
if (provider.id === 'perplexity' || provider.id === 'openrouter') {