IOS-H0-01 P1 | AI 对话 SSE 流式接收 + DeepSeek V4 Pro 思考过程展示 #38

Closed
opened 2026-06-06 14:41:34 +08:00 by wangdl · 2 comments
Owner

背景

当前 AIChatPage 使用一次性 POST /messages 同步等待完整回复。后端改为 SSE 流式输出后,iOS 需要适配流式接收,并展示 V4 Pro 的思考过程。

需求

  1. RagChatService 新增 sendMessageStream()URLSession + AsyncBytes 逐行读 SSE
  2. AIChatViewModel 适配流式:thinkingContent 逐字追加,思考结束后追加 content
  3. AIChatPage 新增思考过程气泡 — 灰色斜体,可展开/折叠
  4. 打字机效果:content 逐字显示

数据格式

SSE: data: {"type":"thinking","content":"让我分析..."}
SSE: data: {"type":"content","content":"你好!"}
SSE: data: {"type":"done","usage":{...}}

关联

  • API: wangdl/api-server — POST /api/rag-chat/sessions/:id/stream (SSE endpoint)
## 背景 当前 `AIChatPage` 使用一次性 `POST /messages` 同步等待完整回复。后端改为 SSE 流式输出后,iOS 需要适配流式接收,并展示 V4 Pro 的思考过程。 ## 需求 1. `RagChatService` 新增 `sendMessageStream()` — `URLSession` + `AsyncBytes` 逐行读 SSE 2. `AIChatViewModel` 适配流式:`thinkingContent` 逐字追加,思考结束后追加 `content` 3. `AIChatPage` 新增思考过程气泡 — 灰色斜体,可展开/折叠 4. 打字机效果:content 逐字显示 ## 数据格式 ``` SSE: data: {"type":"thinking","content":"让我分析..."} SSE: data: {"type":"content","content":"你好!"} SSE: data: {"type":"done","usage":{...}} ``` ## 关联 - API: wangdl/api-server — POST /api/rag-chat/sessions/:id/stream (SSE endpoint)
Author
Owner

iOS 侧完成 (2026-06-06)

改动

  • APIClient 新增 getToken() 方法
  • RagChatService 新增 sendMessageStream() — URLSession bytes 逐行读 SSE
  • AIChatViewModel send() 改用流式:thinking + content 逐字更新 placeholder message
  • AIMessage 新增 thinkingContent + isStreaming 字段
  • AIChatPage 思考过程气泡 — 灰色斜体 + brain 图标 + streaming 指示器

状态

iOS 侧完成,等待后端部署后联调。

## iOS 侧完成 (2026-06-06) ### 改动 - `APIClient` 新增 `getToken()` 方法 - `RagChatService` 新增 `sendMessageStream()` — URLSession bytes 逐行读 SSE - `AIChatViewModel` `send()` 改用流式:thinking + content 逐字更新 placeholder message - `AIMessage` 新增 `thinkingContent` + `isStreaming` 字段 - `AIChatPage` 思考过程气泡 — 灰色斜体 + brain 图标 + streaming 指示器 ### 状态 ✅ iOS 侧完成,等待后端部署后联调。
Author
Owner

关闭

已被 M-CHAT 里程碑替代。ChatScope 系统已完整实现了 AI 会话的 scope 绑定和 SSE 流式输出。

## 关闭 已被 M-CHAT 里程碑替代。ChatScope 系统已完整实现了 AI 会话的 scope 绑定和 SSE 流式输出。
Sign in to join this conversation.
No description provided.