M7-03 P1 | Prisma ChatCitation 完善字段支持精确定位 #72

Closed
opened 2026-06-06 16:21:27 +08:00 by wangdl · 1 comment
Owner

目标

ChatCitation 补齐 sourceType/sourceId 和位置信息,支持 iOS 端跳回原文。

Schema 变更

model ChatCitation {
  // 新增
  sourceType     String?   // material | knowledge_item | folder | web | ai_generated_note
  sourceId       String?   
  materialId     String?
  knowledgeItemId String?
  folderId       String?
  pageNumber     Int?
  blockId        String?
  paragraphIndex Int?
  startOffset    Int?
  endOffset      Int?

  // 已有字段
  messageId      String
  chunkId        String?
  sourceTitle    String?
  excerptText    String?
  ...
}

说明

新建字段全部可选,兼容旧数据。后续 AI 回复时根据检索范围填充。

## 目标 ChatCitation 补齐 sourceType/sourceId 和位置信息,支持 iOS 端跳回原文。 ## Schema 变更 ```prisma model ChatCitation { // 新增 sourceType String? // material | knowledge_item | folder | web | ai_generated_note sourceId String? materialId String? knowledgeItemId String? folderId String? pageNumber Int? blockId String? paragraphIndex Int? startOffset Int? endOffset Int? // 已有字段 messageId String chunkId String? sourceTitle String? excerptText String? ... } ``` ## 说明 新建字段全部可选,兼容旧数据。后续 AI 回复时根据检索范围填充。
wangdl added this to the M7:ChatScope 会话系统 — 学习对象绑定的上下文会话 milestone 2026-06-06 16:21:27 +08:00
Author
Owner

完成情况

交付物

ChatCitation 新增字段 (prisma/schema.prisma):

lineStart  Int?
lineEnd    Int?

新增索引:

@@index([sourceId])

用途

  • lineStart / lineEnd — 精确定位引用在原文中的行号,前端可跳转到具体位置
  • @@index([sourceId]) — 加速按来源查询引用,例如"查看所有来自《xxx.pdf》的引用"

涉及文件

文件 变更
prisma/schema.prisma ChatCitation +2 字段 +1 索引
## 完成情况 ### 交付物 **ChatCitation 新增字段** (`prisma/schema.prisma`): ```prisma lineStart Int? lineEnd Int? ``` **新增索引**: ```prisma @@index([sourceId]) ``` ### 用途 - `lineStart` / `lineEnd` — 精确定位引用在原文中的行号,前端可跳转到具体位置 - `@@index([sourceId])` — 加速按来源查询引用,例如"查看所有来自《xxx.pdf》的引用" ### 涉及文件 | 文件 | 变更 | |------|------| | prisma/schema.prisma | ChatCitation +2 字段 +1 索引 |
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wangdl/api-server#72
No description provided.