deepagents-printshop 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agents/content_editor/__init__.py +1 -0
- agents/content_editor/agent.py +279 -0
- agents/content_editor/content_reviewer.py +327 -0
- agents/content_editor/versioned_agent.py +455 -0
- agents/latex_specialist/__init__.py +1 -0
- agents/latex_specialist/agent.py +531 -0
- agents/latex_specialist/latex_analyzer.py +510 -0
- agents/latex_specialist/latex_optimizer.py +1192 -0
- agents/qa_orchestrator/__init__.py +1 -0
- agents/qa_orchestrator/agent.py +603 -0
- agents/qa_orchestrator/langgraph_workflow.py +733 -0
- agents/qa_orchestrator/pipeline_types.py +72 -0
- agents/qa_orchestrator/quality_gates.py +495 -0
- agents/qa_orchestrator/workflow_coordinator.py +139 -0
- agents/research_agent/__init__.py +1 -0
- agents/research_agent/agent.py +258 -0
- agents/research_agent/llm_report_generator.py +1023 -0
- agents/research_agent/report_generator.py +536 -0
- agents/visual_qa/__init__.py +1 -0
- agents/visual_qa/agent.py +410 -0
- deepagents_printshop-0.1.0.dist-info/METADATA +744 -0
- deepagents_printshop-0.1.0.dist-info/RECORD +37 -0
- deepagents_printshop-0.1.0.dist-info/WHEEL +4 -0
- deepagents_printshop-0.1.0.dist-info/entry_points.txt +2 -0
- deepagents_printshop-0.1.0.dist-info/licenses/LICENSE +86 -0
- tools/__init__.py +1 -0
- tools/change_tracker.py +419 -0
- tools/content_type_loader.py +171 -0
- tools/graph_generator.py +281 -0
- tools/latex_generator.py +374 -0
- tools/llm_latex_generator.py +678 -0
- tools/magazine_layout.py +462 -0
- tools/pattern_injector.py +250 -0
- tools/pattern_learner.py +477 -0
- tools/pdf_compiler.py +386 -0
- tools/version_manager.py +346 -0
- tools/visual_qa.py +799 -0
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepagents-printshop
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Multi-agent LaTeX document generation with LangGraph QA pipeline
|
|
5
|
+
Project-URL: Homepage, https://github.com/kormco/deepagents-printshop
|
|
6
|
+
Project-URL: Repository, https://github.com/kormco/deepagents-printshop
|
|
7
|
+
Author: DeepAgents PrintShop Contributors
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ai,document-generation,langgraph,latex,multi-agent,pdf
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: anthropic
|
|
20
|
+
Requires-Dist: deepagents-cli
|
|
21
|
+
Requires-Dist: langchain
|
|
22
|
+
Requires-Dist: langchain-anthropic
|
|
23
|
+
Requires-Dist: langchain-openai
|
|
24
|
+
Requires-Dist: langgraph
|
|
25
|
+
Requires-Dist: matplotlib
|
|
26
|
+
Requires-Dist: openai
|
|
27
|
+
Requires-Dist: pandas
|
|
28
|
+
Requires-Dist: pdf2image
|
|
29
|
+
Requires-Dist: pillow
|
|
30
|
+
Requires-Dist: pypdf
|
|
31
|
+
Requires-Dist: python-dotenv
|
|
32
|
+
Requires-Dist: tavily-python
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
35
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# DeepAgents PrintShop - Intelligent LaTeX Document Generator
|
|
39
|
+
|
|
40
|
+
[](LICENSE)
|
|
41
|
+
[](https://python.org)
|
|
42
|
+
[](https://github.com/langchain-ai/langgraph)
|
|
43
|
+
[](https://pypi.org/project/deepagents-cli/)
|
|
44
|
+
|
|
45
|
+
An advanced multi-agent system that generates professional LaTeX documents with comprehensive quality assurance, LLM-based document optimization, and automated visual quality analysis. Orchestrated by a **LangGraph StateGraph** with quality gates, iterative refinement, and inter-agent communication.
|
|
46
|
+
|
|
47
|
+
## Example Output
|
|
48
|
+
|
|
49
|
+
The system generates two types of professional documents:
|
|
50
|
+
|
|
51
|
+
### Research Report
|
|
52
|
+
A professional academic-style research report with tables, figures, TikZ diagrams, and citations.
|
|
53
|
+
|
|
54
|
+
**Features:**
|
|
55
|
+
- Cover page disclaimer stating content is fictitious sample data
|
|
56
|
+
- Auto-generated table of contents matching the config manifest
|
|
57
|
+
- Data tables rendered from CSV files
|
|
58
|
+
- Performance comparison charts
|
|
59
|
+
- TikZ vector diagrams (neural network architecture)
|
|
60
|
+
- "Typeset by DeepAgents PrintShop" attribution
|
|
61
|
+
|
|
62
|
+
[View sample PDF](deepagents-printshop-SAMPLE-research_report.pdf) (~217KB, 10 pages) | [View pipeline walkthrough](docs/pipeline-walkthrough/PIPELINE_WALKTHROUGH.md)
|
|
63
|
+
|
|
64
|
+
### Magazine
|
|
65
|
+
A full-color magazine layout with multi-column text, pull quotes, and professional typography.
|
|
66
|
+
|
|
67
|
+
**Features:**
|
|
68
|
+
- Full-page cover with background image
|
|
69
|
+
- Creative table of contents with large section numbers
|
|
70
|
+
- Two-column article layouts with drop caps
|
|
71
|
+
- Pull quotes and infographic statistics
|
|
72
|
+
- Dark sections with inverted colors
|
|
73
|
+
- Back cover with barcode and issue/price info
|
|
74
|
+
- "Generated by DeepAgents PrintShop" attribution
|
|
75
|
+
|
|
76
|
+
[View sample PDF](deepagents-printshop-SAMPLE-magazine.pdf) (~7MB, 10-15 pages)
|
|
77
|
+
|
|
78
|
+
> **Note:** All generated documents include a disclaimer stating they contain fictitious sample content created for demonstration purposes.
|
|
79
|
+
|
|
80
|
+
### LangGraph Pipeline Architecture
|
|
81
|
+
|
|
82
|
+
The QA pipeline is orchestrated as a **LangGraph StateGraph** with conditional edges for quality gate decisions:
|
|
83
|
+
|
|
84
|
+
```mermaid
|
|
85
|
+
graph TD
|
|
86
|
+
START --> content_review
|
|
87
|
+
content_review -->|score >= 80| latex_optimization
|
|
88
|
+
content_review -->|score < 80| iteration
|
|
89
|
+
content_review -->|max iterations| escalation
|
|
90
|
+
latex_optimization -->|score >= 85| visual_qa
|
|
91
|
+
latex_optimization -->|score < 85| iteration
|
|
92
|
+
latex_optimization -->|max iterations| escalation
|
|
93
|
+
visual_qa --> quality_assessment
|
|
94
|
+
quality_assessment -->|score >= 80| completion
|
|
95
|
+
quality_assessment -->|score < 80| iteration
|
|
96
|
+
quality_assessment -->|max iterations| escalation
|
|
97
|
+
iteration --> content_review
|
|
98
|
+
completion --> END
|
|
99
|
+
escalation --> END
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Inter-agent communication flows through a shared `agent_context` dict — each node can read upstream notes and write downstream context for smarter decision-making.
|
|
103
|
+
|
|
104
|
+
## Recommended: Run with Claude Code
|
|
105
|
+
|
|
106
|
+
This project is designed to work seamlessly with **[Claude Code](https://claude.ai/code)** (Anthropic's agentic coding tool). Claude Code can:
|
|
107
|
+
|
|
108
|
+
- Run the full QA pipeline and monitor progress
|
|
109
|
+
- Automatically debug LaTeX compilation errors
|
|
110
|
+
- Iterate on document quality issues
|
|
111
|
+
- Make real-time adjustments to generated content
|
|
112
|
+
- Handle the multi-step workflow naturally
|
|
113
|
+
|
|
114
|
+
Simply open this project in Claude Code and ask it to "run the magazine pipeline" or "generate a research report" - it will handle the rest.
|
|
115
|
+
|
|
116
|
+
### Practical Example: Publishing Your Own Content
|
|
117
|
+
|
|
118
|
+
Instead of just running the sample documents, you can use Claude Code to publish your own research or content:
|
|
119
|
+
|
|
120
|
+
**Example prompt:**
|
|
121
|
+
> "I have research notes about machine learning model evaluation in my `~/research/ml_evaluation/` folder. Create a new PrintShop content source from these files and generate a professional PDF report."
|
|
122
|
+
|
|
123
|
+
Claude Code will:
|
|
124
|
+
1. Read your source files and understand the content structure
|
|
125
|
+
2. Create `artifacts/sample_content/ml_evaluation/` with properly organized content
|
|
126
|
+
3. Generate a `config.md` with appropriate metadata and content manifest
|
|
127
|
+
4. Convert your notes into structured markdown sections
|
|
128
|
+
5. Import any data tables as CSV files
|
|
129
|
+
6. Run the full QA pipeline to generate a polished PDF
|
|
130
|
+
|
|
131
|
+
**Other practical prompts:**
|
|
132
|
+
- "Convert my thesis draft into a properly formatted research report"
|
|
133
|
+
- "Take these meeting notes and create a professional magazine-style newsletter"
|
|
134
|
+
- "Format my API documentation into a technical report with code examples"
|
|
135
|
+
|
|
136
|
+
## Important Notice
|
|
137
|
+
|
|
138
|
+
**Disclaimer**: This software is provided "as-is" without warranty of any kind. The author is not liable for any damages or issues arising from the use of this software.
|
|
139
|
+
|
|
140
|
+
**Security Warning**: This project uses third-party packages and AI services (Claude API). Before using this software, especially in scenarios involving confidential data or private information:
|
|
141
|
+
- Review all third-party dependencies in `requirements.txt`
|
|
142
|
+
- Understand that content is sent to external LLM APIs (Anthropic Claude)
|
|
143
|
+
- Conduct your own security assessment for your use case
|
|
144
|
+
- Never process sensitive, proprietary, or confidential information without proper security measures
|
|
145
|
+
- Consider running in an isolated environment for sensitive workflows
|
|
146
|
+
|
|
147
|
+
By using this software, you acknowledge these risks and agree to conduct appropriate due diligence.
|
|
148
|
+
|
|
149
|
+
## Features
|
|
150
|
+
|
|
151
|
+
### Core Capabilities
|
|
152
|
+
- **LLM-Based LaTeX Generation**: Intelligent document creation with Claude Sonnet
|
|
153
|
+
- **Content-Driven References**: Inline `<!-- IMAGE: -->`, `<!-- CSV_TABLE: -->`, and `<!-- TIKZ: -->` comments in markdown are converted to LaTeX figures, tables, and diagrams
|
|
154
|
+
- **Content Type System**: Document types (`content_types/`) define rendering instructions, structure rules, and LaTeX requirements in natural language
|
|
155
|
+
- **Self-Correcting Compilation**: Automatic error detection and fix generation
|
|
156
|
+
- **Unicode Sanitization**: Automatic replacement of Unicode math characters with LaTeX equivalents for pdflatex compatibility
|
|
157
|
+
- **Multi-Agent QA Pipeline**: Automated quality assurance with specialized agents
|
|
158
|
+
- **Visual Quality Analysis**: AI-powered PDF layout and typography analysis
|
|
159
|
+
- **Iterative Refinement**: Progressive quality improvement over multiple passes
|
|
160
|
+
- **Version Tracking**: Complete change history with diff generation
|
|
161
|
+
- **Pattern Learning System**: Learns from version history to improve future documents
|
|
162
|
+
|
|
163
|
+
### Document Features
|
|
164
|
+
- Professional LaTeX reports with customizable structure
|
|
165
|
+
- Automatic table of contents driven by `config.md` manifest
|
|
166
|
+
- Data tables from CSV files via inline references
|
|
167
|
+
- Image placement via inline references
|
|
168
|
+
- TikZ vector diagrams via inline references
|
|
169
|
+
- PDF compilation with pdflatex
|
|
170
|
+
- Hyperlink and cross-reference support
|
|
171
|
+
- Cover page disclaimers and production citations from content type definitions
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
### Agent Nodes & Tools
|
|
175
|
+
|
|
176
|
+
| Node | Agent | Tools Used | LLM Calls |
|
|
177
|
+
|------|-------|------------|-----------|
|
|
178
|
+
| **ContentReview** | ContentEditorAgent | `ContentReviewer`, `VersionManager`, `ChangeTracker` | Claude Sonnet (grammar/readability analysis) |
|
|
179
|
+
| **LaTeXOptimization** | LaTeXSpecialistAgent | `LaTeXAnalyzer`, `LaTeXOptimizer`, `LLMLaTeXGenerator`, `PDFCompiler` | Claude Sonnet (LaTeX generation, syntax fixing, self-correction) |
|
|
180
|
+
| **VisualQA** | VisualQAFeedbackAgent | `PDFToImageConverter`, `VisualValidator`, `MultimodalLLMAnalyzer`, `LLMLaTeXGenerator`, `PDFCompiler` | Claude Haiku Vision (page analysis), Claude Sonnet (fix generation) |
|
|
181
|
+
|
|
182
|
+
### Quality Gates (Conditional Edges)
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
186
|
+
│ QUALITY GATE LOGIC │
|
|
187
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
188
|
+
│ │
|
|
189
|
+
│ Content Gate: score ≥ 80 → PASS │ score < 80 → ITERATE │
|
|
190
|
+
│ LaTeX Gate: score ≥ 85 → PASS │ score < 85 → ITERATE │
|
|
191
|
+
│ Overall Gate: score ≥ 90 → PASS (human handoff) │
|
|
192
|
+
│ score ≥ 80 → PASS (acceptable) │
|
|
193
|
+
│ score < 80 → ITERATE (if iterations < 3) │
|
|
194
|
+
│ iterations ≥ 3 → ESCALATE (human intervention) │
|
|
195
|
+
│ │
|
|
196
|
+
│ Convergence: improvement < 2 points → plateau detected │
|
|
197
|
+
│ │
|
|
198
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
## Content-Driven Document Assembly
|
|
203
|
+
|
|
204
|
+
Documents are assembled from a `config.md` manifest that defines section ordering, and markdown files that contain inline references to data and media:
|
|
205
|
+
|
|
206
|
+
### config.md Manifest
|
|
207
|
+
|
|
208
|
+
```markdown
|
|
209
|
+
## Content Manifest
|
|
210
|
+
1. Abstract
|
|
211
|
+
2. Introduction: introduction.md
|
|
212
|
+
3. Research Areas: research_areas.md
|
|
213
|
+
4. Methodology: methodology.md
|
|
214
|
+
5. Results: results.md
|
|
215
|
+
6. Visualizations: visualizations.md
|
|
216
|
+
7. Conclusion: conclusion.md
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Each manifest entry becomes a `\section{}` in the ToC. Markdown `##` headers become `\subsection{}`, `###` become `\subsubsection{}`.
|
|
220
|
+
|
|
221
|
+
### Inline References
|
|
222
|
+
|
|
223
|
+
**CSV tables** — rendered with booktabs:
|
|
224
|
+
```markdown
|
|
225
|
+
<!-- CSV_TABLE: model_performance.csv
|
|
226
|
+
caption: Complete Model Performance Data
|
|
227
|
+
label: tab:complete_perf
|
|
228
|
+
columns: all
|
|
229
|
+
rows: all
|
|
230
|
+
format: professional
|
|
231
|
+
-->
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Images** — rendered as figures:
|
|
235
|
+
```markdown
|
|
236
|
+
<!-- IMAGE: images/performance_comparison.png
|
|
237
|
+
caption: Performance Comparison Across Model Architectures
|
|
238
|
+
label: fig:performance_comparison
|
|
239
|
+
-->
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**TikZ diagrams** — rendered as vector graphics:
|
|
243
|
+
```markdown
|
|
244
|
+
<!-- TIKZ:
|
|
245
|
+
caption: Neural Network Architecture
|
|
246
|
+
label: fig:neural_net
|
|
247
|
+
code:
|
|
248
|
+
\node[circle, draw, minimum size=1cm] (input) at (0,0) {Input};
|
|
249
|
+
\node[circle, draw, minimum size=1cm] (hidden1) at (3,1) {H1};
|
|
250
|
+
\draw[->] (input) -- (hidden1);
|
|
251
|
+
-->
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Content Types
|
|
255
|
+
|
|
256
|
+
Content types in `content_types/<type>/type.md` define document class, rendering instructions, and LaTeX requirements in natural language. The LLM reads these instructions to generate disclaimers, citations, headers/footers, and other structural elements.
|
|
257
|
+
|
|
258
|
+
Available types: `research_report`, `magazine`, `ieee_conference`
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
## Pattern Learning System
|
|
262
|
+
|
|
263
|
+
The system learns from document generation history to continuously improve quality. **Patterns are organized by document type** (research_report, article, technical_doc, etc.), allowing type-specific optimizations. Instead of hard-coded rules, learned patterns are injected into LLM prompts for intelligent application.
|
|
264
|
+
|
|
265
|
+
### How It Works
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
1. Generate Documents → 2. Track Quality Metrics → 3. Mine Patterns
|
|
269
|
+
↓
|
|
270
|
+
6. Apply in Next Run ← 5. Inject into Prompts ← 4. Store Learnings
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Pattern Learner** (`tools/pattern_learner.py`):
|
|
274
|
+
- Analyzes version history and quality reports
|
|
275
|
+
- Extracts common LaTeX fixes (e.g., "Fixed multiple consecutive spaces")
|
|
276
|
+
- Tracks quality score trends (average: 89/100, target: 94/100)
|
|
277
|
+
- Identifies recurring recommendations (e.g., "Use booktabs package")
|
|
278
|
+
- Generates `.deepagents/learned_patterns.json` and human-readable reports
|
|
279
|
+
|
|
280
|
+
**Pattern Injector** (`tools/pattern_injector.py`):
|
|
281
|
+
- Loads learned patterns before document generation
|
|
282
|
+
- Provides agent-specific context (LaTeX Specialist, Visual QA, etc.)
|
|
283
|
+
- Injects patterns into Claude's generation prompts
|
|
284
|
+
- LLM reasons about patterns rather than blindly applying rules
|
|
285
|
+
|
|
286
|
+
**LLM Integration** (`agents/research_agent/llm_report_generator.py`):
|
|
287
|
+
- Uses `LLMLaTeXGenerator` instead of rule-based templates
|
|
288
|
+
- Receives pattern context in generation prompts
|
|
289
|
+
- Claude applies learnings intelligently based on document context
|
|
290
|
+
- Self-correcting with historical knowledge
|
|
291
|
+
|
|
292
|
+
### Running Pattern Learning
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# Mine patterns from version history (for research_report document type)
|
|
296
|
+
docker-compose run --rm deepagents-printshop python tools/pattern_learner.py
|
|
297
|
+
|
|
298
|
+
# View learned patterns (organized by document type)
|
|
299
|
+
cat .deepagents/memories/research_report/learned_patterns.json
|
|
300
|
+
cat .deepagents/memories/research_report/pattern_learning_report.md
|
|
301
|
+
|
|
302
|
+
# Generate document with pattern learning (automatic - uses research_report patterns)
|
|
303
|
+
docker-compose run --rm deepagents-printshop python agents/research_agent/llm_report_generator.py
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Installation
|
|
307
|
+
|
|
308
|
+
### PyPI (Python package only)
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
pip install deepagents-printshop
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
This installs the Python package and CLI entry point (`printshop`). You still need system dependencies (TeX Live, Poppler) for PDF compilation — see [SYSTEM_DEPS.md](SYSTEM_DEPS.md).
|
|
315
|
+
|
|
316
|
+
### From Source
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
git clone https://github.com/kormco/deepagents-printshop
|
|
320
|
+
cd deepagents-printshop
|
|
321
|
+
pip install -e ".[dev]"
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Quick Start
|
|
325
|
+
|
|
326
|
+
### Option 1: Docker (Recommended)
|
|
327
|
+
|
|
328
|
+
**Prerequisites:**
|
|
329
|
+
- Docker Desktop (installed and running)
|
|
330
|
+
- Anthropic API key (for Claude)
|
|
331
|
+
|
|
332
|
+
**Setup:**
|
|
333
|
+
|
|
334
|
+
1. **Copy the environment file and add your API keys:**
|
|
335
|
+
```bash
|
|
336
|
+
cp .env.example .env
|
|
337
|
+
```
|
|
338
|
+
Edit `.env` and add your `ANTHROPIC_API_KEY`
|
|
339
|
+
|
|
340
|
+
2. **Build and run the Docker container:**
|
|
341
|
+
```bash
|
|
342
|
+
docker-compose build
|
|
343
|
+
docker-compose run --rm deepagents-printshop
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
3. **Run the automated QA pipeline:**
|
|
347
|
+
```bash
|
|
348
|
+
# Generate research report (default)
|
|
349
|
+
python agents/qa_orchestrator/agent.py
|
|
350
|
+
|
|
351
|
+
# Generate magazine
|
|
352
|
+
python agents/qa_orchestrator/agent.py --content magazine
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Option 2: Local Setup (Without Docker)
|
|
356
|
+
|
|
357
|
+
**Prerequisites:**
|
|
358
|
+
- Python 3.11 or higher
|
|
359
|
+
- LaTeX distribution (required for PDF compilation):
|
|
360
|
+
- **Ubuntu/Debian:** `sudo apt-get install texlive-latex-base texlive-latex-extra texlive-fonts-recommended`
|
|
361
|
+
- **macOS:** `brew install --cask mactex` or `brew install texlive`
|
|
362
|
+
- **Windows:** Download and install **[MiKTeX](https://miktex.org/download)** (recommended) or [TeX Live](https://tug.org/texlive/)
|
|
363
|
+
- MiKTeX auto-installs missing packages on first use
|
|
364
|
+
- After install, verify with: `pdflatex --version`
|
|
365
|
+
- Poppler (for PDF to image conversion in Visual QA)
|
|
366
|
+
- **Ubuntu/Debian:** `sudo apt-get install poppler-utils`
|
|
367
|
+
- **macOS:** `brew install poppler`
|
|
368
|
+
- **Windows:** Download from [Poppler for Windows](https://github.com/oschwartz10612/poppler-windows/releases/) and add to PATH
|
|
369
|
+
- Anthropic API key (for Claude)
|
|
370
|
+
|
|
371
|
+
> **Windows Users:** MiKTeX is required to compile LaTeX to PDF. Without it, the pipeline will generate `.tex` files but cannot produce PDFs. The Visual QA stage also requires Poppler for PDF-to-image conversion.
|
|
372
|
+
|
|
373
|
+
**Setup:**
|
|
374
|
+
|
|
375
|
+
1. **Clone the repository:**
|
|
376
|
+
```bash
|
|
377
|
+
git clone <your-repo-url>
|
|
378
|
+
cd deepagents-printshop
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
2. **Create and activate a Python virtual environment:**
|
|
382
|
+
```bash
|
|
383
|
+
# Create virtual environment
|
|
384
|
+
python -m venv venv
|
|
385
|
+
|
|
386
|
+
# Activate virtual environment
|
|
387
|
+
# On Windows:
|
|
388
|
+
venv\Scripts\activate
|
|
389
|
+
# On macOS/Linux:
|
|
390
|
+
source venv/bin/activate
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
3. **Install Python dependencies:**
|
|
394
|
+
```bash
|
|
395
|
+
pip install -r requirements.txt
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
4. **Set up environment variables:**
|
|
399
|
+
```bash
|
|
400
|
+
# Copy the example file
|
|
401
|
+
cp .env.example .env
|
|
402
|
+
|
|
403
|
+
# Edit .env and add your API key:
|
|
404
|
+
# ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxx
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
5. **Run the automated QA pipeline:**
|
|
408
|
+
```bash
|
|
409
|
+
# Generate research report (default)
|
|
410
|
+
python agents/qa_orchestrator/agent.py
|
|
411
|
+
|
|
412
|
+
# Generate magazine
|
|
413
|
+
python agents/qa_orchestrator/agent.py --content magazine
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
**Running Individual Agents Locally:**
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
# Content quality review
|
|
420
|
+
python agents/content_editor/agent.py
|
|
421
|
+
|
|
422
|
+
# LaTeX generation (Author Agent)
|
|
423
|
+
python agents/research_agent/agent.py
|
|
424
|
+
|
|
425
|
+
# LaTeX optimization
|
|
426
|
+
python agents/latex_specialist/agent.py
|
|
427
|
+
|
|
428
|
+
# Visual quality analysis
|
|
429
|
+
python agents/visual_qa/agent.py
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**Verify LaTeX Installation:**
|
|
433
|
+
```bash
|
|
434
|
+
# Test LaTeX compiler
|
|
435
|
+
pdflatex --version
|
|
436
|
+
|
|
437
|
+
# Test PDF to image conversion
|
|
438
|
+
pdftoppm -h
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## Project Structure
|
|
442
|
+
|
|
443
|
+
```
|
|
444
|
+
deepagents-printshop/
|
|
445
|
+
├── agents/
|
|
446
|
+
│ ├── content_editor/ # Grammar, readability, style improvement
|
|
447
|
+
│ │ ├── agent.py # Main agent entry point
|
|
448
|
+
│ │ ├── content_reviewer.py # Claude-powered content analysis
|
|
449
|
+
│ │ └── versioned_agent.py # Version-aware agent wrapper
|
|
450
|
+
│ ├── latex_specialist/ # LaTeX formatting and typography
|
|
451
|
+
│ │ ├── agent.py
|
|
452
|
+
│ │ ├── latex_analyzer.py # LaTeX structure analysis
|
|
453
|
+
│ │ └── latex_optimizer.py # Typography optimization, TikZ/CSV/image processing
|
|
454
|
+
│ ├── qa_orchestrator/ # Multi-agent workflow coordination
|
|
455
|
+
│ │ ├── agent.py # Main orchestrator entry point
|
|
456
|
+
│ │ ├── langgraph_workflow.py # LangGraph StateGraph pipeline
|
|
457
|
+
│ │ ├── quality_gates.py # Pass/iterate/escalate logic
|
|
458
|
+
│ │ └── workflow_coordinator.py
|
|
459
|
+
│ ├── research_agent/ # Author Agent: LaTeX document generation
|
|
460
|
+
│ │ ├── agent.py
|
|
461
|
+
│ │ ├── llm_report_generator.py # LLM-based generation
|
|
462
|
+
│ │ └── report_generator.py # Template-based generator (legacy)
|
|
463
|
+
│ └── visual_qa/ # Visual PDF quality analysis
|
|
464
|
+
│ └── agent.py
|
|
465
|
+
├── content_types/ # Document type definitions
|
|
466
|
+
│ ├── research_report/type.md # Academic report rendering instructions
|
|
467
|
+
│ ├── magazine/type.md # Magazine layout rendering instructions
|
|
468
|
+
│ └── ieee_conference/type.md # IEEE conference paper instructions
|
|
469
|
+
├── tools/
|
|
470
|
+
│ ├── llm_latex_generator.py # LLM LaTeX generation with self-correction
|
|
471
|
+
│ ├── content_type_loader.py # Loads content type definitions
|
|
472
|
+
│ ├── pattern_learner.py # Mines version history for patterns
|
|
473
|
+
│ ├── pattern_injector.py # Injects patterns into agent prompts
|
|
474
|
+
│ ├── latex_generator.py # LaTeX document builder (preamble, sections, figures)
|
|
475
|
+
│ ├── pdf_compiler.py # PDF compilation with error handling
|
|
476
|
+
│ ├── visual_qa.py # Visual analysis with Claude Vision
|
|
477
|
+
│ ├── version_manager.py # File versioning system
|
|
478
|
+
│ └── change_tracker.py # Content change tracking and diffs
|
|
479
|
+
├── artifacts/
|
|
480
|
+
│ ├── sample_content/ # Source content (organized by document type)
|
|
481
|
+
│ │ ├── research_report/ # Academic research report content
|
|
482
|
+
│ │ │ ├── config.md # Document configuration & manifest
|
|
483
|
+
│ │ │ ├── *.md # Markdown content files with inline references
|
|
484
|
+
│ │ │ ├── data/ # CSV data tables
|
|
485
|
+
│ │ │ └── images/ # Charts and figures
|
|
486
|
+
│ │ └── magazine/ # Magazine content
|
|
487
|
+
│ │ ├── config.md # Magazine configuration & manifest
|
|
488
|
+
│ │ ├── *.md # Article content files
|
|
489
|
+
│ │ └── images/ # Cover, photos, barcode
|
|
490
|
+
│ ├── reviewed_content/ # Versioned outputs (created at runtime)
|
|
491
|
+
│ └── output/ # Final LaTeX and PDF files
|
|
492
|
+
├── tests/ # Pytest suite for pipeline and quality gates
|
|
493
|
+
├── .deepagents/ # Agent memory (created at runtime)
|
|
494
|
+
├── Dockerfile
|
|
495
|
+
├── docker-compose.yml
|
|
496
|
+
├── requirements.txt
|
|
497
|
+
└── SETUP.md # Detailed setup instructions
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
## Workflow Details
|
|
501
|
+
|
|
502
|
+
### Automated Pipeline (Recommended)
|
|
503
|
+
|
|
504
|
+
Run the QA orchestrator for a fully automated multi-agent workflow:
|
|
505
|
+
|
|
506
|
+
```bash
|
|
507
|
+
python agents/qa_orchestrator/agent.py
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
**Pipeline Stages:**
|
|
511
|
+
|
|
512
|
+
1. **Content Review** (Content Editor Agent + Claude LLM)
|
|
513
|
+
- Grammar and spelling correction with AI analysis
|
|
514
|
+
- Readability improvement using Claude
|
|
515
|
+
- Style consistency enforcement
|
|
516
|
+
- Pattern learning integration
|
|
517
|
+
- Quality scoring (0-100)
|
|
518
|
+
|
|
519
|
+
2. **LaTeX Optimization** (LaTeX Specialist Agent + Claude LLM)
|
|
520
|
+
- Markdown to LaTeX conversion via LLM (subsections from markdown headings)
|
|
521
|
+
- Config manifest titles become `\section{}` entries in the ToC
|
|
522
|
+
- Inline CSV_TABLE, IMAGE, and TIKZ references converted to LaTeX
|
|
523
|
+
- Cover page disclaimer and production citation from content type instructions
|
|
524
|
+
- Unicode sanitization for pdflatex compatibility
|
|
525
|
+
- Typography and structure optimization
|
|
526
|
+
- Quality scoring (0-100)
|
|
527
|
+
|
|
528
|
+
3. **Visual QA** (Visual QA Agent + Claude Vision)
|
|
529
|
+
- PDF to image conversion
|
|
530
|
+
- Page-by-page visual analysis
|
|
531
|
+
- Layout quality assessment
|
|
532
|
+
- Typography validation
|
|
533
|
+
- **LLM Self-Correction Loop:**
|
|
534
|
+
- Issues detected → LLM generates fixes
|
|
535
|
+
- Compilation attempted
|
|
536
|
+
- If errors → LLM analyzes and re-generates
|
|
537
|
+
- Repeat until successful or max attempts
|
|
538
|
+
|
|
539
|
+
4. **Quality Gates**
|
|
540
|
+
- Validates each stage meets thresholds
|
|
541
|
+
- Decides: pass, iterate, or escalate
|
|
542
|
+
- Tracks quality progression
|
|
543
|
+
- Generates comprehensive reports
|
|
544
|
+
|
|
545
|
+
### Quality Thresholds
|
|
546
|
+
|
|
547
|
+
```python
|
|
548
|
+
Content Quality:
|
|
549
|
+
Minimum: 80/100
|
|
550
|
+
Good: 85/100
|
|
551
|
+
Excellent: 90/100
|
|
552
|
+
|
|
553
|
+
LaTeX Quality:
|
|
554
|
+
Minimum: 85/100
|
|
555
|
+
Good: 90/100
|
|
556
|
+
Excellent: 95/100
|
|
557
|
+
|
|
558
|
+
Overall Pipeline:
|
|
559
|
+
Target: 80/100
|
|
560
|
+
Human Handoff: 90/100
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
## LLM-Based Tools
|
|
564
|
+
|
|
565
|
+
### LLM LaTeX Generator with Pattern Learning
|
|
566
|
+
The system uses Claude Sonnet for intelligent LaTeX generation with historical learning:
|
|
567
|
+
|
|
568
|
+
**Features:**
|
|
569
|
+
- Reasons about document structure and formatting
|
|
570
|
+
- **Applies learned patterns from historical documents**
|
|
571
|
+
- **Receives context about common issues and best practices**
|
|
572
|
+
- Handles edge cases dynamically
|
|
573
|
+
- Self-corrects compilation errors
|
|
574
|
+
- Learns from feedback loops
|
|
575
|
+
- Avoids problematic package combinations
|
|
576
|
+
|
|
577
|
+
**Self-Correction Loop with Pattern Learning:**
|
|
578
|
+
```
|
|
579
|
+
0. Load learned patterns → Inject into LLM context
|
|
580
|
+
↓
|
|
581
|
+
1. Generate LaTeX (with pattern awareness) → 2. Compile
|
|
582
|
+
↓
|
|
583
|
+
Error?
|
|
584
|
+
↓
|
|
585
|
+
3. LLM analyzes error (with historical context) ← Yes
|
|
586
|
+
↓
|
|
587
|
+
4. Generate corrected version
|
|
588
|
+
↓
|
|
589
|
+
5. Retry compilation (max 3 attempts)
|
|
590
|
+
↓
|
|
591
|
+
6. Track fixes → Update learned patterns for next run
|
|
592
|
+
```
|
|
593
|
+
|
|
594
|
+
### Visual QA with Claude Vision
|
|
595
|
+
Uses multimodal LLM analysis for PDF quality:
|
|
596
|
+
|
|
597
|
+
**Analyzed Aspects:**
|
|
598
|
+
- Title page layout and typography
|
|
599
|
+
- Table of contents structure
|
|
600
|
+
- Content page formatting
|
|
601
|
+
- Header/footer consistency
|
|
602
|
+
- Figure and table quality
|
|
603
|
+
- **Critical:** LaTeX syntax detection (flags unrendered LaTeX commands)
|
|
604
|
+
|
|
605
|
+
## Version Control System
|
|
606
|
+
|
|
607
|
+
All content versions are tracked with complete change history:
|
|
608
|
+
|
|
609
|
+
**Version Progression:**
|
|
610
|
+
```
|
|
611
|
+
v0_original (baseline markdown content)
|
|
612
|
+
↓
|
|
613
|
+
v1_content_edited (improved content)
|
|
614
|
+
↓
|
|
615
|
+
v2_latex_optimized (LaTeX + initial PDF)
|
|
616
|
+
↓
|
|
617
|
+
v3_visual_qa (visual analysis + iterative PDF improvements)
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
**Change Tracking:**
|
|
621
|
+
- JSON diff between versions
|
|
622
|
+
- Markdown summary of changes
|
|
623
|
+
- File-level change tracking
|
|
624
|
+
- Quality score progression
|
|
625
|
+
- Agent metadata and timestamps
|
|
626
|
+
|
|
627
|
+
## Output Files
|
|
628
|
+
|
|
629
|
+
After running the pipeline:
|
|
630
|
+
|
|
631
|
+
```
|
|
632
|
+
artifacts/
|
|
633
|
+
├── output/<run_id>/ # Final generated documents
|
|
634
|
+
│ ├── research_report.pdf # Research report PDF
|
|
635
|
+
│ └── research_report.tex # Research report LaTeX source
|
|
636
|
+
├── reviewed_content/ # Versioned outputs (created at runtime)
|
|
637
|
+
│ ├── v1_content_edited/
|
|
638
|
+
│ │ └── *.md # After content review
|
|
639
|
+
│ └── v2_latex_optimized/
|
|
640
|
+
│ └── *.tex, *.pdf # After LaTeX optimization
|
|
641
|
+
├── agent_reports/
|
|
642
|
+
│ ├── quality/
|
|
643
|
+
│ │ └── content_review_report.md
|
|
644
|
+
│ └── orchestration/
|
|
645
|
+
│ └── <run_id>_pipeline_summary.md
|
|
646
|
+
└── version_history/
|
|
647
|
+
├── changes/
|
|
648
|
+
│ └── v0_to_v1_summary.md
|
|
649
|
+
└── version_manifest.json
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
## Development
|
|
653
|
+
|
|
654
|
+
### Adding Custom Content
|
|
655
|
+
|
|
656
|
+
1. Create a new content folder: `artifacts/sample_content/my_document/`
|
|
657
|
+
2. Add a `config.md` with document settings, content manifest, and abstract
|
|
658
|
+
3. Place markdown files in the folder with inline `<!-- IMAGE: -->`, `<!-- CSV_TABLE: -->`, and `<!-- TIKZ: -->` references
|
|
659
|
+
4. Add CSV tables to `artifacts/sample_content/my_document/data/`
|
|
660
|
+
5. Add images to `artifacts/sample_content/my_document/images/`
|
|
661
|
+
6. Optionally create a content type in `content_types/my_type/type.md` with rendering instructions
|
|
662
|
+
7. Run the pipeline with: `python agents/qa_orchestrator/agent.py --content my_document`
|
|
663
|
+
|
|
664
|
+
See `artifacts/sample_content/research_report/config.md` for config.md format.
|
|
665
|
+
|
|
666
|
+
### Extending Agents
|
|
667
|
+
|
|
668
|
+
Each agent follows the DeepAgents framework pattern:
|
|
669
|
+
- Persistent memory in `.deepagents/[agent_name]/memories/`
|
|
670
|
+
- Configurable quality thresholds
|
|
671
|
+
- Versioned outputs
|
|
672
|
+
- Comprehensive reporting
|
|
673
|
+
|
|
674
|
+
### Customizing Quality Gates
|
|
675
|
+
|
|
676
|
+
Edit `agents/qa_orchestrator/quality_gates.py`:
|
|
677
|
+
|
|
678
|
+
```python
|
|
679
|
+
QualityThresholds(
|
|
680
|
+
content_minimum=80,
|
|
681
|
+
latex_minimum=85,
|
|
682
|
+
overall_target=80,
|
|
683
|
+
max_iterations=3
|
|
684
|
+
)
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
## Troubleshooting
|
|
688
|
+
|
|
689
|
+
### Common Issues
|
|
690
|
+
|
|
691
|
+
**Docker Build Fails:**
|
|
692
|
+
- Ensure Docker Desktop is running
|
|
693
|
+
- Check for symlink issues on Windows (delete `current` symlinks)
|
|
694
|
+
|
|
695
|
+
**API Errors:**
|
|
696
|
+
- Verify `ANTHROPIC_API_KEY` is set in `.env`
|
|
697
|
+
- Check API rate limits
|
|
698
|
+
|
|
699
|
+
**PDF Compilation Fails:**
|
|
700
|
+
- Check LaTeX logs in `artifacts/output/`
|
|
701
|
+
- LLM self-correction will attempt fixes automatically
|
|
702
|
+
- Review error messages in console output
|
|
703
|
+
|
|
704
|
+
**Visual QA Errors:**
|
|
705
|
+
- Ensure `poppler-utils` is installed in Docker
|
|
706
|
+
- Check PDF exists at expected path
|
|
707
|
+
- Verify Claude API has vision enabled
|
|
708
|
+
|
|
709
|
+
## Architecture Highlights
|
|
710
|
+
|
|
711
|
+
### Multi-Agent Coordination
|
|
712
|
+
- **QA Orchestrator** manages workflow state machine
|
|
713
|
+
- **Quality Gates** enforce standards and decision logic
|
|
714
|
+
- **Version Manager** tracks all content changes
|
|
715
|
+
- **Change Tracker** generates detailed diffs
|
|
716
|
+
|
|
717
|
+
### LLM Integration
|
|
718
|
+
- **Claude Sonnet** for LaTeX generation and correction
|
|
719
|
+
- **Claude Haiku** for content analysis
|
|
720
|
+
- **Claude Vision** for PDF visual quality assessment
|
|
721
|
+
- **Temperature tuning** for consistent vs. creative outputs
|
|
722
|
+
|
|
723
|
+
### Quality Assurance
|
|
724
|
+
- Automated testing at each pipeline stage
|
|
725
|
+
- Progressive quality improvement over iterations
|
|
726
|
+
- Human-in-the-loop escalation when needed
|
|
727
|
+
- Comprehensive reporting and analytics
|
|
728
|
+
|
|
729
|
+
## License
|
|
730
|
+
|
|
731
|
+
This project uses a dual license structure. See [LICENSE](LICENSE) for full details.
|
|
732
|
+
|
|
733
|
+
**Software**: Apache License 2.0 — free to use, modify, and distribute with attribution.
|
|
734
|
+
|
|
735
|
+
**Generated Content Attribution**: Documents generated using DeepAgents PrintShop must include attribution such as:
|
|
736
|
+
> "Generated with DeepAgents PrintShop" or "Powered by DeepAgents PrintShop"
|
|
737
|
+
|
|
738
|
+
**Sample Content**: The example magazine content in `artifacts/sample_content/` is licensed under CC BY-SA 4.0.
|
|
739
|
+
|
|
740
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. See LICENSE for full disclaimer.
|
|
741
|
+
|
|
742
|
+
## GitHub Topics
|
|
743
|
+
|
|
744
|
+
Recommended repository topics: `latex`, `document-generation`, `multi-agent`, `langgraph`, `pdf`, `ai-agent`, `quality-assurance`, `deep-agents`
|