modcomms/backend/app/agents/base_agent.py
michael c1030ee292 Add PDF rasterization support for reliable preview and analysis
PDFs are now converted to PNG images at 200 DPI before being sent to
Gemini for analysis. This fixes the unreliable iframe-based PDF preview
and ensures all pages are properly analyzed.

- Add PyMuPDF dependency for PDF rasterization
- Create pdf_service.py with rasterize() and get_page_count()
- Update agent interfaces to accept list of images for multi-page support
- Add analyze_with_images() to Gemini service for multi-image analysis
- Return rasterized PDF pages via WebSocket for frontend display
- Add page navigation UI for multi-page PDFs in preview components

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 09:36:56 -06:00

25 lines
731 B
Python
Executable file

from abc import ABC, abstractmethod
from typing import List, Tuple
from app.models.schemas import SubReview
class BaseAgent(ABC):
"""Abstract base class for all review agents."""
name: str = "Base Agent"
@abstractmethod
async def analyze(self, images: List[Tuple[bytes, str]]) -> SubReview:
"""
Analyze the proof and return a SubReview.
Args:
images: List of (file_data, mime_type) tuples representing the proof.
For single images/videos, this will contain one tuple.
For multi-page PDFs, this will contain one tuple per page.
Returns:
SubReview containing ragStatus, feedback, and issues
"""
pass