From 1427004d4b540a831fed4f0ef31d672e89a022f5 Mon Sep 17 00:00:00 2001 From: kim Date: Sat, 17 Oct 2026 23:23:06 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=AC=EB=9D=BC=EB=A7=88=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=EC=9D=80=20=ED=99=9C=EC=84=B1=20LLM=EC=9D=B4=20?= =?UTF-8?q?=EC=98=AC=EB=9D=BC=EB=A7=88=EC=9D=BC=20=EB=95=8C=EB=A7=8C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9(search.ollama=5Fonly=5Fwith=5Follama=5Fllm,?= =?UTF-8?q?=20=EA=B8=B0=EB=B3=B8=20=EC=BC=9C=EC=A7=90)=20=E2=80=94=20?= =?UTF-8?q?=EC=95=84=EB=8B=88=EB=A9=B4=20SearXNG+=ED=8F=B4=EB=B0=B1=20?= =?UTF-8?q?=EC=B2=B4=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- src/tools/web.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/tools/web.ts b/src/tools/web.ts index 6f1a688..b1b8e50 100644 --- a/src/tools/web.ts +++ b/src/tools/web.ts @@ -526,7 +526,30 @@ function rankResults(query: string, results: SearchResultItem[]) { type SearchConfig = { parallelSearxng?: boolean; preferred: 'tavily' | 'google' | 'brave' | 'ddg' | 'searxng' | 'ollama_cloud'; tavilyKey?: string; googleKey?: string; googleCx?: string; braveKey?: string; searxngUrl?: string; ollamaApiKey?: string }; let _searchConfigCache: { value: SearchConfig; expiresAt: number } | null = null; +/** + * 올라마 검색(ollama_cloud)은 활성 LLM이 올라마일 때만 쓴다(search.ollama_only_with_ollama_llm, 기본 켜짐). + * 2026-10-17: 기본 모델을 Anthropic으로 옮긴 뒤에도 검색이 올라마 구독에 매여 있으면 구독을 정리할 수 없다. + * Claude 자체 검색이 1순위이므로 올라마가 아닐 때의 대체 경로는 SearXNG(+Tavily·Brave·구글·DDG 폴백)다. + * 캐시된 설정 위에서 호출 때마다 판정하므로 설정 화면에서 provider를 바꾸면 5분 캐시를 기다리지 않고 바로 반영된다. + */ function getSearchConfig(): SearchConfig { + const base = getSearchConfigBase(); + try { + const data: any = getConfig().getConfig(); + const gated = data?.search?.ollama_only_with_ollama_llm !== false; + const llmProvider = String(data?.llm?.provider || 'ollama'); + if (gated && !['ollama', 'ollama_local'].includes(llmProvider)) { + return { + ...base, + ollamaApiKey: undefined, // 아래 체인이 "키 없음"으로 건너뛴다 + preferred: base.preferred === 'ollama_cloud' ? (base.searxngUrl ? 'searxng' : 'ddg') : base.preferred, + }; + } + } catch { /* 설정을 못 읽으면 원래 설정 */ } + return base; +} + +function getSearchConfigBase(): SearchConfig { const now = Date.now(); if (_searchConfigCache && now < _searchConfigCache.expiresAt) return _searchConfigCache.value; let value: SearchConfig = { preferred: 'ddg' };