|
@@ -19,8 +19,9 @@ from pathlib import Path
|
|
|
# 与 examples/how/run.py 一致:禁止 httpx/urllib 自动检测系统 HTTP 代理
|
|
# 与 examples/how/run.py 一致:禁止 httpx/urllib 自动检测系统 HTTP 代理
|
|
|
# os.environ.setdefault("no_proxy", "*")
|
|
# os.environ.setdefault("no_proxy", "*")
|
|
|
|
|
|
|
|
-# 添加项目根目录到 Python 路径
|
|
|
|
|
-sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
|
|
|
|
|
|
+# 项目根目录(兼容从项目根或脚本目录启动)
|
|
|
|
|
+PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent
|
|
|
|
|
+sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
|
|
|
|
from dotenv import load_dotenv
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
|
@@ -322,7 +323,7 @@ async def main(account_name, post_id):
|
|
|
model_id = model_key
|
|
model_id = model_key
|
|
|
print(f" - 模型: {model_id}")
|
|
print(f" - 模型: {model_id}")
|
|
|
|
|
|
|
|
- store = FileSystemTraceStore(base_path=".trace")
|
|
|
|
|
|
|
+ store = FileSystemTraceStore(base_path=str(PROJECT_ROOT / ".trace"))
|
|
|
runner = AgentRunner(
|
|
runner = AgentRunner(
|
|
|
trace_store=store,
|
|
trace_store=store,
|
|
|
llm_call=create_openrouter_llm_call(model=model_id),
|
|
llm_call=create_openrouter_llm_call(model=model_id),
|
|
@@ -520,9 +521,11 @@ async def main(account_name, post_id):
|
|
|
print(final_response)
|
|
print(final_response)
|
|
|
print("=" * 60)
|
|
print("=" * 60)
|
|
|
print()
|
|
print()
|
|
|
- output_dir = Path("output")
|
|
|
|
|
- output_dir.mkdir(exist_ok=True)
|
|
|
|
|
|
|
+ # 以脚本所在目录为基准,兼容从项目根或脚本目录启动
|
|
|
|
|
+ script_dir = Path(__file__).resolve().parent
|
|
|
|
|
+ output_dir = script_dir / "output"
|
|
|
output_file = output_dir / account_name / "推导日志" / current_trace_id / log_id / "result.txt"
|
|
output_file = output_dir / account_name / "推导日志" / current_trace_id / log_id / "result.txt"
|
|
|
|
|
+ output_file.parent.mkdir(parents=True, exist_ok=True)
|
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|
|
f.write(final_response)
|
|
f.write(final_response)
|
|
|
print(f"✓ 结果已保存到: {output_file}")
|
|
print(f"✓ 结果已保存到: {output_file}")
|
|
@@ -546,4 +549,4 @@ async def main(account_name, post_id):
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
# anthropic/claude-sonnet-4.6
|
|
# anthropic/claude-sonnet-4.6
|
|
|
# google/gemini-3-flash-preview
|
|
# google/gemini-3-flash-preview
|
|
|
- asyncio.run(main(account_name="家有大志", post_id="68fb6a5c000000000302e5de"))
|
|
|
|
|
|
|
+ asyncio.run(main(account_name="家有大志", post_id="6921937a000000001b0278d1"))
|