> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Scientific Writer Agent

> Generate LaTeX-formatted academic papers with the CAJAL local model

> [!WARNING]
>
> **Removed in PraisonAI PR #1641** — `ScientificWriterAgent` / CAJAL integration was reverted. This page is kept for historical reference only; do not use in new projects.

Scientific Writer Agent created LaTeX-formatted academic papers using the CAJAL local model (no longer available in current releases).

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Removed — do not use in new projects (see Warning above)
# from praisonaiagents import ScientificWriterAgent
# agent = ScientificWriterAgent()
# paper = agent.write_paper("Machine Learning in Healthcare")
```

The user requested a LaTeX paper topic; the removed Scientific Writer agent drafted academic output via CAJAL (historical only).

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Scientific Paper Generation"
        A[Research Topic] --> B[Scientific Writer]
        B --> C[LaTeX Paper]
    end

    classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff

    class A input
    class B agent
    class C output
```

## Quick Start

**1. Simple Usage**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Historical API — removed in PR #1641
from praisonaiagents import ScientificWriterAgent

agent = ScientificWriterAgent()
paper = agent.write_paper("Machine Learning in Healthcare")

print(f"Title: {paper.title}")
print(f"Sections: {len(paper.sections)}")
```

**2. With Configuration**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import ScientificWriterAgent

agent = ScientificWriterAgent(
    model="Agnuxo/CAJAL-4B-P2PCLAW"
)

paper = agent.write_paper(
    "Quantum Computing Applications",
    style="research",
    citation_style="IEEE",
)
```

> [!NOTE]
>
> CAJAL was a 2GB local model. Required: `pip install transformers torch`

***

## How It Works

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent as Scientific Writer
    participant CAJAL as CAJAL Model
    participant LaTeX as LaTeX Output
    
    User->>Agent: Topic & Requirements
    Agent->>CAJAL: Process Scientific Request
    CAJAL-->>Agent: Generated Content
    Agent->>LaTeX: Format as LaTeX
    LaTeX-->>User: Academic Paper
```

| Method | Purpose | Output |
| - | - | - |
| `write_paper()` | Full paper generation | Complete `ScientificPaper` |
| `write_section()` | Single section creation | Individual `PaperSection` |
| `review_and_cite()` | Literature review with citations | Formatted citation text |

***

## Choosing the Right Method

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    Start[Need Scientific Content?] --> Full{Full Paper?}
    Full -->|Yes| Paper[write_paper]
    Full -->|No| Section{One Section?}
    Section -->|Yes| Single[write_section]
    Section -->|No| Citations{Add Citations?}
    Citations -->|Yes| Review[review_and_cite]
    Citations -->|No| Paper
    
    classDef method fill:#10B981,stroke:#7C90A0,color:#fff
    classDef decision fill:#F59E0B,stroke:#7C90A0,color:#fff
    
    class Paper,Single,Review method
    class Full,Section,Citations decision
```

***

## Common Patterns

### Single Section Generation

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import ScientificWriterAgent

agent = ScientificWriterAgent()
section = agent.write_section(
    section_title="Methodology",
    content_request="Machine learning approach for medical diagnosis",
    context="Previous work on CNN architectures"
)

print(section.title)
print(section.content)
print(section.latex_content)
```

### Adding Citations to Existing Content

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import ScientificWriterAgent

agent = ScientificWriterAgent()
draft = "Machine learning shows promise in healthcare applications."

cited_content = agent.review_and_cite(
    research_query="machine learning healthcare applications",
    existing_content=draft
)
print(cited_content)
```

### Multi-Agent Workflow

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, AgentTeam, Task, ScientificWriterAgent

# Create specialized research agents
literature_reviewer = Agent(
    name="Literature Reviewer",
    instructions="Find and analyze academic papers on the topic"
)

methodology_designer = Agent(
    name="Methodology Designer", 
    instructions="Design experimental methodology and approaches"
)

scientific_writer = ScientificWriterAgent(
    model="Agnuxo/CAJAL-4B-P2PCLAW"
)

# Create research workflow
team = AgentTeam(agents=[literature_reviewer, methodology_designer, scientific_writer])

tasks = [
    Task(
        description="Review literature on quantum computing in cryptography",
        agent=literature_reviewer
    ),
    Task(
        description="Design methodology for quantum key distribution analysis", 
        agent=methodology_designer
    ),
    Task(
        description="Write complete academic paper based on research",
        agent=scientific_writer
    )
]

result = team.run(tasks=tasks)
```

***

## Configuration Options

### ScientificWriterAgent Constructor

| Parameter | Type | Default | Description |
| - | - | - | - |
| `name` | `Optional[str]` | `"Scientific Writer"` | Agent display name |
| `model` | `Optional[str]` | `"Agnuxo/CAJAL-4B-P2PCLAW"` | Model identifier (CAJAL default) |
| `instructions` | `Optional[str]` | Built-in scientific instructions | Custom behavior instructions |
| `role` | `Optional[str]` | `"Scientific Paper Writer"` | Agent role description |
| `goal` | `Optional[str]` | `"Generate high-quality scientific papers..."` | Agent goal definition |
| `backstory` | `Optional[str]` | Built-in academic backstory | Agent background story |

### Method Parameters

#### `write_paper(topic, sections=None, style="academic", citation_style="APA")`

| Parameter | Type | Default | Description |
| - | - | - | - |
| `topic` | `str` | Required | Research topic for the paper |
| `sections` | `Optional[List[str]]` | `["Introduction", "Literature Review", "Methodology", "Results", "Discussion", "Conclusion"]` | Paper section structure |
| `style` | `str` | `"academic"` | Writing style: `"academic"`, `"review"`, `"research"` |
| `citation_style` | `str` | `"APA"` | Citation format: `"APA"`, `"IEEE"`, `"Nature"` |

#### `write_section(section_title, content_request, context=None)`

| Parameter | Type | Default | Description |
| - | - | - | - |
| `section_title` | `str` | Required | Title of the section |
| `content_request` | `str` | Required | Content requirements |
| `context` | `Optional[str]` | `None` | Additional context information |

#### `review_and_cite(research_query, existing_content=None)`

| Parameter | Type | Default | Description |
| - | - | - | - |
| `research_query` | `str` | Required | Research query for citations |
| `existing_content` | `Optional[str]` | `None` | Existing text to add citations to |

### Return Types

#### `PaperSection` (dataclass)

| Field | Type | Default | Description |
| - | - | - | - |
| `title` | `str` | Required | Section title |
| `content` | `str` | Required | Section content |
| `latex_content` | `str` | `""` | LaTeX-formatted content |

#### `ScientificPaper` (dataclass)

| Field | Type | Default | Description |
| - | - | - | - |
| `title` | `str` | Required | Paper title |
| `abstract` | `str` | Required | Paper abstract |
| `sections` | `List[PaperSection]` | `[]` | Paper sections |
| `references` | `List[str]` | `[]` | Bibliography entries |
| `latex_content` | `str` | `""` | Full LaTeX document |
| `metadata` | `Dict[str, Any]` | `{}` | Metadata (`model`, `generated_by`, `is_cajal`) |

***

## User Interaction Flow

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    User[Researcher] --> Topic[Define Topic]
    Topic --> Agent[Create ScientificWriterAgent]
    Agent --> Generate[paper = write_paper topic]
    Generate --> Inspect[Review paper.sections]
    Inspect --> Export[Save paper.latex_content]
    Export --> Compile[LaTeX Compilation]
    
    classDef user fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef process fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff
    
    class User,Topic user
    class Agent,Generate,Inspect process
    class Export,Compile output
```

A typical researcher workflow:

1. **Define Research Topic**: Specify the subject area and requirements
2. **Configure Agent**: Choose model (CAJAL for local) and citation style
3. **Generate Paper**: Call `write_paper()` with topic and preferences
4. **Review Sections**: Inspect individual sections in `paper.sections`
5. **Export LaTeX**: Save `paper.latex_content` to a `.tex` file
6. **Compile Document**: Process with LaTeX compiler for final PDF

***

## Best Practices

> [accordion] When to Use CAJAL vs General LLMs
>
> **CAJAL Model Benefits:**
>
> * Local processing (no API calls)
> * Offline capability
> * Scientific specialization
> * Consistent academic formatting
>
> **General LLM Benefits:**
>
> * Broader knowledge base
> * Faster processing
> * No local storage requirements
> * Latest research awareness
>
> **Recommendation:** Use CAJAL for sensitive research or offline environments; use general LLMs for broader knowledge requirements.

> [accordion] Choosing Section Lists for Different Paper Types
>
> **Research Papers:**
>
> ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> sections = ["Introduction", "Related Work", "Methodology", "Experiments", "Results", "Discussion", "Conclusion"]
> ```
>
> **Review Papers:**
>
> ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> sections = ["Introduction", "Background", "Literature Survey", "Analysis", "Future Directions", "Conclusion"]
> ```
>
> **Technical Reports:**
>
> ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
> sections = ["Executive Summary", "Problem Statement", "Solution Approach", "Implementation", "Evaluation", "Recommendations"]
> ```

> [accordion] Citation Style Selection
>
> * **APA**: Psychology, education, social sciences
> * **IEEE**: Engineering, computer science, technology
> * **Nature**: Natural sciences, physics, chemistry, biology
> * **MLA**: Literature, humanities (when available)
>
> Match the style to your target publication venue.

> [accordion] Multi-Agent Scientific Workflows
>
> Combine Scientific Writer with complementary agents:
>
> 1. **Literature Review Agent** → Research existing work
> 2. **Data Analysis Agent** → Process experimental data
> 3. **Scientific Writer Agent** → Generate formatted paper
> 4. **Review Agent** → Quality check and feedback
>
> This creates a comprehensive research pipeline for complex projects.

***

## Related

> [card] [Code Agent](https://praison.ai/docs/features/codeagent.md)
>
> Generate and analyze code for research implementations

> [card] [Math Agent](https://praison.ai/docs/features/mathagent.md)
>
> Solve mathematical problems and create equations


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.