fix(llm): save intermediate thinking — DeepSeek reasoning_content fallback, force non-empty thought, increase API truncation to 50K

This commit is contained in:
PM-pinou
2026-07-24 11:26:34 +08:00
parent 982cdcf83e
commit d7f9db098c
3 changed files with 8 additions and 3 deletions
+4 -2
View File
@@ -191,8 +191,10 @@ def run_llm_analysis_view(request):
save_fields = ['progress_pct', 'progress_msg']
if tool_name == 'thinking':
# Accumulate LLM thinking text (appended to llm_thinking)
if result:
run.llm_thinking = (run.llm_thinking or '') + f'\n[{step}] {result}'
thought = (result or '').strip()
if not thought:
thought = f'步骤 {step} 分析中...'
run.llm_thinking = (run.llm_thinking or '') + f'\n[{step}] {thought}'
save_fields = ['progress_pct', 'progress_msg', 'llm_thinking']
elif tool_name == 'complete':
pass # No extra tracking needed
+1 -1
View File
@@ -53,7 +53,7 @@ def run_status_api(request, display_id):
'progress_pct': run.progress_pct,
'progress_msg': run.progress_msg,
'run_log': run.run_log[-2000:], # last 2000 chars
'llm_thinking': run.llm_thinking[-5000:], # last 5K chars
'llm_thinking': run.llm_thinking[-50000:] if run.llm_thinking else '',
'tool_calls': run.tool_calls_json,
})
+3
View File
@@ -328,6 +328,9 @@ def run_llm_pipeline(dataset_id: str, entity_col: str = "",
msg = resp["choices"][0]["message"]
content = msg.get("content", "")
# DeepSeek reasoning fallback (reasoning_content for chain-of-thought)
if not content:
content = msg.get("reasoning_content", "") or ""
# Pass thinking text to callback
if callback: