修改打包方式
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 1m2s
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 1m2s
This commit is contained in:
68
sanity_check.py
Normal file
68
sanity_check.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
Stage 2 集成验证脚本——一次性 sanity check。
|
||||
|
||||
跑前准备:
|
||||
1. 启动匠厂客户端(确认能正常打开聊天页 + 至少配好一个可用模型)
|
||||
2. 在本仓库激活 Python venv,确认 playwright 已装
|
||||
3. 直接 python sanity_check.py 即可
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
print("=" * 60)
|
||||
print("Stage 2 SDK Sanity Check")
|
||||
print("=" * 60)
|
||||
|
||||
try:
|
||||
from jiangchang_desktop_sdk import JiangchangDesktopClient
|
||||
print("[1/6] import OK")
|
||||
except Exception as e:
|
||||
print(f"[FAIL] import failed: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
with JiangchangDesktopClient() as c:
|
||||
print("[2/6] context entered")
|
||||
|
||||
c.ensure_app_running()
|
||||
print("[3/6] ensure_app_running OK")
|
||||
|
||||
c.wait_gateway_ready()
|
||||
print("[4/6] wait_gateway_ready OK (note: returns even if gw not actually ready)")
|
||||
|
||||
c.new_task()
|
||||
print("[5/6] new_task OK")
|
||||
|
||||
t0 = time.time()
|
||||
answer = c.ask("你好,请用一句话回复,确认 SDK 可用")
|
||||
elapsed = time.time() - t0
|
||||
print(f"[6/6] ask() returned in {elapsed:.1f}s")
|
||||
print(f" answer length: {len(answer)} chars")
|
||||
print(f" answer preview: {answer[:200]!r}")
|
||||
assert answer.strip(), "Empty answer!"
|
||||
|
||||
print()
|
||||
print("[BONUS] verifying read() works")
|
||||
msgs = c.read()
|
||||
print(f" read() returned {len(msgs)} messages")
|
||||
for i, m in enumerate(msgs[-4:]):
|
||||
print(f" [-{len(msgs)-i}] role={m.role!r} id={m.id!r} "
|
||||
f"content_len={len(m.content) if m.content else 0}")
|
||||
|
||||
print()
|
||||
print("[BONUS] verifying send_file raises NotImplementedError")
|
||||
try:
|
||||
c.send_file("/tmp/fake.txt")
|
||||
print(" [FAIL] send_file did NOT raise!")
|
||||
except NotImplementedError as e:
|
||||
print(f" [OK] send_file raised: {str(e)[:80]}...")
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("ALL CHECKS PASSED ✓")
|
||||
print("=" * 60)
|
||||
except Exception as e:
|
||||
print(f"\n[FAIL] sanity check crashed:")
|
||||
traceback.print_exc()
|
||||
sys.exit(2)
|
||||
Reference in New Issue
Block a user