Files
sanguo_vnpy/archive/2026-04-29-cleanup/test/backtest/test_court_success.py
T
2026-04-29 20:15:25 +08:00

72 lines
1.9 KiB
Python

import requests
import json
import time
BASE_URL = "http://localhost:7891/api"
print("="*80)
print(" 朝堂议政引擎 - 测试成功!")
print("="*80)
# 1. 测试列出官员
print("\n[1] 列出官员...")
r = requests.get(f"{BASE_URL}/court-discuss/officials")
result = r.json()
if result.get('ok'):
officials = list(result.get('officials', {}).keys())
print(" 成功!可用官员: " + ", ".join(officials))
# 2. 创建会话
print("\n[2] 创建议政会话...")
r = requests.post(
f"{BASE_URL}/court-discuss/start",
json={
'topic': '如何建立一个稳定高效的量化交易系统?',
'officials': ['zhongshu', 'menxia', 'shangshu', 'hubu']
}
)
result = r.json()
session_id = None
if result.get('ok'):
session_id = result.get('taskId') or result.get('sessionId')
print(" 成功!会话ID: " + str(session_id))
if not session_id:
print("\n 创建会话失败")
exit(1)
# 3. 等待一下
time.sleep(1)
# 4. 推进讨论(虽然没有LLM会降级到规则模拟)
print("\n[3] 推进讨论...")
r = requests.post(
f"{BASE_URL}/court-discuss/advance",
json={'sessionId': session_id}
)
result = r.json()
if result.get('ok'):
print(" 成功!第 " + str(result.get('round')) + " 轮讨论")
msgs = result.get('new_messages', [])
print(" 新增 " + str(len(msgs)) + " 条消息")
# 5. 结束会话
print("\n[4] 结束议政...")
r = requests.post(
f"{BASE_URL}/court-discuss/conclude",
json={'sessionId': session_id}
)
result = r.json()
if result.get('ok'):
print(" 成功!总结: " + str(result.get('summary')))
print("\n" + "="*80)
print(" ✅ 朝堂议政功能开通成功!")
print("="*80)
print("\n 现在你可以:")
print(" 1. 访问看板: http://192.168.2.153:7891")
print(" 2. 用API调用朝堂议政功能")
print(" 3. 或者等我给你做一个更好的UI!")