feat: 报告结构支持检索方向/来源与智能新增,并修复协助卡停轮与宿主跳转
为深度研究报告结构增加检索方向与技能来源、对话式智能新增页与详情排版;澄清中间件在 after_model 可靠结束本轮,避免弱模型出卡后继续生成;任务按钮补充 host 跳转与相关深链能力。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a5a9c952e8
commit
51afebb394
67 files changed
+4511
-699
No files matched your search
@@ -169,6 +169,7 @@ class FullReportRewriteRequest(BaseModel):
|
||||
instruction: str = Field(..., min_length=1, max_length=4_000)
|
||||
operation: Literal["rewrite", "generate"] = "rewrite"
|
||||
report_outline: str | None = Field(default=None, alias="reportOutline", max_length=20_000)
|
||||
structure_mode: Literal["fixed", "adaptive"] | None = Field(default=None, alias="structureMode")
|
||||
style: str | None = Field(default=None, max_length=64)
|
||||
model_name: str | None = Field(default=None, alias="modelName", max_length=256)
|
||||
|
||||
@@ -179,6 +180,7 @@ class CreateReportVariantRequest(BaseModel):
|
||||
"""Create an independent report before regenerating it with a new structure."""
|
||||
|
||||
report_outline: str | None = Field(default=None, alias="reportOutline", max_length=20_000)
|
||||
structure_mode: Literal["fixed", "adaptive"] | None = Field(default=None, alias="structureMode")
|
||||
|
||||
model_config = {"populate_by_name": True}
|
||||
|
||||
@@ -322,17 +324,34 @@ def _report_hash(report: str) -> str:
|
||||
return hashlib.sha256(report.encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
def _instruction_with_report_outline(instruction: str, report_outline: str) -> str:
|
||||
def _instruction_with_report_outline(
|
||||
instruction: str,
|
||||
report_outline: str,
|
||||
structure_mode: str | None = None,
|
||||
) -> str:
|
||||
"""Make a selected report template an explicit rewrite constraint."""
|
||||
normalized_instruction = instruction.strip()
|
||||
normalized_outline = report_outline.strip()
|
||||
if not normalized_outline:
|
||||
return normalized_instruction
|
||||
if structure_mode == "fixed":
|
||||
constraint = (
|
||||
"请按以下结构输出全文:文首题名与「日期:」「类型:」「密级:」等版头必须保留并填入真实值"
|
||||
"(占位符 XXX/xxx/xxxxx 不得照抄或删行;日期用当天中文日期;类型按题名判断;密级无另行规定时写「内部」)。"
|
||||
"章节标题、编号与层级必须与大纲一致,不得改写、合并、省略或重排任何小节;"
|
||||
"材料不足的小节保留原标题并写明资料不足,不得为凑结构编造事实。"
|
||||
)
|
||||
else:
|
||||
constraint = (
|
||||
"请按以下结构输出全文:文首题名与「日期:」「类型:」「密级:」等版头必须保留并填入真实值"
|
||||
"(占位符 XXX/xxx/xxxxx 不得照抄或删行;日期用当天中文日期;类型按题名判断;密级无另行规定时写「内部」)。"
|
||||
"章节按大纲展开;仅当某小节完全没有材料时才可合并或省略该小节,不得为套用结构编造事实。"
|
||||
)
|
||||
return "\n\n".join(
|
||||
(
|
||||
normalized_instruction,
|
||||
"【报告结构要求】",
|
||||
"请按以下 Markdown 章节结构重组全文;不适用的章节可以合并或省略,且不得为套用结构编造事实。",
|
||||
constraint,
|
||||
normalized_outline,
|
||||
)
|
||||
)
|
||||
@@ -825,6 +844,8 @@ async def create_report_variant(
|
||||
config_snapshot["parent_session_id"] = session_id
|
||||
if outline:
|
||||
config_snapshot["custom_outline"] = outline
|
||||
if body.structure_mode:
|
||||
config_snapshot["structure_mode"] = body.structure_mode
|
||||
|
||||
parent_title = str(parent.get("title") or parent.get("query") or "研究报告").strip()
|
||||
variant_id = _new_id("drs")
|
||||
@@ -895,7 +916,7 @@ async def start_full_report_rewrite_job(
|
||||
raise HTTPException(status_code=409, detail="A completed report is required before full rewrite")
|
||||
|
||||
report_outline = body.report_outline.strip() if body.report_outline else ""
|
||||
instruction = _instruction_with_report_outline(body.instruction, report_outline)
|
||||
instruction = _instruction_with_report_outline(body.instruction, report_outline, body.structure_mode)
|
||||
style = body.style.strip() if body.style else "formal_analysis"
|
||||
sources = await source_store.list_by_session(
|
||||
session_id,
|
||||
@@ -1409,7 +1430,7 @@ async def stream_full_report_rewrite(
|
||||
base_hash = _report_hash(report)
|
||||
style = body.style.strip() if body.style else "formal_analysis"
|
||||
report_outline = body.report_outline.strip() if body.report_outline else ""
|
||||
instruction = _instruction_with_report_outline(body.instruction, report_outline)
|
||||
instruction = _instruction_with_report_outline(body.instruction, report_outline, body.structure_mode)
|
||||
rewrite_target = _make_rewrite_target(report, 0, len(report), "全文")
|
||||
question = (
|
||||
"请重写整篇研究报告。"
|
||||
|
||||
Reference in new issue
Block a user