올라마 검색은 활성 LLM이 올라마일 때만 사용(search.ollama_only_with_ollama_llm, 기본 켜짐) — 아니면 SearXNG+폴백 체인
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a4f20e7c32
commit
1427004d4b
1 file changed
+23
@@ -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' };
|
||||
|
||||
Reference in new issue
Block a user