dsh-free-search 0.4.34 → 0.4.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +1 -1
- package/lib/index.js +30 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -222,7 +222,7 @@ window.__ModuleLoader__.load({
|
|
|
222
222
|
};
|
|
223
223
|
const tt = (lang) => I18N[lang === "en" ? "en" : "zh"];
|
|
224
224
|
// 当前插件版本(与 lib/index.js 的 PLUGIN_VERSION 保持一致)
|
|
225
|
-
const PLUGIN_VERSION = "0.4.
|
|
225
|
+
const PLUGIN_VERSION = "0.4.35";
|
|
226
226
|
const ENGINES = [
|
|
227
227
|
{ id: "ddg", label: "DuckDuckGo · HTML", badge: "FREE", link: "https://duckduckgo.com" },
|
|
228
228
|
{ id: "ddg-lite", label: "DuckDuckGo · Lite", badge: "FREE", link: "https://duckduckgo.com" },
|
package/lib/index.js
CHANGED
|
@@ -52,7 +52,7 @@ const FREE_ENGINES = ["ddg", "ddg-lite", "bing", "searxng", "anysearch"];
|
|
|
52
52
|
const ALL_ENGINES = ["ddg", "ddg-lite", "bing", "searxng", "anysearch", "exa", "tavily", "keenable", "firecrawl", "parallel", "perplexity", "serpbase", "deepseek-official"];
|
|
53
53
|
|
|
54
54
|
// 当前插件版本(发布时与 package.json 同步)
|
|
55
|
-
const PLUGIN_VERSION = "0.4.
|
|
55
|
+
const PLUGIN_VERSION = "0.4.35";
|
|
56
56
|
// 检查更新的 npm registry 元数据地址(dsh-free-search 是 npmjs 上的公开包)
|
|
57
57
|
const NPM_REGISTRY_URL = "https://registry.npmjs.org/dsh-free-search/latest";
|
|
58
58
|
const PLUGIN_NPM_URL = "https://www.npmjs.com/package/dsh-free-search";
|
|
@@ -347,6 +347,31 @@ async function searchDdgLite(query, maxResults, options, signal) {
|
|
|
347
347
|
return { sources: uniqueSources(sources, maxResults ?? 10), truncated: false };
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
// Bing 在「查询无结果」时会返回一张完全无关的缓存 SERP(<li class="b_algo"> 照常存在,
|
|
351
|
+
// 但内容是别的查询/热门页的内容),直接返回等于把垃圾结果喂给模型(issue #38:YouTube、
|
|
352
|
+
// 法语微软文档、瑞士基金等都复现过)。这里用「查询 token 与结果文本是否重叠」识别这种页面。
|
|
353
|
+
// token 规则:CJK 取 1-2 字组合(二元组),拉丁/数字取长度 >=2 的词。
|
|
354
|
+
function queryOverlapTokens(query) {
|
|
355
|
+
const tokens = new Set();
|
|
356
|
+
for (const run of String(query).match(/[\u4e00-\u9fff]+/g) ?? []) {
|
|
357
|
+
if (run.length <= 2) tokens.add(run);
|
|
358
|
+
for (let i = 0; i + 1 < run.length; i++) tokens.add(run.slice(i, i + 2));
|
|
359
|
+
}
|
|
360
|
+
for (const word of String(query).toLowerCase().split(/[^a-z0-9]+/)) {
|
|
361
|
+
if (word.length >= 2) tokens.add(word);
|
|
362
|
+
}
|
|
363
|
+
return [...tokens];
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function looksRelevant(query, sources) {
|
|
367
|
+
const tokens = queryOverlapTokens(query);
|
|
368
|
+
if (tokens.length === 0) return true; // 纯符号查询无法判定,不拦截
|
|
369
|
+
return sources.some((s) => {
|
|
370
|
+
const hay = `${s.title ?? ""} ${s.snippet ?? ""} ${s.url ?? ""}`.toLowerCase();
|
|
371
|
+
return tokens.some((t) => hay.includes(t.toLowerCase()));
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
350
375
|
async function searchBing(query, maxResults, options, signal) {
|
|
351
376
|
// mkt:显式 bingMarket 优先;否则按 lang 映射(zh→zh-CN, ru→ru-RU ...)
|
|
352
377
|
const profile = LANG_PROFILES[options?.lang] ?? LANG_PROFILES.zh;
|
|
@@ -374,6 +399,10 @@ async function searchBing(query, maxResults, options, signal) {
|
|
|
374
399
|
...(snippetMatch ? { snippet: stripTags(snippetMatch[1]) } : {}),
|
|
375
400
|
});
|
|
376
401
|
}
|
|
402
|
+
// Bing 无结果时会返回无关的缓存页:判为 0 结果,交给统一回退链换下一个引擎
|
|
403
|
+
if (sources.length > 0 && !looksRelevant(query, sources)) {
|
|
404
|
+
return { sources: [], truncated: false };
|
|
405
|
+
}
|
|
377
406
|
return { sources: uniqueSources(sources, maxResults ?? 10), truncated: false };
|
|
378
407
|
}
|
|
379
408
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-free-search",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.35",
|
|
4
4
|
"description": "Free web search for DeepSeek Harness: 13 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel keyless; Perplexity/SerpBase/DeepSeek with key) + time filtering + platform search + web_fetch, with web settings UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|