fix(llm): save intermediate thinking — DeepSeek reasoning_content fallback, force non-empty thought, increase API truncation to 50K
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user