Dialog

Multi-user dialog management, archiving, and AI message routing via dialoghelper.

每个用户对应一个独立的 solveit dialog(路径 /wecom/users/{user_id}/chat),实现多用户隔离。历史会话可归档保留,/new 指令触发归档并开启新会话。

AI 摘要生成

归档前向 AI 请求一个不超过10字的主题摘要,用于归档文件命名,方便日后检索。失败时回退为 untitled

会话归档

archive_dialog 生成摘要、停止 dialog 内核,并将 .ipynb 文件移至 archive/ 子目录,文件名格式为 YYYYMMDD_HHMM_摘要.ipynb


source

archive_dialog


async def archive_dialog(
    user_id:str, # WeCom user ID whose active dialog should be archived
)->bool:

Generate an AI summary, stop the dialog, and move its .ipynb to the archive folder.

消息路由

process_message 是核心入口:收到 /new 时归档旧会话并创建新 dialog;其他消息则追加为 prompt 并将 AI 回复发回给用户。


source

process_message


async def process_message(
    user_id:str, # WeCom sender ID
    content:str, # Plain-text message body
):

Route messages: ‘/new’ archives and resets the session; anything else is forwarded to AI.