Merge ebdbeeb549247ae9252acbd379ef0510b354c92a into d1e684c419b4f88fee62490b0c2b4fcf65469e59

This commit is contained in:
bxclib2 2026-07-12 07:13:13 +08:00 committed by GitHub
commit 7a00a4abcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,11 @@ const WEB_SEARCH_MODES = new Set<WebSearchMode>([
const unsupportedNativeModels = new Set<string>()
// Third-party Anthropic-compatible providers whose model IDs don't contain
// "claude" but do support the web_search_20250305 server tool (e.g. DeepSeek,
// Kimi, Zhipu GLM). Add model patterns here to enable native web search.
const thirdPartyNativeSearchModelPatterns = [/^deepseek-/]
export function isLikelyClaudeModel(model: string | undefined): boolean {
if (!model) {
return false
@ -177,7 +182,10 @@ export function makeWebSearchUnavailableOutput(
function canUseAnthropicNativeWebSearch(model: string | undefined): boolean {
const key = normalizeModelKey(model)
return isLikelyClaudeModel(model) && (!key || !unsupportedNativeModels.has(key))
if (!key || unsupportedNativeModels.has(key)) {
return false
}
return isLikelyClaudeModel(model) || thirdPartyNativeSearchModelPatterns.some(p => p.test(key))
}
function normalizeModelKey(model: string | undefined): string | null {