新增LLM节点 - #27
Conversation
…validation feat: add Azure OpenAI validation
…ning-service feat: add volcano inference option
…_token-value feat: optimize volcengine check
…workflow Remove LLM validation and add local checks
WalkthroughRefactors the plugin to a local-first word validation and LLM-assisted extraction flow, adds Volcano LLM integration with timeouts/fallbacks, introduces batch writes for Eudic, updates manifest metadata and options (including new LLM settings), and refreshes README to document batch additions, local filtering, and API changes. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant P as Plugin (translate)
participant L as Local Filter
participant V as Volcano LLM
participant D as Dictionary API(s)
U->>P: Submit text
P->>L: Normalize & classify
alt invalid
P-->>U: Error (not a valid word input)
else valid
P->>V: Extract candidate words (timeout)
alt LLM returns words
P->>P: Dedup/trim
alt dict_type = Eudic
P->>D: Batch add words
else other dicts
loop words
P->>D: Add word (serial)
end
end
D-->>P: Add status
P-->>U: Summary message
else LLM timeout/fail
P-->>U: Structured error (with diagnostics)
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (10)
README.md (2)
5-5: Unify the dictionary brand wording: “欧路” vs “欧陆”.The project consistently uses “欧路词典” elsewhere. This line uses “欧陆词典”. Please standardize to “欧路词典” to avoid confusion.
-欧陆词典API改为批量提交,规避QPS限制。 +欧路词典 API 改为批量提交,规避 QPS 限制。
5-5: Document new LLM configuration options in the Settings section.README describes the LLM/batch flow but doesn’t explain how to configure Volcano (API Key, Endpoint, Model, System Prompt, Timeout). Add a brief subsection under “设置” to map to the new options added in src/info.json so users can actually enable the feature.
I can draft the “设置” subsection that mirrors the new options (volcano_api_key/endpoint/model/llm_system_prompt/word_check_timeout_ms) and include a minimal example.
src/info.json (2)
6-7: Manifest summary claims “LLM 超时>5s默认通过”,but main.js currently does not default-pass on LLM failure.Either update the behavior in translate()/extractWordsByLLMVolcano() to implement default-pass on timeout, or revise this summary to match current behavior (which returns a structured error/debug message).
Would you like me to adjust translate() to (a) fall back to localExtractWords() when statusCode=0/timeout, or (b) default-pass the raw input in single-word mode only?
67-72: Expose “max words to add” as an option to match code intent.main.js reads llm_words_max_add but the manifest doesn’t define it; it always falls back to 200. Add this option so users can control batch size.
{ "identifier": "word_check_timeout_ms", "type": "text", "title": "LLM 超时(毫秒)", "textConfig": { "type": "visible", "placeholderText": "5000" } - }, + }, + { + "identifier": "llm_words_max_add", + "type": "text", + "title": "LLM 抽取最大单词数", + "textConfig": { "type": "visible", "placeholderText": "200" } + },src/main.js (6)
110-115: withTimeout() is a no-op; either implement or remove.Given we rely on $http.timeout and cancelSignal, this no-op can be removed to avoid misleading future readers. If you want a true business-level timeout, I can provide a safe wrapper that doesn’t rely on setTimeout.
529-549: ok predicate uses cleaned.length >= 0 (always true).If the intent is “HTTP success regardless of words length,” this is fine. Otherwise, consider > 0 and handle empty set as non-fatal success upstream, as you already do. No change required if by design.
- ok: sc >= 200 && sc < 300 && cleaned.length >= 0, + ok: sc >= 200 && sc < 300 && cleaned.length >= 0, // by design: ok even when 0 words
572-587: Eudic single-add result handling is OK, but message could be more actionable.On non-201, consider surfacing server message to help users fix configuration.
- if (res && res.response && res.response.statusCode === 201) { + if (res && res.response && res.response.statusCode === 201) { cb({ result: buildResult("添加单词成功:" + word) }); } else { - cb({ error: buildError("欧路词典 token 或配置有误,请检查。") }); + var serverMsg = (res && res.data && res.data.message) ? String(res.data.message) : "请检查欧路 token / 单词本 id"; + cb({ error: buildError("欧路写入失败:" + serverMsg) }); }
772-792: LLM failure path returns debug error; manifest/README suggest default-pass or graceful fallback.Current behavior propagates a detailed error. If you want “超时>5s默认通过并写入单词本,” consider falling back to localExtractWords() when winfo.statusCode === 0 or errorMessage includes “timeout”, then proceed with the same add flow.
I can provide a guarded fallback here that triggers only on timeouts to avoid masking real 4xx/5xx errors.
341-352: Unused helper: shouldAddToWordbook().Dead code increases maintenance cost. Remove or integrate into classifyInput/translate.
353-373: Unused helper: parseYesNo().No call sites remain after refactor to extraction flow. Safe to remove.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
README.md(2 hunks)src/info.json(1 hunks)src/main.js(1 hunks)
🔇 Additional comments (3)
README.md (1)
15-15: Good addition — explicitly calls out local filtering.This aligns with the code’s local regex/tokenization gate before invoking LLM.
src/main.js (2)
223-241: Local strict word filter looks solid.Good coverage: excludes emails/URLs/whitespace/CJK/digits/underscores; allows internal hyphen/apostrophe and rejects consecutive --/''.
641-659: Batch Eudic path looks correct and matches official API.Good: POST /studylist/words with category_id, language, words; 201 expected; timeout and cancelSignal wired.
从只能添加单个单词,升级到了可以批量添加单词,利用LLM进行分词和过滤简单词,按照单词重要性进行排序添加。欧陆词典API改为批量提交,规避QPS限制。价值上将排除网址、邮件、非英语单词等情况,同时适配句子翻译场景。
Summary by CodeRabbit