docs: v1.5.7 动态API提供商管理,OpenCode Go集成,Bug修复
This commit is contained in:
+28
-5
@@ -467,7 +467,7 @@ def generate_plan():
|
||||
)
|
||||
|
||||
# 真正调用API生成报告
|
||||
_, ai_report, error, _ = generate_ai_report(
|
||||
_, ai_report, error, extra = generate_ai_report(
|
||||
student_name=student.name,
|
||||
wechat_nickname=student.wechat_nickname or "",
|
||||
problems=problem_data,
|
||||
@@ -479,24 +479,46 @@ def generate_plan():
|
||||
)
|
||||
|
||||
if error:
|
||||
# 拼接详细的错误信息用于显示
|
||||
display_error = f"AI生成失败: {error}"
|
||||
if extra:
|
||||
debug_info = []
|
||||
if extra.get("prompt_tokens"):
|
||||
debug_info.append(f"输入token={extra['prompt_tokens']}")
|
||||
if extra.get("completion_tokens"):
|
||||
debug_info.append(f"输出token={extra['completion_tokens']}")
|
||||
if extra.get("finish_reason"):
|
||||
debug_info.append(f"finish={extra['finish_reason']}")
|
||||
if extra.get("raw_keys"):
|
||||
debug_info.append(f"keys={extra['raw_keys']}")
|
||||
if debug_info:
|
||||
display_error += " [" + ", ".join(debug_info) + "]"
|
||||
yield sse_format(
|
||||
{
|
||||
"step": "ai_error",
|
||||
"message": f"AI生成失败: {error}",
|
||||
"message": display_error,
|
||||
"progress": 80,
|
||||
"error": error,
|
||||
"error": display_error,
|
||||
}
|
||||
)
|
||||
plan_content["ai_report_error"] = error
|
||||
plan_content["ai_report_error"] = display_error
|
||||
else:
|
||||
# 显示AI返回的报告长度
|
||||
report_lines = len(ai_report.split("\n")) if ai_report else 0
|
||||
detail_parts = [f"报告长度: {len(ai_report) if ai_report else 0} 字符, {report_lines} 行"]
|
||||
if extra:
|
||||
if extra.get("prompt_tokens"):
|
||||
detail_parts.append(f"输入token: {extra['prompt_tokens']}")
|
||||
if extra.get("completion_tokens"):
|
||||
detail_parts.append(f"输出token: {extra['completion_tokens']}")
|
||||
if extra.get("finish_reason"):
|
||||
detail_parts.append(f"finish_reason: {extra['finish_reason']}")
|
||||
yield sse_format(
|
||||
{
|
||||
"step": "ai_response",
|
||||
"message": f"AI报告已生成",
|
||||
"progress": 75,
|
||||
"detail": f"报告长度: {len(ai_report) if ai_report else 0} 字符, {report_lines} 行",
|
||||
"detail": " | ".join(detail_parts),
|
||||
}
|
||||
)
|
||||
yield sse_format(
|
||||
@@ -558,6 +580,7 @@ def generate_plan():
|
||||
"ai_report": ai_report,
|
||||
"prompt_length": prompt_length,
|
||||
"ai_report_length": len(ai_report) if ai_report else 0,
|
||||
"ai_error": plan_content.get("ai_report_error", ""),
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user