# Dialog


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

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

## AI 摘要生成

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

## 会话归档

[`archive_dialog`](https://TheSecondStep.github.io/solveit_wxbot/dialog.html#archive_dialog)
生成摘要、停止 dialog 内核，并将 `.ipynb` 文件移至 `archive/`
子目录，文件名格式为 `YYYYMMDD_HHMM_摘要.ipynb`。

------------------------------------------------------------------------

<a
href="https://github.com/TheSecondStep/solveit_wxbot/blob/main/solveit_wxbot/dialog.py#L33"
target="_blank" style="float:right; font-size:smaller">source</a>

### archive_dialog

``` python

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`](https://TheSecondStep.github.io/solveit_wxbot/dialog.html#process_message)
是核心入口：收到 `/new` 时归档旧会话并创建新 dialog；其他消息则追加为
prompt 并将 AI 回复发回给用户。

------------------------------------------------------------------------

<a
href="https://github.com/TheSecondStep/solveit_wxbot/blob/main/solveit_wxbot/dialog.py#L51"
target="_blank" style="float:right; font-size:smaller">source</a>

### process_message

``` python

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.*
