mirror of
https://github.com/snowy-yang/xiaonuan.git
synced 2026-10-21 08:04:48 +00:00
- FastAPI + WebSocket 服务,Textual TUI 终端客户端 - PostgreSQL 存储专用连接层(asyncpg 连接池,主程序零 SQL) - 无限且永久的记忆:语义检索注入 + 每夜巩固 + 身世档案(lore) - 作息推断(猜上下学时间)、定时事件(叫早/每日提醒) - 情绪回访 / 承诺追踪 / 慢信 / 回忆杀 / 她的生活 / 连续陪伴天数 - 原生 function calling 工具:天气 / 新闻 / 搜索(免 Key) - 极小模型快速路由(AI_SMALL_*)+ 夜间批量通道(AI_BATCH_*) - 小学徒小满:夜间琐事整理,小暖晨间检查转述 - 离线测试:路由器 / 工具循环 / 杂项 / 向量 / TUI 冒烟
18 lines
720 B
Python
18 lines
720 B
Python
"""向量逻辑离线测试:uv run python vec_test.py"""
|
|
from app.connector import hash_embed
|
|
from app.db import cosine
|
|
|
|
base = hash_embed("我喜欢打篮球")
|
|
near = hash_embed("打篮球的时候我很开心")
|
|
far = hash_embed("明天北京的天气怎么样")
|
|
|
|
print("self:", round(cosine(base, base), 3))
|
|
print("near:", round(cosine(base, near), 3))
|
|
print("far: ", round(cosine(base, far), 3))
|
|
|
|
assert abs(cosine(base, base) - 1.0) < 1e-9, "自身相似度应为 1"
|
|
assert cosine(base, near) > cosine(base, far), "相近文本应比无关文本相似"
|
|
assert cosine(base, []) == 0.0 and cosine([], base) == 0.0, "空向量应返回 0"
|
|
assert len(base) == 256, "维度应为 256"
|
|
print("向量逻辑测试通过")
|