perf: upgrade Graphiti LLM to Qwen 32B + improve progress feedback
- Upgrade from Qwen2.5-7B to Qwen2.5-32B-Instruct (faster, better quality) - Add real-time progress messages: "正在处理第 X/Y 个文本块" - Log per-episode processing time - Expand progress range from 15-55% to 15-90% (no more episode polling step) - Add GRAPHITI_LLM_* separate config for graph building LLM Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
parent
a35ba347f3
commit
d5a908077a
|
|
@ -424,7 +424,7 @@ def build_graph():
|
||||||
|
|
||||||
# 添加文本(progress_callback 签名是 (msg, progress_ratio))
|
# 添加文本(progress_callback 签名是 (msg, progress_ratio))
|
||||||
def add_progress_callback(msg, progress_ratio):
|
def add_progress_callback(msg, progress_ratio):
|
||||||
progress = 15 + int(progress_ratio * 40) # 15% - 55%
|
progress = 15 + int(progress_ratio * 75) # 15% - 90%
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
task_id,
|
task_id,
|
||||||
message=msg,
|
message=msg,
|
||||||
|
|
|
||||||
|
|
@ -267,14 +267,17 @@ class GraphitiClient:
|
||||||
edge_types: Optional[Dict] = None,
|
edge_types: Optional[Dict] = None,
|
||||||
progress_callback=None,
|
progress_callback=None,
|
||||||
):
|
):
|
||||||
"""Add multiple text episodes sequentially (Graphiti processes one at a time)."""
|
"""Add multiple text episodes sequentially with real-time progress."""
|
||||||
total = len(texts)
|
total = len(texts)
|
||||||
|
import time as _time
|
||||||
for i, text in enumerate(texts):
|
for i, text in enumerate(texts):
|
||||||
|
# Report progress BEFORE processing (so user sees "正在处理 2/5...")
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(
|
progress_callback(
|
||||||
f"Processing episode {i + 1}/{total}",
|
f"正在处理第 {i + 1}/{total} 个文本块(Graphiti 实体提取中...)",
|
||||||
(i + 1) / total,
|
i / total,
|
||||||
)
|
)
|
||||||
|
start = _time.time()
|
||||||
try:
|
try:
|
||||||
self.add_episode(
|
self.add_episode(
|
||||||
graph_id, text, source_description,
|
graph_id, text, source_description,
|
||||||
|
|
@ -283,9 +286,18 @@ class GraphitiClient:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to add episode {i + 1}/{total}: {e}")
|
logger.error(f"Failed to add episode {i + 1}/{total}: {e}")
|
||||||
raise
|
raise
|
||||||
|
elapsed = _time.time() - start
|
||||||
|
logger.info(f"Episode {i + 1}/{total} processed in {elapsed:.1f}s")
|
||||||
|
|
||||||
|
# Report completion of this episode
|
||||||
|
if progress_callback:
|
||||||
|
progress_callback(
|
||||||
|
f"第 {i + 1}/{total} 个文本块处理完成(用时 {elapsed:.0f}s)",
|
||||||
|
(i + 1) / total,
|
||||||
|
)
|
||||||
# Small delay to avoid rate limiting
|
# Small delay to avoid rate limiting
|
||||||
if i < total - 1:
|
if i < total - 1:
|
||||||
time.sleep(0.5)
|
_time.sleep(0.3)
|
||||||
|
|
||||||
# ========== Search ==========
|
# ========== Search ==========
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue