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.
Files changed (37) hide show
  1. agents/content_editor/__init__.py +1 -0
  2. agents/content_editor/agent.py +279 -0
  3. agents/content_editor/content_reviewer.py +327 -0
  4. agents/content_editor/versioned_agent.py +455 -0
  5. agents/latex_specialist/__init__.py +1 -0
  6. agents/latex_specialist/agent.py +531 -0
  7. agents/latex_specialist/latex_analyzer.py +510 -0
  8. agents/latex_specialist/latex_optimizer.py +1192 -0
  9. agents/qa_orchestrator/__init__.py +1 -0
  10. agents/qa_orchestrator/agent.py +603 -0
  11. agents/qa_orchestrator/langgraph_workflow.py +733 -0
  12. agents/qa_orchestrator/pipeline_types.py +72 -0
  13. agents/qa_orchestrator/quality_gates.py +495 -0
  14. agents/qa_orchestrator/workflow_coordinator.py +139 -0
  15. agents/research_agent/__init__.py +1 -0
  16. agents/research_agent/agent.py +258 -0
  17. agents/research_agent/llm_report_generator.py +1023 -0
  18. agents/research_agent/report_generator.py +536 -0
  19. agents/visual_qa/__init__.py +1 -0
  20. agents/visual_qa/agent.py +410 -0
  21. deepagents_printshop-0.1.0.dist-info/METADATA +744 -0
  22. deepagents_printshop-0.1.0.dist-info/RECORD +37 -0
  23. deepagents_printshop-0.1.0.dist-info/WHEEL +4 -0
  24. deepagents_printshop-0.1.0.dist-info/entry_points.txt +2 -0
  25. deepagents_printshop-0.1.0.dist-info/licenses/LICENSE +86 -0
  26. tools/__init__.py +1 -0
  27. tools/change_tracker.py +419 -0
  28. tools/content_type_loader.py +171 -0
  29. tools/graph_generator.py +281 -0
  30. tools/latex_generator.py +374 -0
  31. tools/llm_latex_generator.py +678 -0
  32. tools/magazine_layout.py +462 -0
  33. tools/pattern_injector.py +250 -0
  34. tools/pattern_learner.py +477 -0
  35. tools/pdf_compiler.py +386 -0
  36. tools/version_manager.py +346 -0
  37. tools/visual_qa.py +799 -0
