Skip to main content

output.pdf_generator

PDF output generator using the Jupyter sandbox.

Converts agent Markdown output → HTML (via Jinja2 template) → PDF (via WeasyPrint executed in the Jupyter sandbox kernel). The generated PDF is stored locally and can be uploaded to S3 user space.

PDFOutputGenerator Objects

class PDFOutputGenerator(BaseOutputGenerator)

Generate PDF output from agent results using the Jupyter sandbox.

The generation pipeline:

  1. Agent produces structured Markdown.
  2. Render Markdown → HTML using Jinja2 template.
  3. Execute HTML → PDF conversion via WeasyPrint in the Jupyter sandbox.
  4. Return the local file path (caller can upload to S3).

Parameters

template_path : str | None Path to a Jinja2 HTML template. If None, uses built-in default. sandbox_url : str URL of the Jupyter sandbox kernel gateway. output_dir : str Directory for storing generated PDFs.

generate

async def generate(agent_result: AgentResult) -> OutputArtifact

Convert agent output to PDF via the Jupyter sandbox.