|
@@ -39,12 +39,12 @@ from agent.trace import (
|
|
|
Trace,
|
|
Trace,
|
|
|
Message,
|
|
Message,
|
|
|
)
|
|
)
|
|
|
-from examples.create.html import trace_to_html
|
|
|
|
|
from agent.llm import create_openrouter_llm_call
|
|
from agent.llm import create_openrouter_llm_call
|
|
|
from agent.tools import get_tool_registry
|
|
from agent.tools import get_tool_registry
|
|
|
|
|
|
|
|
-# DEFAULT_MODEL = "anthropic/claude-sonnet-4.5"
|
|
|
|
|
-DEFAULT_MODEL = "google/gemini-3-flash-preview"
|
|
|
|
|
|
|
+DEFAULT_MODEL = "anthropic/claude-sonnet-4.5"
|
|
|
|
|
+# DEFAULT_MODEL = "google/gemini-3-flash-preview"
|
|
|
|
|
+
|
|
|
|
|
|
|
|
# ===== 非阻塞 stdin 检测 =====
|
|
# ===== 非阻塞 stdin 检测 =====
|
|
|
if sys.platform == 'win32':
|
|
if sys.platform == 'win32':
|
|
@@ -354,7 +354,7 @@ async def main():
|
|
|
store = FileSystemTraceStore(base_path=".trace")
|
|
store = FileSystemTraceStore(base_path=".trace")
|
|
|
runner = AgentRunner(
|
|
runner = AgentRunner(
|
|
|
trace_store=store,
|
|
trace_store=store,
|
|
|
- llm_call=create_openrouter_llm_call(model=DEFAULT_MODEL),
|
|
|
|
|
|
|
+ llm_call=create_openrouter_llm_call(model=prompt.config.get('model', DEFAULT_MODEL)),
|
|
|
skills_dir=skills_dir,
|
|
skills_dir=skills_dir,
|
|
|
experiences_path="./.cache/experiences.md",
|
|
experiences_path="./.cache/experiences.md",
|
|
|
debug=True
|
|
debug=True
|
|
@@ -581,16 +581,6 @@ async def main():
|
|
|
if current_trace_id:
|
|
if current_trace_id:
|
|
|
await runner.stop(current_trace_id)
|
|
await runner.stop(current_trace_id)
|
|
|
|
|
|
|
|
- finally:
|
|
|
|
|
- # 进程退出时自动生成 messages HTML 到 .trace/<id>/ 目录
|
|
|
|
|
- if current_trace_id:
|
|
|
|
|
- try:
|
|
|
|
|
- html_path = store.base_path / current_trace_id / "messages.html"
|
|
|
|
|
- await trace_to_html(current_trace_id, html_path, base_path=str(store.base_path))
|
|
|
|
|
- print(f"\n✓ Messages 可视化已保存: {html_path}")
|
|
|
|
|
- except Exception as e:
|
|
|
|
|
- print(f"\n⚠ 生成 HTML 失败: {e}")
|
|
|
|
|
-
|
|
|
|
|
# 6. 输出结果
|
|
# 6. 输出结果
|
|
|
if final_response:
|
|
if final_response:
|
|
|
print()
|
|
print()
|
|
@@ -611,14 +601,13 @@ async def main():
|
|
|
|
|
|
|
|
# 可视化提示
|
|
# 可视化提示
|
|
|
if current_trace_id:
|
|
if current_trace_id:
|
|
|
- html_path = store.base_path / current_trace_id / "messages.html"
|
|
|
|
|
print("=" * 60)
|
|
print("=" * 60)
|
|
|
- print("可视化:")
|
|
|
|
|
|
|
+ print("可视化 Step Tree:")
|
|
|
print("=" * 60)
|
|
print("=" * 60)
|
|
|
- print(f"1. 本地 HTML: {html_path}")
|
|
|
|
|
- print()
|
|
|
|
|
- print("2. API Server:")
|
|
|
|
|
|
|
+ print("1. 启动 API Server:")
|
|
|
print(" python3 api_server.py")
|
|
print(" python3 api_server.py")
|
|
|
|
|
+ print()
|
|
|
|
|
+ print("2. 浏览器访问:")
|
|
|
print(" http://localhost:8000/api/traces")
|
|
print(" http://localhost:8000/api/traces")
|
|
|
print()
|
|
print()
|
|
|
print(f"3. Trace ID: {current_trace_id}")
|
|
print(f"3. Trace ID: {current_trace_id}")
|