feat(report): 报告生成端到端 — 规划→分章并行检索撰写→渲染真实 Word
- shared: 新增 intent=report 任务约定 + ReportPath(跨进程共享落盘目录,零配置对齐) - dispatcher: handleReport 专用编排(DeepSeek 规划大纲 → 各章并行 RAG 检索+撰写 → 汇聚 → report_render),Pool.Chat 非流式聚合;进度与正文经 Token 流实时回流 - mcp-go: 用标准库 archive/zip + OOXML 拼出真实可打开的 .docx(零额外依赖), report_render 工具落盘到共享目录;附 docx 有效性测试 - gateway: POST /reports 触发;GET /reports/:id/download 下发 Word - desktop: 新增「报告」页(主题→实时编排进度→下载 Word),左导航置为就绪 实测:DeepSeek 生成 5 章报告 → 渲染 5KB docx → file 识别为 Microsoft Word 2007+ → textutil 提取标题/各章正文完整。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package contract
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// ReportsDir 是报告渲染产物(.docx)的落盘目录。
|
||||
// Gateway(下载)与 mcp-go(渲染)跨进程共享同一目录:用环境变量统一,
|
||||
// 缺省取系统临时目录下的 sundynix-reports —— 单机开发零配置即可对齐。
|
||||
func ReportsDir() string {
|
||||
if d := os.Getenv("SUNDYNIX_REPORTS_DIR"); d != "" {
|
||||
return d
|
||||
}
|
||||
return filepath.Join(os.TempDir(), "sundynix-reports")
|
||||
}
|
||||
|
||||
// ReportPath 返回某任务渲染出的 Word 文档绝对路径。
|
||||
func ReportPath(id string) string {
|
||||
return filepath.Join(ReportsDir(), id+".docx")
|
||||
}
|
||||
@@ -34,6 +34,13 @@ const (
|
||||
// Gateway 持有配置,消费方(Dispatcher/mcp-go)经 NATS 取用/订阅变更。
|
||||
ConfigKindChat = "chat" // 对话模型(Dispatcher 用)
|
||||
ConfigKindEmbedding = "embedding" // 向量模型(mcp-go RAG 用)
|
||||
|
||||
// 报告生成:Task.Meta[MetaIntent]==IntentReport 时,Dispatcher 走专用多步编排
|
||||
// (规划大纲 → 各章节并行检索+撰写 → 汇聚 → 渲染 Word),而非通用对话图。
|
||||
MetaIntent = "intent"
|
||||
IntentReport = "report"
|
||||
MetaTopic = "topic" // 报告主题
|
||||
MetaKB = "kb" // 报告依据的知识库(可空,则不挂检索)
|
||||
)
|
||||
|
||||
// ConfigGetSubject / ConfigUpdatedSubject 返回某类配置的 request / 广播主题。
|
||||
|
||||
Reference in New Issue
Block a user