dsh-zhihu-search 1.2.5 → 1.2.7
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/README.md +1 -1
- package/README_en.md +1 -1
- package/lib/present/search.js +4 -2
- package/lib/tools/global-search.js +7 -5
- package/lib/tools/search.js +6 -4
- package/lib/types.d.ts +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/README_en.md
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
29
|
> [!NOTE]
|
|
30
|
-
> **Built on the official Zhihu Open Platform API**, not web scraping. All search results include citable original links, and Zhihu's own results also carry their upvote counts, ensuring every model response is verifiable.
|
|
30
|
+
> **Built on the official Zhihu Open Platform API**, not web scraping. All search results include citable original links, and Zhihu's own results also carry their upvote counts, ensuring every model response is verifiable. Search results are text summaries only and do not include article images.
|
|
31
31
|
|
|
32
32
|
Equips DSH with three Zhihu tools: in-site search, global web search, and Zhida direct answers — returning a list of citable sources instead of an unverifiable summary.
|
|
33
33
|
|
package/lib/present/search.js
CHANGED
|
@@ -42,8 +42,10 @@ export function renderSearch(value) {
|
|
|
42
42
|
for (const item of value.items) {
|
|
43
43
|
lines.push(`### [${escapeLinkText(item.title)}](${item.url})`);
|
|
44
44
|
const meta = [`**作者**: ${item.author || '匿名'}`];
|
|
45
|
-
//
|
|
46
|
-
|
|
45
|
+
// 点赞段只对知乎内容渲染。
|
|
46
|
+
// 全网搜索会混进第三方网页:外站没有「知乎点赞」这回事,上游对它恒报 0,
|
|
47
|
+
// 渲染出来就是把「不适用」说成「没人赞」——所以连同缺失一起整段省略。
|
|
48
|
+
if (item.contentType !== '' && item.voteUpCount !== undefined)
|
|
47
49
|
meta.push(`**点赞**: ${String(item.voteUpCount)}`);
|
|
48
50
|
// 类型缺失时整段省略,而不是渲染成空的「类型: 」。
|
|
49
51
|
if (item.contentType !== '')
|
|
@@ -39,11 +39,12 @@ function projectItem(item) {
|
|
|
39
39
|
url,
|
|
40
40
|
snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
|
|
41
41
|
author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
|
|
42
|
-
// 上游没报点赞数时整个键省略,不兜底成 0
|
|
43
|
-
//
|
|
42
|
+
// 上游没报点赞数时整个键省略,不兜底成 0 —— 写 0 等于告诉模型「没人赞」。
|
|
43
|
+
// 注意实测结论:上游**从未省略**该字段,外站网页也有这个键、值是占位的 0。
|
|
44
|
+
// 省略分支是防伪造的兜底;外站那个 0 由渲染层决定不展示(present/search.ts)。
|
|
44
45
|
...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
|
|
45
|
-
// ContentType
|
|
46
|
-
//
|
|
46
|
+
// ContentType 缺失时留空,不编造标签:实测第三方网页(如接单平台)的类型是**空串**
|
|
47
|
+
// (字段在、值为空),兜底成 'Article' 会让模型把广告页当成知乎文章。
|
|
47
48
|
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
48
49
|
};
|
|
49
50
|
}
|
|
@@ -58,7 +59,8 @@ export function createZhihuGlobalSearchTool(deps) {
|
|
|
58
59
|
name: ZHIHU_GLOBAL_SEARCH_TOOL,
|
|
59
60
|
description: '知乎全网索引搜索:检索知乎索引收录的公开网页,结果里会混入部分知乎站内内容。' +
|
|
60
61
|
'适合按站点域名或发布时间找资料;要专搜知乎的问答和文章、且要更贴题的排序,用 zhihu_search。' +
|
|
61
|
-
`单次最多 ${String(MAX_COUNT)}
|
|
62
|
+
`单次最多 ${String(MAX_COUNT)} 条且没有翻页参数;域名过滤不接受知乎域名。` +
|
|
63
|
+
'只返回文字摘要与原始链接,结果不含图片。',
|
|
62
64
|
parameters: {
|
|
63
65
|
query: { type: 'string', required: true, description: '搜索关键词。' },
|
|
64
66
|
count: { type: 'integer', description: `返回条数,1–${String(MAX_COUNT)},默认 ${String(DEFAULT_COUNT)}。`, default: DEFAULT_COUNT },
|
package/lib/tools/search.js
CHANGED
|
@@ -41,10 +41,11 @@ function projectItem(item) {
|
|
|
41
41
|
url,
|
|
42
42
|
snippet: sanitizeSnippet(typeof item.ContentText === 'string' ? item.ContentText : ''),
|
|
43
43
|
author: sanitizeSnippet(typeof item.AuthorName === 'string' ? item.AuthorName : '', 60),
|
|
44
|
-
// 上游没报点赞数时整个键省略,不兜底成 0
|
|
45
|
-
//
|
|
44
|
+
// 上游没报点赞数时整个键省略,不兜底成 0 —— 写 0 等于告诉模型「没人赞」。
|
|
45
|
+
// 注意实测结论:上游**从未省略**该字段,外站网页也有这个键、值是占位的 0。
|
|
46
|
+
// 省略分支是防伪造的兜底;外站那个 0 由渲染层决定不展示(present/search.ts)。
|
|
46
47
|
...(typeof item.VoteUpCount === 'number' && Number.isFinite(item.VoteUpCount) ? { voteUpCount: item.VoteUpCount } : {}),
|
|
47
|
-
// ContentType
|
|
48
|
+
// ContentType 缺失时留空,不编造标签:实测外站网页的类型是**空串**(字段在、值为空),
|
|
48
49
|
// 兜底成 'Answer' 会让模型把一个陌生网页当成知乎回答。
|
|
49
50
|
contentType: typeof item.ContentType === 'string' ? item.ContentType : '',
|
|
50
51
|
};
|
|
@@ -60,7 +61,8 @@ export function createZhihuSearchTool(deps) {
|
|
|
60
61
|
name: ZHIHU_SEARCH_TOOL,
|
|
61
62
|
description: '知乎站内搜索:检索知乎的问答与文章,可筛出高赞、多评论或近期更新的内容,也支持限定发布时间。' +
|
|
62
63
|
'适合中文经验、产品评测、行业讨论、技术实践。' +
|
|
63
|
-
'要搜知乎站外某个网站上的资料改用 zhihu_global_search;要一段成体系的解释而不是来源列表改用 zhihu_zhida。'
|
|
64
|
+
'要搜知乎站外某个网站上的资料改用 zhihu_global_search;要一段成体系的解释而不是来源列表改用 zhihu_zhida。' +
|
|
65
|
+
'只返回文字摘要与原始链接,结果不含图片。',
|
|
64
66
|
// 语义化参数:模型永远不会看到 SortBy / Filter 的字符串语法。
|
|
65
67
|
parameters: {
|
|
66
68
|
query: { type: 'string', required: true, description: '搜索关键词,中文效果最好。' },
|
package/lib/types.d.ts
CHANGED
|
@@ -115,8 +115,10 @@ export interface SearchOutput {
|
|
|
115
115
|
snippet: string;
|
|
116
116
|
author: string;
|
|
117
117
|
/**
|
|
118
|
-
* 点赞数。上游没报该字段时**整个键省略**,不兜底成 0
|
|
119
|
-
*
|
|
118
|
+
* 点赞数。上游没报该字段时**整个键省略**,不兜底成 0。
|
|
119
|
+
*
|
|
120
|
+
* 实测(30 条样本)上游**从未省略**该字段:外站网页也有这个键,值是占位的 `0`,
|
|
121
|
+
* 它不代表「没人赞」。省略分支是防伪造的兜底,外站那个 0 不在渲染层展示。
|
|
120
122
|
*/
|
|
121
123
|
voteUpCount?: number;
|
|
122
124
|
contentType: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-zhihu-search",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "DSH plugin: Zhihu in-site search, global web search, and Zhida over the official Zhihu Open Platform API — with a native settings card and source-cited results.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|