@@ -0,0 +1,250 @@
1
+ """
2
+ Pattern Injector - Milestone 3
3
+
4
+ Injects learned patterns into agent prompts to improve decision-making.
5
+ Uses historical learnings to guide LLM behavior without hard-coding fixes.
6
+ """
7
+
8
+ import json
9
+ from pathlib import Path
10
+ from typing import Dict, Optional
11
+
12
+
13
+ class PatternInjector:
14
+ """
15
+ Inject learned patterns into agent prompts.
16
+
17
+ Provides context-aware prompt augmentation based on historical patterns.
18
+ """
19
+
20
+ def __init__(self, document_type: str = "research_report"):
21
+ """
22
+ Initialize pattern injector.
23
+
24
+ Args:
25
+ document_type: Type of document (e.g., 'research_report', 'article', 'technical_doc')
26
+ """
27
+ self.document_type = document_type
28
+ self.patterns_file = Path(".deepagents") / "memories" / document_type / "learned_patterns.json"
29
+ self.patterns = self._load_patterns()
30
+
31
+ def _load_patterns(self) -> Dict:
32
+ """Load learned patterns from file."""
33
+ if not self.patterns_file.exists():
34
+ return {
35
+ "common_latex_fixes": {},
36
+ "quality_improvements": [],
37
+ "recurring_issues": [],
38
+ "agent_performance": {},
39
+ "insights": []
40
+ }
41
+
42
+ try:
43
+ with open(self.patterns_file, 'r', encoding='utf-8') as f:
44
+ return json.load(f)
45
+ except Exception as e:
46
+ print(f"āš ļø Could not load patterns: {e}")
47
+ return {
48
+ "common_latex_fixes": {},
49
+ "quality_improvements": [],
50
+ "recurring_issues": [],
51
+ "agent_performance": {},
52
+ "insights": []
53
+ }
54
+
55
+ def get_context_for_latex_specialist(self) -> str:
56
+ """
57
+ Generate prompt context for LaTeX Specialist agent.
58
+
59
+ Returns:
60
+ Formatted context string with historical learnings
61
+ """
62
+ if not self.patterns:
63
+ return ""
64
+
65
+ context_parts = []
66
+
67
+ # Add common fixes
68
+ if self.patterns.get("common_latex_fixes"):
69
+ context_parts.append("## Historical Patterns - Common LaTeX Issues\n")
70
+ context_parts.append("Based on analysis of previous documents, the following issues appear frequently:\n")
71
+
72
+ # Sort by frequency
73
+ fixes = sorted(
74
+ self.patterns["common_latex_fixes"].items(),
75
+ key=lambda x: x[1]["count"],
76
+ reverse=True
77
+ )
78
+
79
+ for fix, data in fixes[:10]: # Top 10
80
+ context_parts.append(f"- **{fix}** (seen {data['count']}x)")
81
+
82
+ context_parts.append("\nšŸ’” Consider checking for these issues proactively.\n")
83
+
84
+ # Add recurring recommendations
85
+ if self.patterns.get("recurring_issues"):
86
+ context_parts.append("\n## Recurring Recommendations\n")
87
+ context_parts.append("These suggestions have been made across multiple documents:\n")
88
+
89
+ for issue in self.patterns["recurring_issues"][:5]: # Top 5
90
+ context_parts.append(f"- {issue}")
91
+
92
+ context_parts.append("\nšŸ’” Pay special attention to these areas.\n")
93
+
94
+ # Add quality baseline
95
+ if self.patterns.get("quality_improvements"):
96
+ scores = [imp["score"] for imp in self.patterns["quality_improvements"]]
97
+ if scores:
98
+ avg_score = sum(scores) / len(scores)
99
+ max_score = max(scores)
100
+
101
+ context_parts.append(f"\n## Quality Baseline\n")
102
+ context_parts.append(f"- Average historical quality score: {avg_score:.1f}/100\n")
103
+ context_parts.append(f"- Best score achieved: {max_score}/100\n")
104
+ context_parts.append(f"- Target for this document: {min(max_score + 5, 100)}/100\n")
105
+
106
+ return "\n".join(context_parts)
107
+
108
+ def get_context_for_content_editor(self) -> str:
109
+ """
110
+ Generate prompt context for Content Editor agent.
111
+
112
+ Returns:
113
+ Formatted context string with historical learnings
114
+ """
115
+ if not self.patterns:
116
+ return ""
117
+
118
+ context_parts = []
119
+
120
+ # Add recurring content issues (if we track them in the future)
121
+ if self.patterns.get("recurring_issues"):
122
+ # Filter for content-related issues
123
+ content_issues = [
124
+ issue for issue in self.patterns["recurring_issues"]
125
+ if any(keyword in issue.lower() for keyword in ["readability", "grammar", "style", "clarity"])
126
+ ]
127
+
128
+ if content_issues:
129
+ context_parts.append("## Historical Patterns - Content Issues\n")
130
+ context_parts.append("Based on previous content reviews:\n")
131
+
132
+ for issue in content_issues[:5]:
133
+ context_parts.append(f"- {issue}")
134
+
135
+ context_parts.append("\nšŸ’” Focus on these areas during review.\n")
136
+
137
+ # Add quality expectations
138
+ if self.patterns.get("quality_improvements"):
139
+ scores = [imp["score"] for imp in self.patterns["quality_improvements"]]
140
+ if scores:
141
+ avg_score = sum(scores) / len(scores)
142
+ context_parts.append(f"\n## Quality Expectations\n")
143
+ context_parts.append(f"Previous documents achieved an average quality of {avg_score:.1f}/100.\n")
144
+ context_parts.append(f"Aim for content that will support or exceed this quality level.\n")
145
+
146
+ return "\n".join(context_parts)
147
+
148
+ def get_context_for_visual_qa(self) -> str:
149
+ """
150
+ Generate prompt context for Visual QA agent.
151
+
152
+ Returns:
153
+ Formatted context string with historical learnings
154
+ """
155
+ if not self.patterns:
156
+ return ""
157
+
158
+ context_parts = []
159
+
160
+ # Add visual-specific recurring issues
161
+ if self.patterns.get("recurring_issues"):
162
+ visual_issues = [
163
+ issue for issue in self.patterns["recurring_issues"]
164
+ if any(keyword in issue.lower() for keyword in ["typography", "spacing", "layout", "formatting"])
165
+ ]
166
+
167
+ if visual_issues:
168
+ context_parts.append("## Historical Patterns - Visual Issues\n")
169
+ context_parts.append("These visual/formatting issues have been identified before:\n")
170
+
171
+ for issue in visual_issues[:5]:
172
+ context_parts.append(f"- {issue}")
173
+
174
+ context_parts.append("\nšŸ’” Check carefully for these in the PDF analysis.\n")
175
+
176
+ return "\n".join(context_parts)
177
+
178
+ def get_context_for_author(self) -> str:
179
+ """
180
+ Generate prompt context for Author/Research agent.
181
+
182
+ Returns:
183
+ Formatted context string with historical learnings
184
+ """
185
+ if not self.patterns:
186
+ return ""
187
+
188
+ context_parts = []
189
+
190
+ # Add general quality insights
191
+ if self.patterns.get("insights"):
192
+ context_parts.append("## Document Generation Insights\n")
193
+
194
+ for insight in self.patterns["insights"][:3]:
195
+ context_parts.append(f"**{insight['title']}:**")
196
+ context_parts.append(f"{insight['description']}")
197
+ context_parts.append(f"šŸ’” {insight['recommendation']}\n")
198
+
199
+ return "\n".join(context_parts)
200
+
201
+ def get_summary(self) -> str:
202
+ """
203
+ Get a brief summary of available patterns.
204
+
205
+ Returns:
206
+ Summary string
207
+ """
208
+ if not self.patterns or not self.patterns_file.exists():
209
+ return f"No learned patterns available yet for document type: {self.document_type}"
210
+
211
+ metadata = self.patterns.get("metadata", {})
212
+ num_fixes = len(self.patterns.get("common_latex_fixes", {}))
213
+ num_issues = len(self.patterns.get("recurring_issues", []))
214
+ num_insights = len(self.patterns.get("insights", []))
215
+
216
+ return (
217
+ f"Learned patterns for '{self.document_type}' from {metadata.get('documents_analyzed', 0)} documents:\n"
218
+ f" - {num_fixes} common LaTeX fixes\n"
219
+ f" - {num_issues} recurring recommendations\n"
220
+ f" - {num_insights} actionable insights"
221
+ )
222
+
223
+
224
+ def demo():
225
+ """Demonstrate pattern injection."""
226
+ print("\n" + "=" * 60)
227
+ print("🧠 Pattern Injector - Demonstration")
228
+ print("=" * 60)
229
+
230
+ injector = PatternInjector()
231
+
232
+ print("\n" + injector.get_summary())
233
+
234
+ print("\n" + "=" * 60)
235
+ print("šŸ“ Context for LaTeX Specialist:")
236
+ print("=" * 60)
237
+ print(injector.get_context_for_latex_specialist())
238
+
239
+ print("\n" + "=" * 60)
240
+ print("šŸ‘ļø Context for Visual QA:")
241
+ print("=" * 60)
242
+ print(injector.get_context_for_visual_qa())
243
+
244
+ print("\n" + "=" * 60)
245
+ print("āœ… Pattern injection ready!")
246
+ print("=" * 60)
247
+
248
+
249
+ if __name__ == "__main__":
250
+ demo()