Metadata-Version: 2.5
Name: autoreporter-ai
Version: 0.1.0
Summary: Offline-first LLM-driven publication-grade PDF report generator powered by Typst, Python charting, and curated design themes.
Project-URL: Homepage, https://github.com/MLResearch42/autoreporter
Project-URL: Repository, https://github.com/MLResearch42/autoreporter
Project-URL: Issues, https://github.com/MLResearch42/autoreporter/issues
Author: AutoReporter Contributors
License: MIT
License-File: LICENSE
Keywords: data-science,llm,pdf,reports,typst,visualization
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Requires-Dist: anthropic>=0.34.0
Requires-Dist: charset-normalizer>=3.0.0
Requires-Dist: matplotlib>=3.8.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: openai>=1.40.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: pillow>=10.0.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: seaborn>=0.13.0
Requires-Dist: typst<1.0.0,>=0.13.0
Provides-Extra: all-formats
Requires-Dist: openpyxl>=3.1.0; extra == 'all-formats'
Requires-Dist: pyarrow>=14.0.0; extra == 'all-formats'
Provides-Extra: dev
Requires-Dist: build>=1.2.0; extra == 'dev'
Requires-Dist: httpx>=0.27.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: python-dotenv>=1.0.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Requires-Dist: twine>=5.0.0; extra == 'dev'
Provides-Extra: excel
Requires-Dist: openpyxl>=3.1.0; extra == 'excel'
Provides-Extra: parquet
Requires-Dist: pyarrow>=14.0.0; extra == 'parquet'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/MLResearch42/autoreporter/main/assets/banner.png" alt="AutoReporter — Offline-first LLM-driven PDF report generator" width="100%" />
</p>

# AutoReporter

Drop in messy project files (spreadsheets, experiment logs, notes, or charts) and get back a **clean, magazine-quality PDF report** — built to work **100% offline** inside closed networks using **Python 3.10+**, **Typst**, and any **OpenAI- or Anthropic-compatible LLM**.

---

## How the AI Review Process Catches Errors & Hallucinations

Most AI PDF tools generate a draft in one shot and hope for the best. That leads to made-up numbers, broken charts, or ugly cut-off tables. AutoReporter runs a **check-your-own-work loop** before, during, and after drafting:

```text
Your Files ──▶ 1. Python Math & Charts ──▶ 2. AI Writes Draft ──▶ 3. Auto-Fix Compile Errors
                                                                           │
Final PDF ◀── Keep Highest-Scoring PDF ◀── 5. Patch & Rebuild ◀── 4. AI Reviews Page Pictures
```

1. **Real math first (stops made-up numbers):** Before the AI writes a single paragraph, Python scans your data and calculates the real stats (averages, ranges, missing values, correlations). Charts are plotted by real Python scripts from your actual files, and summary tables are saved as clean `.csv` files that Typst reads directly — so the AI never has to re-type big tables from memory.
2. **Automatic bug fixing (stops broken builds):** If a Python chart script crashes or the Typst layout has a syntax error, AutoReporter grabs the exact error message and line number and sends it right back to the AI to fix (up to 3–4 tries automatically).
3. **Post-draft Vision AI review (catches visual & factual slips):** After the draft PDF compiles, AutoReporter converts **every page into a PNG picture** and sends those page images — along with the draft source and report plan — *back* through a vision-capable AI acting as a strict editor. It checks for:
   - Tables or text overflowing off the page, or raw code symbols accidentally showing up
   - Overlapping chart labels, tiny unreadable text, or crowded axes
   - Awkward page breaks, giant blank gaps, or going over your page limit
   - Missing key findings or captions that don't match what's shown
4. **Targeted fixes + rollback safety net:** The reviewer scores the draft from 1 to 10 and lists concrete fixes. AutoReporter re-runs any flagged chart script, patches the layout, recompiles, and checks again (default: `2` rounds). It **always keeps the highest-scoring working PDF** — if a later edit fails to compile or accidentally deletes content, AutoReporter throws out the bad patch and keeps the best version.

---

## Compact Cheatsheet

### What You Can Pass In (`inputs`)
A single file, a list of files, a whole folder, or live Python objects:
- **Spreadsheets & data:** `.csv`, `.tsv`, `.parquet`, `.xlsx`, `pandas.DataFrame`
- **Notes & logs:** `.md`, `.txt`, `.log`, `.json`, `.jsonl`, Python `dict`, or raw text strings
- **Existing figures:** `.png`, `.jpg`, `.svg` (embedded directly into the report)

### Report Options (Python & CLI)

| Python (`generate_report`) | CLI (`autoreporter build`) | Default | What It Does (Plain English) |
| :--- | :--- | :--- | :--- |
| `inputs` | positional args | *(required)* | File(s), folder, DataFrame, or text to turn into a report |
| `prompt` | `-p`, `--prompt` | `None` | Optional instructions (e.g. *"Focus on what beat the baseline"*) |
| `theme` | `-t`, `--theme` | `"executive_board"` | Pick 1 of the 10 themes below, or `"auto"` to let the AI choose |
| `output_dir` / `output_filename` | `-o` / `--output-dir` | current dir | Where to save the PDF (auto-named from title if omitted) |
| `audience` | `--audience` | `"mixed"` | Who's reading: `"executive"`, `"technical"`, `"mixed"`, `"stakeholder"` |
| `tone` | `--tone` | theme default | Writing style tweak (e.g. `"formal"`, `"concise"`, `"persuasive"`) |
| `max_pages` | `--max-pages` | auto | Keep the report at or under this page count |
| `page_size` | `--page-size` | `"letter"` | `"letter"`, `"a4"`, or `"widescreen_16_9"` (slide-style deck) |
| `toc` | `--toc` | `"auto"` | Table of contents: `True`, `False`, or `"auto"` (on for 5+ pages) |
| `include_charts` | `--no-charts` | `True` | Generate matching Python SVG charts (`--no-charts` turns off) |
| `visual_qa_rounds` | `--qa-rounds` | `2` | How many post-draft AI review rounds to run (`0` skips review) |
| `save_intermediates` | `--save-intermediates` | `False` | Save `.typ`, chart scripts/SVGs, CSVs, and QA notes for manual edits |
| `dry_run` | `--dry-run` | `False` | Only build and print the outline plan — don't render the PDF yet |

### AI Connection & Branding Options

| Python (`LLMConfig` / `BrandingConfig`) | CLI Flag | Env Var Default | Plain-English Meaning |
| :--- | :--- | :--- | :--- |
| `provider` | `--provider` | `AUTOREPORTER_PROVIDER` | `"auto"`, `"openai"`, or `"anthropic"` (SDK to use) |
| `model` | `--model` | `AUTOREPORTER_MODEL` | Model name (e.g. `claude-opus-5-5`, `gpt-5.4`, `gemini-2.5-flash`) |
| `base_url` | `--base-url` | `AUTOREPORTER_BASE_URL` | Custom API URL (work gateway, Gemini, vLLM, LiteLLM) |
| `api_key` | `--api-key` | `AUTOREPORTER_API_KEY` | API key (also falls back to OpenAI/Anthropic/Gemini env vars) |
| `vision_model` | `--vision-model` | `AUTOREPORTER_VISION_MODEL` | Optional separate model just for the visual review step |
| `ca_bundle` / `verify_ssl` | `--ca-bundle` / `--insecure` | `AUTOREPORTER_CA_BUNDLE` | Corporate SSL certificate file for private networks |
| `temperature` / `max_tokens` | `--temperature` / `--max-tokens` | `0.3` / `8192` | Creativity vs. consistency, and max length per AI call |
| `title`, `author`, `organization` | `--title`, `--author`, `--org` | auto / `None` | Cover page, header, and footer metadata |
| `logo_path`, `classification` | `--logo`, `--classification` | `None` | Company logo + header/footer banner (e.g. `INTERNAL USE ONLY`) |

> **Offline-ready out of the box:** All 7 open-source font families and all 10 Typst themes are bundled inside the Python package. No internet downloads happen at runtime.

---

