Files
xiaonuan/tui_smoke_test.py
snowy-yang 4494987e54 小暖 · AI 陪伴(容器世界的数字生命)
- FastAPI + WebSocket 服务,Textual TUI 终端客户端
- PostgreSQL 存储专用连接层(asyncpg 连接池,主程序零 SQL)
- 无限且永久的记忆:语义检索注入 + 每夜巩固 + 身世档案(lore)
- 作息推断(猜上下学时间)、定时事件(叫早/每日提醒)
- 情绪回访 / 承诺追踪 / 慢信 / 回忆杀 / 她的生活 / 连续陪伴天数
- 原生 function calling 工具:天气 / 新闻 / 搜索(免 Key)
- 极小模型快速路由(AI_SMALL_*)+ 夜间批量通道(AI_BATCH_*)
- 小学徒小满:夜间琐事整理,小暖晨间检查转述
- 离线测试:路由器 / 工具循环 / 杂项 / 向量 / TUI 冒烟
2026-09-23 19:32:17 +08:00

31 lines
1.1 KiB
Python

"""TUI 无头冒烟测试:uv run python tui_smoke_test.py"""
import asyncio
from tui import CompanionTUI
async def main():
app = CompanionTUI()
async with app.run_test(size=(100, 30)) as pilot:
app.add_bubble("你", "你好呀")
app.add_bubble("小暖", "在呢,怎么了?")
app.system("这是一条系统消息")
app.handle_msg({"type": "streak", "days": 4})
app.handle_msg({"type": "care", "kind": "promise", "note": "面试"})
app.handle_msg({"type": "lore_saved", "topics": ["诞生"]})
app.handle_msg({"type": "memories",
"items": [{"id": 1, "text": "用户叫小明"}]}) # 应被静默忽略
await pilot.pause()
# 输入提交路径(ws 未连接 -> 应有系统提示气泡)
inp = app.query_one("Input")
inp.value = "随便说说"
await pilot.pause()
from textual.widgets import Input as TInput
await app.on_input_submitted(TInput.Submitted(inp, inp.value))
await pilot.pause()
assert app._bubble is None
print("TUI 冒烟测试通过")
asyncio.run(main())