Skip to content

Commit 9a167e8

Browse files
Merge pull request #314 from steven-jianhao-li/dev
Dev
2 parents caf0358 + 59197f3 commit 9a167e8

28 files changed

Lines changed: 802 additions & 66 deletions

addon/prefs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pref("__prefsPrefix__.maxTokens", "8192");
5151
pref("__prefsPrefix__.enableMaxTokens", true);
5252
pref("__prefsPrefix__.topP", "1.0");
5353
pref("__prefsPrefix__.enableTopP", true);
54+
pref("__prefsPrefix__.reasoningEffort", "default");
5455
pref("__prefsPrefix__.stream", true);
5556
pref("__prefsPrefix__.requestTimeout", "300000"); // 5分钟超时
5657
// MINERU API KEY

docs/api-configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ Google AI Studio 免费层级对不同模型有不同的速率限制。查看可
7777
2. 平台选择 **OpenAI**
7878
3. 粘贴 API 密钥
7979
4. 模型名称填写(从 [官方模型列表](https://platform.openai.com/docs/models) 获取,模型名在Snapshots下,例如:`gpt-5.2``gpt-5-mini`
80-
5. 点击 **"测试连接"**
80+
5. 如使用支持推理的 GPT / o 系列模型,可在该模型平台详情中调整 **思维链长度**;OpenAI 官方端点默认使用 **斟酌**
81+
6. 点击 **"测试连接"**
8182

8283
![OpenAI 模型名获取](images/api-config-openai-models.png)
8384

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "zotero-ai-butler",
33
"type": "module",
4-
"version": "3.6.0-beta.6",
4+
"version": "3.6.0-beta.8",
55
"description": "Your personal AI butler, automatically and meticulously reads papers and summarizes notes.",
66
"config": {
77
"addonName": "zotero-ai-butler",

src/hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ function initializeDefaultPrefsOnStartup() {
245245
maxApiSwitchCount: "3", // 最大切换次数
246246
failedKeyCooldown: "300000", // 失败密钥冷却时间(毫秒),默认5分钟
247247
temperature: "0.7", // 默认温度参数,平衡创造性和准确性
248+
reasoningEffort: "default",
248249
stream: true, // 默认启用流式输出,提供更好的用户体验
249250
summaryPrompt: getDefaultSummaryPrompt(), // 加载默认提示词模板
250251
promptVersion: PROMPT_VERSION, // 当前提示词版本号

src/modules/aiNoteClassifier.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
export type NoteTag = { tag: string };
2+
3+
const SUMMARY_NOTE_TAG = "AI-Generated";
4+
const TABLE_NOTE_TAG = "AI-Table";
5+
const CHAT_NOTE_TAG = "AI-Butler-Chat";
6+
const MINDMAP_NOTE_TAG = "AI-Mindmap";
7+
const IMAGE_NOTE_TAGS = ["AI-Image-Summary", "AI-ImageSummary"];
8+
9+
const AI_BUTLER_SUMMARY_HEADING_RE = /<h2>\s*AI\s*\s*-\s*(?!)/;
10+
const AI_BUTLER_CHAT_HEADING_RE =
11+
/<h2>\s*AI\s*\s*-\s*(?:\s*-|\s*|[\s<])/;
12+
const AI_BUTLER_MINDMAP_HEADING_RE = /AI\s*\s*-/;
13+
const AI_BUTLER_IMAGE_HEADING_RE = /AI\s*\s*-/;
14+
15+
export function hasNoteTag(tags: NoteTag[], tag: string): boolean {
16+
return tags.some((t) => t.tag === tag);
17+
}
18+
19+
export function isFollowUpChatNote(tags: NoteTag[], noteHtml: string): boolean {
20+
const hasSummaryTag = hasNoteTag(tags, SUMMARY_NOTE_TAG);
21+
return (
22+
hasNoteTag(tags, CHAT_NOTE_TAG) ||
23+
(!hasSummaryTag && AI_BUTLER_CHAT_HEADING_RE.test(noteHtml))
24+
);
25+
}
26+
27+
export function isRegularSummaryNote(
28+
tags: NoteTag[],
29+
noteHtml: string,
30+
): boolean {
31+
const isTableNote = hasNoteTag(tags, TABLE_NOTE_TAG);
32+
const isMindmapNote =
33+
hasNoteTag(tags, MINDMAP_NOTE_TAG) ||
34+
AI_BUTLER_MINDMAP_HEADING_RE.test(noteHtml);
35+
const isImageNote =
36+
IMAGE_NOTE_TAGS.some((tag) => hasNoteTag(tags, tag)) ||
37+
AI_BUTLER_IMAGE_HEADING_RE.test(noteHtml);
38+
39+
if (
40+
isTableNote ||
41+
isMindmapNote ||
42+
isImageNote ||
43+
isFollowUpChatNote(tags, noteHtml)
44+
) {
45+
return false;
46+
}
47+
48+
return (
49+
hasNoteTag(tags, SUMMARY_NOTE_TAG) ||
50+
AI_BUTLER_SUMMARY_HEADING_RE.test(noteHtml)
51+
);
52+
}

src/modules/autoScanManager.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
import { getPref } from "../utils/prefs";
20+
import { isRegularSummaryNote } from "./aiNoteClassifier";
2021
import { TaskQueueManager } from "./taskQueue";
2122

2223
/**
@@ -288,14 +289,9 @@ export class AutoScanManager {
288289
const n = await Zotero.Items.getAsync(nid);
289290
if (!n) continue;
290291

291-
// 检查标签
292292
const tags: Array<{ tag: string }> = (n as any).getTags?.() || [];
293-
const hasTag = tags.some((t) => t.tag === "AI-Generated");
294-
if (hasTag) return true;
295-
296-
// 检查标题标记
297293
const noteHtml: string = (n as any).getNote?.() || "";
298-
if (/<h2>\s*AI \s*-/.test(noteHtml)) {
294+
if (isRegularSummaryNote(tags, noteHtml)) {
299295
return true;
300296
}
301297
}

0 commit comments

Comments
 (0)