Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 为“文档摘要”能力新增 SSE 流式生成链路,用于适配响应较慢的模型;同时将原 /api/v1/node/summary 调整为异步后台生成(主要用于批量场景),并在 admin 侧接入新的流式接口以实现边生成边展示。
Changes:
- 后端新增
/api/v1/node/summary/streamSSE 接口,并在 LLM usecase 中实现流式摘要输出与<think>过滤。 - admin 前端新增
nodeStream请求封装,并在多个摘要相关 UI 中切换为流式生成与独立的 generating/saving 状态。 - 更新 swagger 文档与部分生成的 TS client/types 以同步新增接口/字段。
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| web/admin/src/utils/fetch.ts | SSEClient 增加 responseMode 与 SSE JSON 解析逻辑,并引入完成态控制 |
| web/admin/src/request/nodeStream.ts | 新增 node summary 流式请求封装(SSE JSON) |
| web/admin/src/request/index.ts | 导出新增的 nodeStream 模块 |
| web/admin/src/pages/document/editor/edit/Summary.tsx | 编辑页摘要改为流式生成并拆分 generating/saving 状态 |
| web/admin/src/pages/document/component/Summary.tsx | 文档列表摘要弹窗改为流式生成并拆分 generating/saving 状态 |
| web/admin/src/pages/document/component/DocSummary.tsx | 批量生成摘要明确走后台异步,并补充 loading/校验逻辑 |
| web/admin/src/pages/document/component/DocPropertiesModal.tsx | 文档属性页摘要生成改为流式生成(summaryLoading) |
| web/admin/src/pages/document/layout/DocPageList/DocPageListContent.tsx | 批量工具栏“生成摘要”仅在选择 ≥2 时展示 |
| web/admin/src/request/Node.ts | 同步新增 summary stream endpoint(生成文件变更) |
| web/admin/src/request/types.ts | 同步补充 DomainRecommendNodeListResp.nav_id/nav_name(生成文件变更) |
| web/admin/src/components/CustomModal/components/config/DirDocConfig/Item.tsx | 目录配置项内摘要生成逻辑切换为流式(当前触发 UI 仍为注释块) |
| web/admin/src/components/CustomModal/components/config/BasicDocConfig/Item.tsx | 基础配置项内摘要生成逻辑切换为流式(当前触发 UI 仍为注释块) |
| backend/usecase/node.go | /summary 改为异步触发;新增 StreamSummaryNode 用于单文档流式摘要 |
| backend/usecase/llm.go | 新增 StreamSummaryNode/streamSummary,并实现流式 <think> 过滤 |
| backend/handler/v1/node.go | 新增 SSE handler:POST /api/v1/node/summary/stream,并写入 SSE event |
| backend/docs/swagger.yaml | swagger 同步新增 stream 接口并更新 summary 描述 |
| backend/docs/swagger.json | swagger 同步新增 stream 接口并更新 summary 描述 |
| backend/docs/docs.go | swagger 模板同步新增 stream 接口并更新 summary 描述 |
| AGENTS.md | 新增仓库 agent 指南文件(与本 PR 目标关联度较弱) |
Comments suppressed due to low confidence (1)
web/admin/src/request/Node.ts:442
- 该文件标注为 swagger-typescript-api 生成(文件头含
THIS FILE WAS GENERATED...),本次变更对其新增/修改了接口定义。为避免后续重新生成时出现漂移/冲突,建议确认这些改动是通过既定生成流程(同步后端 swagger 后重新生成 client)产生的,并在代码层尽量只在request/nodeStream.ts这类 wrapper 中做协议层适配,而不是长期依赖对生成文件的手工维护。
/**
* @description Summary Node
*
* @tags node
* @name PostApiV1NodeSummary
* @summary Summary Node 异步后台生成
* @request POST:/api/v1/node/summary
* @secure
* @response `200` `DomainResponse` OK
*/
export const postApiV1NodeSummary = (
body: DomainNodeSummaryReq,
params: RequestParams = {},
) =>
httpRequest<DomainResponse>({
path: `/api/v1/node/summary`,
method: "POST",
body: body,
secure: true,
type: ContentType.Json,
format: "json",
...params,
});
/**
* @description Stream Summary Node for single document
*
* @tags node
* @name PostApiV1NodeSummaryStream
* @summary Stream Summary Node
* @request POST:/api/v1/node/summary/stream
* @secure
* @response `200` `string` SSE stream
*/
export const postApiV1NodeSummaryStream = (
body: DomainNodeSummaryReq,
params: RequestParams = {},
) =>
httpRequest<string>({
path: `/api/v1/node/summary/stream`,
method: "POST",
body: body,
secure: true,
type: ContentType.Json,
...params,
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
452cad7 to
a23dfdc
Compare
a23dfdc to
6233d72
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
web/admin/src/pages/document/editor/edit/Wrap.tsx:210
- 这里移除了
onUploadImgUrl(以及对应的postApiV1FileUploadUrl上传逻辑),会导致编辑器不再支持“通过图片 URL 上传/转存”的能力。该行为变更与本 PR 的“摘要流式生成”目标不一致,且可能影响用户既有功能。建议确认是否为有意删除;若仍需保留能力,应恢复该回调或提供等价替代实现。
const editorRef = useTiptap({
editable: !isMarkdown,
contentType: isMarkdown ? 'markdown' : 'html',
immediatelyRender: true,
content: defaultDetail.content,
baseUrl: window.__BASENAME__ || '',
exclude: ['invisibleCharacters', 'youtube', 'mention'],
onCreate: ({ editor: tiptapEditor }) => {
const characterCount = (
tiptapEditor.storage as any
).characterCount.characters();
setCharacterCount(characterCount);
},
onError: handleError,
onUpload: handleUpload,
onUpdate: handleUpdate,
onTocUpdate: handleTocUpdate,
onAiWritingGetSuggestion: handleAiWritingGetSuggestion,
});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6233d72 to
90e2b9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 标题
文档摘要支持流式生成 适配响应过慢的模型 比如qwen3.5-plus
变更类型
请勾选适用的变更类型:
变更内容
详细描述本次 PR 的具体变更内容:
测试情况
描述本次变更的测试情况:
其他说明
任何其他需要说明的事项: