From e75f20b3294fda3e2444b509ff655882b58e0e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AF=BA=E6=96=AF=E8=B4=B9=E6=8B=89=E5=9B=BE?= <1132505822@qq.com> Date: Sun, 12 Apr 2026 17:46:47 +0800 Subject: [PATCH] feat: add IntroductionDraft node --- custom_nodes/research/__init__.py | 3 +- custom_nodes/research/introduction_draft.py | 79 +++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 custom_nodes/research/introduction_draft.py diff --git a/custom_nodes/research/__init__.py b/custom_nodes/research/__init__.py index f1f06dc9d..df65ed7ba 100644 --- a/custom_nodes/research/__init__.py +++ b/custom_nodes/research/__init__.py @@ -14,7 +14,8 @@ class ResearchExtension(ComfyExtension): from custom_nodes.research.reference_paper_select import ReferencePaperSelect from custom_nodes.research.section_plan import SectionPlan from custom_nodes.research.abstract_draft import AbstractDraft - return [PaperSearch, PaperClaimExtract, ClaimEvidenceAssemble, StyleProfileExtract, ReferencePaperSelect, SectionPlan, AbstractDraft] + from custom_nodes.research.introduction_draft import IntroductionDraft + return [PaperSearch, PaperClaimExtract, ClaimEvidenceAssemble, StyleProfileExtract, ReferencePaperSelect, SectionPlan, AbstractDraft, IntroductionDraft] async def comfy_entrypoint() -> ComfyExtension: diff --git a/custom_nodes/research/introduction_draft.py b/custom_nodes/research/introduction_draft.py new file mode 100644 index 000000000..51f657e2c --- /dev/null +++ b/custom_nodes/research/introduction_draft.py @@ -0,0 +1,79 @@ +"""IntroductionDraft node - generate introduction text.""" +import json +from typing_extensions import override +from comfy_api.latest import ComfyNode, io + + +class IntroductionDraft(io.ComfyNode): + """Generate an introduction draft based on problem framing and contributions.""" + + @classmethod + def define_schema(cls) -> io.Schema: + return io.Schema( + node_id="IntroductionDraft", + display_name="Draft Introduction", + category="Research", + inputs=[ + io.String.Input( + "problem_framing", + display_name="Problem Framing", + default="", + multiline=True, + ), + io.String.Input( + "gap_statement", + display_name="Gap Statement", + default="", + multiline=True, + ), + io.String.Input( + "contribution", + display_name="Our Contribution", + default="", + multiline=True, + ), + io.String.Input( + "style_profile", + display_name="Style Profile (JSON)", + default="{}", + multiline=True, + ), + ], + outputs=[ + io.String.Output(display_name="Introduction Text"), + ], + ) + + @classmethod + def execute(cls, problem_framing: str, gap_statement: str, contribution: str, style_profile: str) -> io.NodeOutput: + try: + style = json.loads(style_profile) if style_profile else {} + except json.JSONDecodeError: + style = {} + + paragraphs = [] + + # Paragraph 1: Hook and problem + if problem_framing: + paragraphs.append(f"{problem_framing}") + else: + paragraphs.append("Medical image analysis plays a crucial role in modern healthcare. Accurate segmentation of anatomical structures enables precise diagnosis and treatment planning. However, achieving reliable automated segmentation remains challenging due to anatomical variability and imaging artifacts.") + + # Paragraph 2: Gap + if gap_statement: + paragraphs.append(f"{gap_statement}") + else: + paragraphs.append("Existing approaches often struggle with boundary ambiguity and fail to generalize across different imaging protocols. While deep learning methods have shown promise, they typically require large annotated datasets that are expensive to obtain in medical domains.") + + # Paragraph 3: Contribution + if contribution: + paragraphs.append(f"{contribution}") + else: + paragraphs.append("To address these limitations, we propose a novel framework that leverages self-supervised pretraining and domain adaptation. Our approach reduces annotation requirements while improving segmentation accuracy across diverse imaging conditions.") + + # Paragraph 4: Structure + paragraphs.append("The remainder of this paper is organized as follows. Section 2 reviews related work. Section 3 describes our methodology. Section 4 presents experimental results. Section 5 discusses implications and concludes the paper.") + + intro_text = "\n\n".join(paragraphs) + + return io.NodeOutput(intro_text=intro_text)