## Install & Quickstart

```bash
pip install autoreporter-ai
# Optional Parquet & Excel file support:
pip install "autoreporter-ai[all-formats]"
```

*(Installs as `autoreporter-ai` on PyPI; imports in Python as `import autoreporter` and provides the `autoreporter` CLI.)*

### Python (One Call)

```python
from autoreporter import BrandingConfig, LLMConfig, generate_report

result = generate_report(
    inputs=["experiments.txt", "metrics.csv", "findings.md"],
    prompt="Summarize why V3 beat V2 and call out any remaining risks.",
    theme="executive_board",   # or "auto"
    output_dir="./reports",
    output_filename="v3_eval.pdf",
    llm=LLMConfig(
        provider="anthropic",  # "auto" | "openai" | "anthropic"
        base_url="https://internal-llm.corp",
        model="claude-opus-5-5",
        api_key="...",         # or set AUTOREPORTER_API_KEY
    ),
    audience="executive",
    max_pages=6,
    visual_qa_rounds=2,        # AI reviews rendered page PNGs and fixes issues
    branding=BrandingConfig(
        author="Data Science Team",
        organization="Applied Research",
        classification="INTERNAL USE ONLY",
    ),
    save_intermediates=True,   # keep report.typ + SVGs if you want to tweak anything
)

print(result.pdf_path, result.page_count, result.qa_score)
```

### Using Gemini (OpenAI-Compatible Endpoint)

```python
llm = LLMConfig(
    provider="openai",
    base_url="https://generativelanguage.googleapis.com/v1beta/openai/",
    model="gemini-2.5-flash",  # or gemini-2.5-pro
    api_key="...",             # or set GEMINI_API_KEY / AUTOREPORTER_API_KEY
)
```

### Reuse Settings Across Multiple Reports

```python
from autoreporter import ReportGenerator

gen = ReportGenerator(
    provider="openai",
    base_url="https://internal-llm.corp/v1",
    model="gpt-5.4",
    default_theme="swiss_grid",
)
gen.generate("q4_metrics.csv", output_dir="./reports")
gen.generate(["ablation.txt", "notes.md"], theme="technical_monograph", output_dir="./reports")
```

### Command Line

```bash
autoreporter themes list
autoreporter build metrics.csv notes.md --theme swiss_grid --max-pages 5 -o report.pdf
```

---

## The 10 Built-In Design Themes

Every theme controls the page layout, fonts, colors, **and** chart colors automatically so charts look like they belong in the report.

| Theme ID | Look & Feel | Great For |
| :--- | :--- | :--- |
| `executive_board` | Deep navy cover, gold accents, clean KPI cards | Leadership briefings & annual reports |
| `swiss_grid` | Crisp white & black grid with bold red accents | Benchmarks & engineering audits |
| `technical_monograph` | Serif book style with wide margin sidenotes | ML experiments & research write-ups |
| `editorial_broadsheet` | Warm paper, serif headlines, burgundy & teal | Strategy memos & deep-dive essays |
| `modern_saas` | Clean indigo cards, generous whitespace | Tech product & platform reviews |
| `scientific_journal` | Forest teal, structured numbered figures | Lab results & statistical studies |
| `warm_atelier` | Ivory paper, terracotta & sage tones | Impact reports & design research |
| `nordic_minimal` | Extra-airy white, calm fjord blue & gray | Scorecards & clean executive briefs |
| `bold_magazine` | High-contrast dark title bands, bright amber | Demos, showcases & standout findings |
| `dark_telemetry` | Full dark mode with cyan & amber charts | On-screen briefings & monitoring |

---

## Development, Testing & Internal PyPI

```bash
# Offline unit, theme, and full 6-stage pipeline tests (55 tests)
pytest -m "not live"

# Live end-to-end test using Gemini (needs GEMINI_API_KEY or .env)
pytest tests/integration/test_live_gemini.py -m live -v -s

# Build self-contained wheel (includes all fonts & themes) and upload to private PyPI
python -m build
twine upload --repository-url https://pypi.internal.corp/simple/ dist/*
```
