clearai-dsh 0.1.0
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.
- package/CHANGELOG.md +26 -0
- package/LICENSE +201 -0
- package/README.md +138 -0
- package/README.zh-CN.md +138 -0
- package/bin/clearai.mjs +224 -0
- package/brand/README.md +41 -0
- package/brand/logo-512-dark.png +0 -0
- package/brand/logo-512.png +0 -0
- package/brand/logo-lockup-dark.png +0 -0
- package/brand/logo-lockup.png +0 -0
- package/brand/logo-lockup.svg +12 -0
- package/brand/logo-wordmark.svg +6 -0
- package/brand/logo.svg +19 -0
- package/cordis.patch.yml +39 -0
- package/lib/client.js +3071 -0
- package/lib/fold.js +1576 -0
- package/lib/host.js +605 -0
- package/package.json +65 -0
- package/presets/clearai/agent.cordis.yml +226 -0
- package/presets/clearai/plugins/brain.js +547 -0
- package/presets/clearai/plugins/clearai-kernel.js +5485 -0
- package/presets/clearai/plugins/ontology.js +306 -0
- package/presets/clearai/plugins/prompts.js +312 -0
- package/presets/clearai/preset.yml +5 -0
- package/presets/clearai/skills/clearai-loop/SKILL.md +89 -0
- package/presets/clearai/template/knowledge/README.md +25 -0
- package/presets/clearai/template/memory/README.md +34 -0
- package/presets/clearai/template/project.md +49 -0
- package/presets/clearai/template/skills/README.md +37 -0
- package/presets/clearai/template/skills/chart-diagram-qa/SKILL.md +43 -0
- package/presets/clearai/template/skills/citation-management/SKILL.md +73 -0
- package/presets/clearai/template/skills/citation-management/references/bibtex_formatting.md +908 -0
- package/presets/clearai/template/skills/citation-management/references/citation_validation.md +794 -0
- package/presets/clearai/template/skills/citation-management/references/google_scholar_search.md +725 -0
- package/presets/clearai/template/skills/citation-management/references/metadata_extraction.md +870 -0
- package/presets/clearai/template/skills/citation-management/references/pubmed_search.md +839 -0
- package/presets/clearai/template/skills/citation-management/scripts/doi_to_bibtex.py +204 -0
- package/presets/clearai/template/skills/citation-management/scripts/extract_metadata.py +569 -0
- package/presets/clearai/template/skills/citation-management/scripts/format_bibtex.py +349 -0
- package/presets/clearai/template/skills/citation-management/scripts/generate_schematic.py +139 -0
- package/presets/clearai/template/skills/citation-management/scripts/generate_schematic_ai.py +817 -0
- package/presets/clearai/template/skills/citation-management/scripts/search_google_scholar.py +282 -0
- package/presets/clearai/template/skills/citation-management/scripts/search_pubmed.py +398 -0
- package/presets/clearai/template/skills/citation-management/scripts/validate_citations.py +497 -0
- package/presets/clearai/template/skills/data-analysis/SKILL.md +92 -0
- package/presets/clearai/template/skills/data-analysis/checklists/readiness_check.md +23 -0
- package/presets/clearai/template/skills/data-analysis/templates/analysis_report.md.tpl +63 -0
- package/presets/clearai/template/skills/data-analysis/templates/cleaning_rules_draft.yaml.tpl +32 -0
- package/presets/clearai/template/skills/data-analysis/templates/data_dictionary.md.tpl +12 -0
- package/presets/clearai/template/skills/data-analysis/templates/domain_knowledge_template.md.tpl +316 -0
- package/presets/clearai/template/skills/data-analysis/templates/feature_candidates.json.tpl +20 -0
- package/presets/clearai/template/skills/data-analysis/templates/quality_scorecard.md.tpl +30 -0
- package/presets/clearai/template/skills/data-analysis/workflows/01-data-profiling.md +42 -0
- package/presets/clearai/template/skills/data-analysis/workflows/02-quality-audit.md +36 -0
- package/presets/clearai/template/skills/data-analysis/workflows/03-physical-correlation.md +25 -0
- package/presets/clearai/template/skills/data-analysis/workflows/04-unstructured-mining.md +26 -0
- package/presets/clearai/template/skills/data-qa-analysis/SKILL.md +102 -0
- package/presets/clearai/template/skills/data-qa-analysis/checklists/readiness_check.md +62 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/best_in_class_report.md.tpl +56 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/cleaning_rules_draft.yaml.tpl +56 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/data_dictionary.md.tpl +13 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/data_source_inventory_and_lineage.md.tpl +146 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/data_status_report.md.tpl +60 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/steady_state_rules.yaml.tpl +41 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/subsystem_registry.md.tpl +101 -0
- package/presets/clearai/template/skills/data-qa-analysis/templates/unified_execution_plan.md.tpl +100 -0
- package/presets/clearai/template/skills/data-qa-analysis/workflows/01-data-source-inventory-and-lineage.md +194 -0
- package/presets/clearai/template/skills/data-qa-analysis/workflows/02-data-alignment-and-tag-semantics.md +122 -0
- package/presets/clearai/template/skills/data-qa-analysis/workflows/03-steady-state-identification.md +126 -0
- package/presets/clearai/template/skills/data-qa-analysis/workflows/04-consumption-analysis.md +152 -0
- package/presets/clearai/template/skills/data-qa-analysis/workflows/05-best-in-class-and-optimization-space.md +78 -0
- package/presets/clearai/template/skills/domain-presearch/SKILL.md +131 -0
- package/presets/clearai/template/skills/domain-presearch/checklists/domain_checklist.md +24 -0
- package/presets/clearai/template/skills/domain-presearch/references/figure_code.md +78 -0
- package/presets/clearai/template/skills/domain-presearch/references/strategic_frameworks.md +38 -0
- package/presets/clearai/template/skills/exploration-loop/SKILL.md +81 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/SKILL.md +77 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/references/bioinformatics_genomics_formats.md +664 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/references/chemistry_molecular_formats.md +664 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/references/general_scientific_formats.md +518 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/references/microscopy_imaging_formats.md +620 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/references/proteomics_metabolomics_formats.md +517 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/references/spectroscopy_analytical_formats.md +633 -0
- package/presets/clearai/template/skills/exploratory-data-analysis/scripts/eda_analyzer.py +547 -0
- package/presets/clearai/template/skills/hypothesis-generation/SKILL.md +73 -0
- package/presets/clearai/template/skills/hypothesis-generation/references/experimental_design_patterns.md +329 -0
- package/presets/clearai/template/skills/hypothesis-generation/references/hypothesis_quality_criteria.md +198 -0
- package/presets/clearai/template/skills/hypothesis-generation/references/literature_search_strategies.md +622 -0
- package/presets/clearai/template/skills/hypothesis-generation/scripts/generate_schematic.py +139 -0
- package/presets/clearai/template/skills/hypothesis-generation/scripts/generate_schematic_ai.py +817 -0
- package/presets/clearai/template/skills/literature-review/SKILL.md +72 -0
- package/presets/clearai/template/skills/literature-review/references/citation_styles.md +166 -0
- package/presets/clearai/template/skills/literature-review/references/database_strategies.md +455 -0
- package/presets/clearai/template/skills/literature-review/scripts/generate_pdf.py +176 -0
- package/presets/clearai/template/skills/literature-review/scripts/generate_schematic.py +139 -0
- package/presets/clearai/template/skills/literature-review/scripts/generate_schematic_ai.py +817 -0
- package/presets/clearai/template/skills/literature-review/scripts/search_databases.py +303 -0
- package/presets/clearai/template/skills/literature-review/scripts/verify_citations.py +221 -0
- package/presets/clearai/template/skills/paper-lookup/SKILL.md +59 -0
- package/presets/clearai/template/skills/paper-lookup/references/arxiv.md +161 -0
- package/presets/clearai/template/skills/paper-lookup/references/biorxiv.md +118 -0
- package/presets/clearai/template/skills/paper-lookup/references/core.md +150 -0
- package/presets/clearai/template/skills/paper-lookup/references/crossref.md +181 -0
- package/presets/clearai/template/skills/paper-lookup/references/medrxiv.md +104 -0
- package/presets/clearai/template/skills/paper-lookup/references/openalex.md +174 -0
- package/presets/clearai/template/skills/paper-lookup/references/pmc.md +152 -0
- package/presets/clearai/template/skills/paper-lookup/references/pubmed.md +124 -0
- package/presets/clearai/template/skills/paper-lookup/references/semantic-scholar.md +203 -0
- package/presets/clearai/template/skills/paper-lookup/references/unpaywall.md +127 -0
- package/presets/clearai/template/skills/process-presearch/SKILL.md +196 -0
- package/presets/clearai/template/skills/process-presearch/checklists/process_checklist.md +18 -0
- package/presets/clearai/template/skills/process-presearch/references/figure_code.md +107 -0
- package/presets/clearai/template/skills/process-presearch/references/source_attribution_example.md +22 -0
- package/presets/clearai/template/skills/process-understanding-extraction/SKILL.md +69 -0
- package/presets/clearai/template/skills/process-understanding-extraction/checklists/readiness_check.md +34 -0
- package/presets/clearai/template/skills/process-understanding-extraction/templates/docx_raw_dump_extractor.py.tpl +132 -0
- package/presets/clearai/template/skills/process-understanding-extraction/templates/entity_map_unit_topology.json.tpl +86 -0
- package/presets/clearai/template/skills/process-understanding-extraction/templates/process_brief.md.tpl +89 -0
- package/presets/clearai/template/skills/process-understanding-extraction/templates/process_brief_builder_from_raw_dump.py.tpl +203 -0
- package/presets/clearai/template/skills/process-understanding-extraction/templates/process_flow_mermaid.md.tpl +41 -0
- package/presets/clearai/template/skills/process-understanding-extraction/templates/unified_execution_plan.md.tpl +53 -0
- package/presets/clearai/template/skills/process-understanding-extraction/workflows/01-process-doc-discovery.md +173 -0
- package/presets/clearai/template/skills/process-understanding-extraction/workflows/02-process-understanding-and-diagramming.md +106 -0
- package/presets/clearai/template/skills/scientific-brainstorming/SKILL.md +64 -0
- package/presets/clearai/template/skills/scientific-brainstorming/references/brainstorming_methods.md +326 -0
- package/presets/clearai/template/skills/scientific-critical-thinking/SKILL.md +72 -0
- package/presets/clearai/template/skills/scientific-critical-thinking/references/common_biases.md +364 -0
- package/presets/clearai/template/skills/scientific-critical-thinking/references/evidence_hierarchy.md +485 -0
- package/presets/clearai/template/skills/scientific-critical-thinking/references/experimental_design.md +496 -0
- package/presets/clearai/template/skills/scientific-critical-thinking/references/logical_fallacies.md +478 -0
- package/presets/clearai/template/skills/scientific-critical-thinking/references/scientific_method.md +169 -0
- package/presets/clearai/template/skills/scientific-critical-thinking/references/statistical_pitfalls.md +506 -0
- package/presets/clearai/template/skills/skill-creator/SKILL.md +109 -0
- package/presets/clearai/template/skills/skill-creator/references/authoring-guide.md +89 -0
- package/presets/clearai/template/skills/statistical-analysis/SKILL.md +79 -0
- package/presets/clearai/template/skills/statistical-analysis/references/assumptions_and_diagnostics.md +369 -0
- package/presets/clearai/template/skills/statistical-analysis/references/bayesian_statistics.md +653 -0
- package/presets/clearai/template/skills/statistical-analysis/references/effect_sizes_and_power.md +578 -0
- package/presets/clearai/template/skills/statistical-analysis/references/reporting_standards.md +469 -0
- package/presets/clearai/template/skills/statistical-analysis/references/test_selection_guide.md +129 -0
- package/presets/clearai/template/skills/statistical-analysis/scripts/assumption_checks.py +538 -0
- package/presets/clearai/template/skills/web-artifact/SKILL.md +165 -0
- package/presets/clearai/template/skills/web-artifact/assets/renderer/renderer.css +229 -0
- package/presets/clearai/template/skills/web-artifact/assets/renderer/renderer.js +373 -0
- package/presets/clearai/template/skills/web-artifact/assets/vendor/elkjs/LICENSE +263 -0
- package/presets/clearai/template/skills/web-artifact/assets/vendor/elkjs/UPSTREAM.md +26 -0
- package/presets/clearai/template/skills/web-artifact/assets/vendor/elkjs/elk.bundled.js +6605 -0
- package/presets/clearai/template/skills/web-artifact/references/when-drawing-a-topology.md +150 -0
- package/presets/clearai/template/skills/web-artifact/references/when-the-page-must-work-offline.md +62 -0
- package/presets/clearai/template/skills/web-artifact/scripts/check_artifact.py +167 -0
- package/presets/clearai/template/skills/web-artifact/scripts/render_topology.js +272 -0
- package/presets/clearai/template/skills/what-if-oracle/LICENSE.txt +5 -0
- package/presets/clearai/template/skills/what-if-oracle/SKILL.md +72 -0
- package/presets/clearai/template/skills/what-if-oracle/references/scenario-templates.md +154 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
PDF Generation Script for Literature Reviews
|
|
4
|
+
Converts markdown files to professionally formatted PDFs with proper styling.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
import os
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
def generate_pdf(
|
|
13
|
+
markdown_file: str,
|
|
14
|
+
output_pdf: str = None,
|
|
15
|
+
citation_style: str = "apa",
|
|
16
|
+
template: str = None,
|
|
17
|
+
toc: bool = True,
|
|
18
|
+
number_sections: bool = True
|
|
19
|
+
) -> bool:
|
|
20
|
+
"""
|
|
21
|
+
Generate a PDF from a markdown file using pandoc.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
markdown_file: Path to the markdown file
|
|
25
|
+
output_pdf: Path for output PDF (defaults to same name as markdown)
|
|
26
|
+
citation_style: Citation style (apa, nature, chicago, etc.)
|
|
27
|
+
template: Path to custom LaTeX template
|
|
28
|
+
toc: Include table of contents
|
|
29
|
+
number_sections: Number the sections
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
True if successful, False otherwise
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
# Verify markdown file exists
|
|
36
|
+
if not os.path.exists(markdown_file):
|
|
37
|
+
print(f"Error: Markdown file not found: {markdown_file}")
|
|
38
|
+
return False
|
|
39
|
+
|
|
40
|
+
# Set default output path
|
|
41
|
+
if output_pdf is None:
|
|
42
|
+
output_pdf = Path(markdown_file).with_suffix('.pdf')
|
|
43
|
+
|
|
44
|
+
# Check if pandoc is installed
|
|
45
|
+
try:
|
|
46
|
+
subprocess.run(['pandoc', '--version'], capture_output=True, check=True)
|
|
47
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
48
|
+
print("Error: pandoc is not installed.")
|
|
49
|
+
print("Install with: brew install pandoc (macOS) or apt-get install pandoc (Linux)")
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
# Build pandoc command
|
|
53
|
+
cmd = [
|
|
54
|
+
'pandoc',
|
|
55
|
+
markdown_file,
|
|
56
|
+
'-o', str(output_pdf),
|
|
57
|
+
'--pdf-engine=xelatex', # Better Unicode support
|
|
58
|
+
'-V', 'geometry:margin=1in',
|
|
59
|
+
'-V', 'fontsize=11pt',
|
|
60
|
+
'-V', 'colorlinks=true',
|
|
61
|
+
'-V', 'linkcolor=blue',
|
|
62
|
+
'-V', 'urlcolor=blue',
|
|
63
|
+
'-V', 'citecolor=blue',
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
# Add table of contents
|
|
67
|
+
if toc:
|
|
68
|
+
cmd.extend(['--toc', '--toc-depth=3'])
|
|
69
|
+
|
|
70
|
+
# Add section numbering
|
|
71
|
+
if number_sections:
|
|
72
|
+
cmd.append('--number-sections')
|
|
73
|
+
|
|
74
|
+
# Add citation processing if bibliography exists
|
|
75
|
+
bib_file = Path(markdown_file).with_suffix('.bib')
|
|
76
|
+
if bib_file.exists():
|
|
77
|
+
cmd.extend([
|
|
78
|
+
'--citeproc',
|
|
79
|
+
'--bibliography', str(bib_file),
|
|
80
|
+
'--csl', f'{citation_style}.csl' if not citation_style.endswith('.csl') else citation_style
|
|
81
|
+
])
|
|
82
|
+
|
|
83
|
+
# Add custom template if provided
|
|
84
|
+
if template and os.path.exists(template):
|
|
85
|
+
cmd.extend(['--template', template])
|
|
86
|
+
|
|
87
|
+
# Execute pandoc
|
|
88
|
+
try:
|
|
89
|
+
print(f"Generating PDF: {output_pdf}")
|
|
90
|
+
print(f"Command: {' '.join(cmd)}")
|
|
91
|
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
|
92
|
+
print(f"✓ PDF generated successfully: {output_pdf}")
|
|
93
|
+
return True
|
|
94
|
+
except subprocess.CalledProcessError as e:
|
|
95
|
+
print(f"Error generating PDF:")
|
|
96
|
+
print(f"STDOUT: {e.stdout}")
|
|
97
|
+
print(f"STDERR: {e.stderr}")
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
def check_dependencies():
|
|
101
|
+
"""Check if required dependencies are installed."""
|
|
102
|
+
dependencies = {
|
|
103
|
+
'pandoc': 'pandoc --version',
|
|
104
|
+
'xelatex': 'xelatex --version'
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
missing = []
|
|
108
|
+
for name, cmd in dependencies.items():
|
|
109
|
+
try:
|
|
110
|
+
subprocess.run(cmd.split(), capture_output=True, check=True)
|
|
111
|
+
print(f"✓ {name} is installed")
|
|
112
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
113
|
+
print(f"✗ {name} is NOT installed")
|
|
114
|
+
missing.append(name)
|
|
115
|
+
|
|
116
|
+
if missing:
|
|
117
|
+
print("\n" + "="*60)
|
|
118
|
+
print("Missing dependencies:")
|
|
119
|
+
for dep in missing:
|
|
120
|
+
if dep == 'pandoc':
|
|
121
|
+
print(" - pandoc: brew install pandoc (macOS) or apt-get install pandoc (Linux)")
|
|
122
|
+
elif dep == 'xelatex':
|
|
123
|
+
print(" - xelatex: brew install --cask mactex (macOS) or apt-get install texlive-xetex (Linux)")
|
|
124
|
+
return False
|
|
125
|
+
|
|
126
|
+
return True
|
|
127
|
+
|
|
128
|
+
def main():
|
|
129
|
+
"""Command-line interface."""
|
|
130
|
+
if len(sys.argv) < 2:
|
|
131
|
+
print("Usage: python generate_pdf.py <markdown_file> [output_pdf] [--citation-style STYLE]")
|
|
132
|
+
print("\nOptions:")
|
|
133
|
+
print(" --citation-style STYLE Citation style (default: apa)")
|
|
134
|
+
print(" --no-toc Disable table of contents")
|
|
135
|
+
print(" --no-numbers Disable section numbering")
|
|
136
|
+
print(" --check-deps Check if dependencies are installed")
|
|
137
|
+
sys.exit(1)
|
|
138
|
+
|
|
139
|
+
# Check dependencies mode
|
|
140
|
+
if '--check-deps' in sys.argv:
|
|
141
|
+
check_dependencies()
|
|
142
|
+
sys.exit(0)
|
|
143
|
+
|
|
144
|
+
# Parse arguments
|
|
145
|
+
markdown_file = sys.argv[1]
|
|
146
|
+
output_pdf = sys.argv[2] if len(sys.argv) > 2 and not sys.argv[2].startswith('--') else None
|
|
147
|
+
|
|
148
|
+
citation_style = 'apa'
|
|
149
|
+
toc = True
|
|
150
|
+
number_sections = True
|
|
151
|
+
|
|
152
|
+
# Parse optional flags
|
|
153
|
+
if '--citation-style' in sys.argv:
|
|
154
|
+
idx = sys.argv.index('--citation-style')
|
|
155
|
+
if idx + 1 < len(sys.argv):
|
|
156
|
+
citation_style = sys.argv[idx + 1]
|
|
157
|
+
|
|
158
|
+
if '--no-toc' in sys.argv:
|
|
159
|
+
toc = False
|
|
160
|
+
|
|
161
|
+
if '--no-numbers' in sys.argv:
|
|
162
|
+
number_sections = False
|
|
163
|
+
|
|
164
|
+
# Generate PDF
|
|
165
|
+
success = generate_pdf(
|
|
166
|
+
markdown_file,
|
|
167
|
+
output_pdf,
|
|
168
|
+
citation_style=citation_style,
|
|
169
|
+
toc=toc,
|
|
170
|
+
number_sections=number_sections
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
sys.exit(0 if success else 1)
|
|
174
|
+
|
|
175
|
+
if __name__ == "__main__":
|
|
176
|
+
main()
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Scientific schematic generation using Nano Banana 2.
|
|
4
|
+
|
|
5
|
+
Generate any scientific diagram by describing it in natural language.
|
|
6
|
+
Nano Banana 2 handles everything automatically with smart iterative refinement.
|
|
7
|
+
|
|
8
|
+
Smart iteration: Only regenerates if quality is below threshold for your document type.
|
|
9
|
+
Quality review: Uses Gemini 3.1 Pro Preview for professional scientific evaluation.
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
# Generate for journal paper (highest quality threshold)
|
|
13
|
+
python generate_schematic.py "CONSORT flowchart" -o flowchart.png --doc-type journal
|
|
14
|
+
|
|
15
|
+
# Generate for presentation (lower threshold, faster)
|
|
16
|
+
python generate_schematic.py "Transformer architecture" -o transformer.png --doc-type presentation
|
|
17
|
+
|
|
18
|
+
# Generate for poster
|
|
19
|
+
python generate_schematic.py "MAPK signaling pathway" -o pathway.png --doc-type poster
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
import argparse
|
|
23
|
+
import os
|
|
24
|
+
import subprocess
|
|
25
|
+
import sys
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def main():
|
|
30
|
+
"""Command-line interface."""
|
|
31
|
+
parser = argparse.ArgumentParser(
|
|
32
|
+
description="Generate scientific schematics using AI with smart iterative refinement",
|
|
33
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
34
|
+
epilog="""
|
|
35
|
+
How it works:
|
|
36
|
+
Simply describe your diagram in natural language
|
|
37
|
+
Nano Banana 2 generates it automatically with:
|
|
38
|
+
- Smart iteration (only regenerates if quality is below threshold)
|
|
39
|
+
- Quality review by Gemini 3.1 Pro Preview
|
|
40
|
+
- Document-type aware quality thresholds
|
|
41
|
+
- Publication-ready output
|
|
42
|
+
|
|
43
|
+
Document Types (quality thresholds):
|
|
44
|
+
journal 8.5/10 - Nature, Science, peer-reviewed journals
|
|
45
|
+
conference 8.0/10 - Conference papers
|
|
46
|
+
thesis 8.0/10 - Dissertations, theses
|
|
47
|
+
grant 8.0/10 - Grant proposals
|
|
48
|
+
preprint 7.5/10 - arXiv, bioRxiv, etc.
|
|
49
|
+
report 7.5/10 - Technical reports
|
|
50
|
+
poster 7.0/10 - Academic posters
|
|
51
|
+
presentation 6.5/10 - Slides, talks
|
|
52
|
+
default 7.5/10 - General purpose
|
|
53
|
+
|
|
54
|
+
Examples:
|
|
55
|
+
# Generate for journal paper (strict quality)
|
|
56
|
+
python generate_schematic.py "CONSORT participant flow" -o flowchart.png --doc-type journal
|
|
57
|
+
|
|
58
|
+
# Generate for poster (moderate quality)
|
|
59
|
+
python generate_schematic.py "Transformer architecture" -o arch.png --doc-type poster
|
|
60
|
+
|
|
61
|
+
# Generate for slides (faster, lower threshold)
|
|
62
|
+
python generate_schematic.py "System diagram" -o system.png --doc-type presentation
|
|
63
|
+
|
|
64
|
+
# Custom max iterations
|
|
65
|
+
python generate_schematic.py "Complex pathway" -o pathway.png --iterations 2
|
|
66
|
+
|
|
67
|
+
# Verbose output
|
|
68
|
+
python generate_schematic.py "Circuit diagram" -o circuit.png -v
|
|
69
|
+
|
|
70
|
+
Environment Variables:
|
|
71
|
+
OPENROUTER_API_KEY Required for AI generation
|
|
72
|
+
"""
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
parser.add_argument("prompt",
|
|
76
|
+
help="Description of the diagram to generate")
|
|
77
|
+
parser.add_argument("-o", "--output", required=True,
|
|
78
|
+
help="Output file path")
|
|
79
|
+
parser.add_argument("--doc-type", default="default",
|
|
80
|
+
choices=["journal", "conference", "poster", "presentation",
|
|
81
|
+
"report", "grant", "thesis", "preprint", "default"],
|
|
82
|
+
help="Document type for quality threshold (default: default)")
|
|
83
|
+
parser.add_argument("--iterations", type=int, default=2,
|
|
84
|
+
help="Maximum refinement iterations (default: 2, max: 2)")
|
|
85
|
+
parser.add_argument("--api-key",
|
|
86
|
+
help="OpenRouter API key (or use OPENROUTER_API_KEY env var)")
|
|
87
|
+
parser.add_argument("-v", "--verbose", action="store_true",
|
|
88
|
+
help="Verbose output")
|
|
89
|
+
|
|
90
|
+
args = parser.parse_args()
|
|
91
|
+
|
|
92
|
+
# Check for API key
|
|
93
|
+
api_key = args.api_key or os.getenv("OPENROUTER_API_KEY")
|
|
94
|
+
if not api_key:
|
|
95
|
+
print("Error: OPENROUTER_API_KEY environment variable not set")
|
|
96
|
+
print("\nFor AI generation, you need an OpenRouter API key.")
|
|
97
|
+
print("Get one at: https://openrouter.ai/keys")
|
|
98
|
+
print("\nSet it with:")
|
|
99
|
+
print(" export OPENROUTER_API_KEY='your_api_key'")
|
|
100
|
+
print("\nOr use --api-key flag")
|
|
101
|
+
sys.exit(1)
|
|
102
|
+
|
|
103
|
+
# Find AI generation script
|
|
104
|
+
script_dir = Path(__file__).parent
|
|
105
|
+
ai_script = script_dir / "generate_schematic_ai.py"
|
|
106
|
+
|
|
107
|
+
if not ai_script.exists():
|
|
108
|
+
print(f"Error: AI generation script not found: {ai_script}")
|
|
109
|
+
sys.exit(1)
|
|
110
|
+
|
|
111
|
+
# Build command
|
|
112
|
+
cmd = [sys.executable, str(ai_script), args.prompt, "-o", args.output]
|
|
113
|
+
|
|
114
|
+
if args.doc_type != "default":
|
|
115
|
+
cmd.extend(["--doc-type", args.doc_type])
|
|
116
|
+
|
|
117
|
+
# Enforce max 2 iterations
|
|
118
|
+
iterations = min(args.iterations, 2)
|
|
119
|
+
if iterations != 2:
|
|
120
|
+
cmd.extend(["--iterations", str(iterations)])
|
|
121
|
+
|
|
122
|
+
if args.verbose:
|
|
123
|
+
cmd.append("-v")
|
|
124
|
+
|
|
125
|
+
# Execute — pass API key via environment to avoid exposure in process listings
|
|
126
|
+
try:
|
|
127
|
+
env = os.environ.copy()
|
|
128
|
+
if api_key:
|
|
129
|
+
env["OPENROUTER_API_KEY"] = api_key
|
|
130
|
+
result = subprocess.run(cmd, check=False, env=env)
|
|
131
|
+
sys.exit(result.returncode)
|
|
132
|
+
except Exception as e:
|
|
133
|
+
print(f"Error executing AI generation: {e}")
|
|
134
|
+
sys.exit(1)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
if __name__ == "__main__":
|
|
138
|
+
main()
|
|
139
|
+
|