Update jargon_miner.py

pull/1359/head
SengokuCola 2025-11-16 00:19:18 +08:00
parent 22dca15f0a
commit db1699566d
1 changed files with 15 additions and 1 deletions

View File

@ -64,11 +64,14 @@ def _init_inference_prompts() -> None:
请根据以上词条内容和上下文推断这个词条的含义 请根据以上词条内容和上下文推断这个词条的含义
- 如果这是一个黑话俚语或网络用语请推断其含义 - 如果这是一个黑话俚语或网络用语请推断其含义
- 如果含义明确常规词汇也请说明 - 如果含义明确常规词汇也请说明
- 如果上下文信息不足无法推断含义请设置 no_info true
JSON 格式输出 JSON 格式输出
{{ {{
"meaning": "详细含义说明(包含使用场景、来源、具体解释等)" "meaning": "详细含义说明(包含使用场景、来源、具体解释等)",
"no_info": false
}} }}
注意如果信息不足无法推断请设置 "no_info": true此时 meaning 可以为空字符串
""" """
Prompt(prompt1_str, "jargon_inference_with_context_prompt") Prompt(prompt1_str, "jargon_inference_with_context_prompt")
@ -323,6 +326,17 @@ class JargonMiner:
except Exception as e: except Exception as e:
logger.error(f"jargon {content} 推断1解析失败: {e}") logger.error(f"jargon {content} 推断1解析失败: {e}")
return return
# 检查推断1是否表示信息不足无法推断
no_info = inference1.get("no_info", False)
meaning1 = inference1.get("meaning", "").strip()
if no_info or not meaning1:
logger.info(f"jargon {content} 推断1表示信息不足无法推断放弃本次推断待下次更新")
# 更新最后一次判定的count值避免在同一阈值重复尝试
jargon_obj.last_inference_count = jargon_obj.count or 0
jargon_obj.save()
return
# 步骤2: 仅基于content推断 # 步骤2: 仅基于content推断
prompt2 = await global_prompt_manager.format_prompt( prompt2 = await global_prompt_manager.format_prompt(