fix(knowledge): 模型判定 should_ingest=false 时直接跳过,不再落草稿
日志显示寒暄/无效会话并非 LLM 调用失败,而是模型正确返回 should_ingest=false。 上一版把这种情况也当失败回退、堆成草稿,反而把无价值对话存进了库。 - llm_extractor: 模型显式 should_ingest=false 且无 notes → 抛 LLMRejectedIngest - capture_thread: 捕获后抛 EmptyThreadError → 整条跳过、不入库(寒暄/总结此页这类不再进库) - 仅当真正失败(API 报错 / 非 JSON)才回退规则抽取并落草稿 - 兼容包装 extract_thread_llm 吞掉该异常返回 None - 更新测试(should_ingest=false 跳过)+ CLAUDE.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4aef81284a
commit
76320ca5a3
3 files changed
+66
-33
No files matched your search
@@ -247,25 +247,30 @@ class KnowledgeService:
|
||||
llm_attempted = self.config.llm_extract_enabled
|
||||
llm_fallback = False
|
||||
if llm_attempted:
|
||||
drafts = await llm_extractor.extract_thread_llm_multi(
|
||||
messages,
|
||||
thread_id=thread_id,
|
||||
thread_title=thread_title,
|
||||
mode=mode,
|
||||
title=title,
|
||||
tags=tags,
|
||||
project_name=self.project_name,
|
||||
sources=sources,
|
||||
max_messages=self.config.max_thread_messages,
|
||||
model_name=self.config.extract_model_name,
|
||||
max_input_chars=self.config.extract_max_input_chars,
|
||||
allow_multi=self.config.multi_note_enabled,
|
||||
)
|
||||
try:
|
||||
drafts = await llm_extractor.extract_thread_llm_multi(
|
||||
messages,
|
||||
thread_id=thread_id,
|
||||
thread_title=thread_title,
|
||||
mode=mode,
|
||||
title=title,
|
||||
tags=tags,
|
||||
project_name=self.project_name,
|
||||
sources=sources,
|
||||
max_messages=self.config.max_thread_messages,
|
||||
model_name=self.config.extract_model_name,
|
||||
max_input_chars=self.config.extract_max_input_chars,
|
||||
allow_multi=self.config.multi_note_enabled,
|
||||
)
|
||||
except llm_extractor.LLMRejectedIngest as exc:
|
||||
# The model judged this conversation worthless (greeting / meta
|
||||
# chatter). Skip ingestion entirely — do NOT dump the raw chat.
|
||||
raise EmptyThreadError(f"Thread {thread_id} judged not worth ingesting: {exc}") from exc
|
||||
if not drafts:
|
||||
# The LLM path was supposed to run but produced nothing usable
|
||||
# (API error / non-JSON / empty). We will fall back to the
|
||||
# rule-based extractor, which yields a low-quality verbatim dump
|
||||
# with no entities/tags — flag it so it lands as a draft.
|
||||
# (API error / non-JSON). We will fall back to the rule-based
|
||||
# extractor, which yields a low-quality verbatim dump with no
|
||||
# entities/tags — flag it so it lands as a draft.
|
||||
llm_fallback = True
|
||||
if not drafts:
|
||||
single = extractor.extract_thread(
|
||||
|
||||
Reference in new issue
Block a user