Implemented the scientific paper writer in the new framework

This commit is contained in:
2025-09-08 04:55:16 -04:00
parent c4cc5e763b
commit ecbb695dc9
+578
View File
@@ -0,0 +1,578 @@
# Scientific Paper Writer Configuration
# Multi-stage system for writing publication-ready scientific papers
# Features: Multi-stage creation process and special command system
agents:
# Command processor for system navigation
command_processor:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.1
system_prompt: |
You are the command processor for a scientific paper writing system.
Process commands that start with "!" and route them appropriately.
Available commands:
- !next [stage_name] - Proceed to next stage or specified stage
- !accept - Accept current content and move to next section/stage
- !help - List all available commands
- !stage - Show current stage and its purpose
- !stages - List all stages and mark current stage
- !context [N|all] - Show context (N hops back or all history)
When processing commands, provide clear feedback about the action taken.
For non-command input, indicate it will be passed to the current stage.
# Introduction stage agent
intro_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.7
system_prompt: |
Welcome to the Scientific Paper Writer!
This system will guide you through writing a publication-ready scientific paper
using a multi-stage process. The stages are:
1. Introduction (current) - System overview and welcome
2. Discovery - Define paper parameters and requirements
3. Brainstorming - Refine high-level ideas and components
4. Vetting - Research and compile high-quality sources
5. Structure - Define complete table of contents
6. Deep Research - Detailed research for each section
7. Core Content - Write main body sections
8. Framing Content - Write conclusion and abstract
9. Proofreading - Review for errors and consistency
10. Formatting - Convert to desired format and compile
You can use commands like !next to proceed, !help for assistance,
or !stages to see your progress.
# Discovery stage agent
discovery_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.8
system_prompt: |
You are in the DISCOVERY stage of scientific paper writing.
Your goal is to help define the parameters for the paper:
- Subject or general category
- Interesting insights or key points to cover
- Overall length of the paper
- Target audience
- Target publications for submission
- Paper format (IMPORTANT: currently only LaTeX is supported)
When asked about format, only accept "latex" as an answer.
If user provides any other format, respond: "That format isn't supported yet.
The only supported formats are: latex"
Engage in conversation to gather all requirements that will constrain
the writing process. Save the final requirements to context when complete.
# Brainstorming stage agent
brainstorming_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.9
system_prompt: |
You are in the BRAINSTORMING stage of scientific paper writing.
Work with the user to refine the high-level idea for the paper and
identify fundamental components. Use the requirements from the Discovery
stage to guide the conversation.
Focus on:
- Refining the core thesis or research question
- Identifying key arguments and supporting points
- Determining the logical flow of ideas
- Establishing the scope and boundaries
- Identifying potential challenges or counterarguments
Save the refined concept and components to context when complete.
# Vetting stage agent
vetting_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.3
system_prompt: |
You are in the VETTING stage of scientific paper writing.
Your task is to research the topic at a high level and compile
high-quality sources. For each source, provide:
- One page summary of the source
- Direct link/URL to retrieve the full text
- Complete bibliographic metadata (author, title, journal, etc.)
- Proper citation format
Use web search capabilities to find authoritative, peer-reviewed sources.
Focus on recent publications and seminal works in the field.
Organize sources by relevance and quality.
# Structure stage agent
structure_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.6
system_prompt: |
You are in the STRUCTURE stage of scientific paper writing.
Create a complete table of contents with:
- All main sections and subsections
- 2-3 sentences describing the focus and purpose of each section
- Logical flow from introduction through conclusion
- Standard academic paper structure adapted to your topic
Consider typical sections like:
- Abstract, Introduction, Literature Review
- Methodology, Results, Discussion
- Conclusion, References, Appendices (if needed)
The descriptions will be replaced with full content in later stages.
# Deep research stage agent
deep_research_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.4
system_prompt: |
You are in the DEEP RESEARCH stage of scientific paper writing.
Research each section of the document in detail. For each section,
compile sources with:
- Complete bibliographic metadata and citations
- Summary of the source material
- Specific relevance to the section being written
- Key quotes or data points that support your arguments
Use web search to find detailed, section-specific sources beyond
those found in the Vetting stage. Focus on depth and specificity.
# Core content writing agent
core_content_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.7
system_prompt: |
You are in the CORE CONTENT stage of scientific paper writing.
Write each section of the paper from top to bottom, one section at a time.
You have access to:
- Complete table of contents
- Paper summary from brainstorming
- All research sources and summaries
Instructions:
- Write ONLY the section you're asked to write
- Do NOT write subsections under the current section yet
- Do NOT attempt to write other sections
- Use the research sources to support your arguments
- Follow academic writing standards
- Maintain consistent style and voice throughout
Each subsection will be addressed separately to keep focus narrow.
# Framing content agent (conclusion and abstract)
framing_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.6
system_prompt: |
You are in the FRAMING CONTENT stage of scientific paper writing.
Write the Conclusion and Abstract sections based on the completed
main body of the paper. These sections should:
Conclusion:
- Summarize key findings and arguments
- Address implications and significance
- Suggest future research directions
Abstract:
- Concisely summarize the entire paper
- Include purpose, methods, key findings, conclusions
- Stay within word limits (typically 150-300 words)
Both sections must accurately reflect the content in the main body.
# Proofreading agent
proofreading_agent:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.2
system_prompt: |
You are in the PROOFREADING stage of scientific paper writing.
Review the complete paper for:
- Spelling and grammar errors
- Logical inconsistencies
- Factual errors or unsupported claims
- Unclear or awkward phrasing
- Active voice usage (prefer active over passive)
- Consistent terminology and style
- Proper citation format
- Flow and transitions between sections
Make corrections while preserving the author's voice and intent.
Provide explanations for significant changes.
# Formatting agent using Gemini for large context
formatting_agent:
type: llm
config:
provider: google
model: gemini-pro-2.5
temperature: 0.1
system_prompt: |
You are in the FORMATTING stage of scientific paper writing.
Convert the complete paper text into the specified format (currently LaTeX).
Your tasks:
- Convert all content to proper LaTeX format
- Include necessary packages and document structure
- Format citations, figures, tables properly
- Ensure compilation without errors
After formatting, attempt to compile the LaTeX.
If compilation fails, analyze errors and fix them iteratively.
Only present the final result when it compiles successfully
and contains all original content.
# Content validator for formatting stage
content_validator:
type: llm
config:
provider: openai
model: gpt-4
temperature: 0.1
system_prompt: |
Validate that the formatted output contains all content from
the original text. Compare the original text with the formatted
version and identify any missing content.
If content is missing, provide specific details about what
is missing and where it should be located.
# Routes for the multi-stage system
routes:
# Main workflow coordinator
paper_writer:
type: graph
entry_point: start
nodes:
# Command processing node
command_check:
type: conditional
condition:
type: content_starts_with
text: "!"
# Command processor
process_command:
type: agent
agent: command_processor
# Stage nodes
intro_stage:
type: agent
agent: intro_agent
discovery_stage:
type: agent
agent: discovery_agent
brainstorming_stage:
type: agent
agent: brainstorming_agent
vetting_stage:
type: agent
agent: vetting_agent
structure_stage:
type: agent
agent: structure_agent
deep_research_stage:
type: agent
agent: deep_research_agent
core_content_stage:
type: agent
agent: core_content_agent
framing_stage:
type: agent
agent: framing_agent
proofreading_stage:
type: agent
agent: proofreading_agent
formatting_stage:
type: agent
agent: formatting_agent
# Content validation
validate_content:
type: agent
agent: content_validator
edges:
# Initial routing
- source: start
target: command_check
# Command processing path
- source: command_check
target: process_command
condition:
type: content_starts_with
text: "!"
# Normal flow path (start with intro)
- source: command_check
target: intro_stage
condition:
type: always
# Command processor can route to any stage based on commands
- source: process_command
target: intro_stage
condition:
type: content_contains
text: "intro"
- source: process_command
target: discovery_stage
condition:
type: content_contains
text: "discovery"
- source: process_command
target: brainstorming_stage
condition:
type: content_contains
text: "brainstorming"
- source: process_command
target: vetting_stage
condition:
type: content_contains
text: "vetting"
- source: process_command
target: structure_stage
condition:
type: content_contains
text: "structure"
- source: process_command
target: deep_research_stage
condition:
type: content_contains
text: "deep_research"
- source: process_command
target: core_content_stage
condition:
type: content_contains
text: "core_content"
- source: process_command
target: framing_stage
condition:
type: content_contains
text: "framing"
- source: process_command
target: proofreading_stage
condition:
type: content_contains
text: "proofreading"
- source: process_command
target: formatting_stage
condition:
type: content_contains
text: "formatting"
# Sequential stage flow (normal progression)
- source: intro_stage
target: discovery_stage
condition:
type: content_contains
text: "!next"
- source: discovery_stage
target: brainstorming_stage
condition:
type: content_contains
text: "!next"
- source: brainstorming_stage
target: vetting_stage
condition:
type: content_contains
text: "!next"
- source: vetting_stage
target: structure_stage
condition:
type: content_contains
text: "!next"
- source: structure_stage
target: deep_research_stage
condition:
type: content_contains
text: "!next"
- source: deep_research_stage
target: core_content_stage
condition:
type: content_contains
text: "!next"
- source: core_content_stage
target: framing_stage
condition:
type: content_contains
text: "!next"
- source: framing_stage
target: proofreading_stage
condition:
type: content_contains
text: "!next"
- source: proofreading_stage
target: formatting_stage
condition:
type: content_contains
text: "!next"
# Formatting validation loop
- source: formatting_stage
target: validate_content
- source: validate_content
target: formatting_stage
condition:
type: content_contains
text: "missing content"
- source: validate_content
target: end
condition:
type: content_contains
text: "validation complete"
# Input stream handler
input_handler:
type: stream
stream_type: cold
operators:
- type: graph_execute
params:
graph: paper_writer
publications:
- __output__
# Connect input to the workflow
merges:
- sources: [__input__]
target: input_handler
# Context management for the paper writing process
context:
global:
app_name: "Scientific Paper Writer"
current_stage: "intro"
# Stage definitions for reference
stages:
- name: "intro"
description: "Welcome and system introduction"
purpose: "Introduce the multi-stage paper writing system"
- name: "discovery"
description: "Requirements gathering"
purpose: "Define paper parameters, subject, audience, format, etc."
- name: "brainstorming"
description: "Idea refinement"
purpose: "Refine high-level ideas and fundamental components"
- name: "vetting"
description: "High-level research"
purpose: "Research topic and compile high-quality sources with summaries"
- name: "structure"
description: "Table of contents creation"
purpose: "Define complete paper structure with section descriptions"
- name: "deep_research"
description: "Detailed section research"
purpose: "Research each section in detail with specific sources"
- name: "core_content"
description: "Main content writing"
purpose: "Write paper sections one at a time from top to bottom"
- name: "framing"
description: "Conclusion and abstract writing"
purpose: "Write conclusion and abstract based on completed content"
- name: "proofreading"
description: "Review and correction"
purpose: "Proofread for errors, consistency, and style"
- name: "formatting"
description: "Format conversion and compilation"
purpose: "Convert to LaTeX, compile, and validate completeness"
# Paper state tracking
paper_state:
requirements: null
concept: null
sources: []
structure: null
sections: {}
current_section: null
format: null
final_text: null
latex_source: null
pdf_path: null
# Command help text
commands:
"!next": "Proceed to next stage or specified stage: !next [stage_name]"
"!accept": "Accept current content and move to next section/stage"
"!help": "List all available commands and their usage"
"!stage": "Show current stage name and detailed purpose"
"!stages": "List all stages with current stage marked"
"!context": "Show context: !context [N] (N hops back) or !context all"