modcomms/backend/app/agents/tone_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

34 lines
1.2 KiB
Python
Executable file

import asyncio
from typing import List, Tuple
from app.agents.base_agent import BaseAgent
from app.models.schemas import SubReview, RagStatus
class ToneAgent(BaseAgent):
"""
Tone Agent - STUB implementation.
Returns mock Green status. Full tone analysis requires implementation.
"""
name = "Tone Agent"
async def analyze(self, images: List[Tuple[bytes, str]]) -> SubReview:
"""
Stub implementation that returns mock Green status.
Args:
images: List of (file_data, mime_type) tuples (not used in stub)
Returns:
SubReview with Green status and stub notice
"""
# Simulate some processing time for realistic UX
await asyncio.sleep(0.5)
return SubReview(
ragStatus=RagStatus.GREEN,
feedback="[STUB] Tone of voice analysis passed. This is a placeholder response - the Tone Agent has not been implemented for this POC. The copy appears to demonstrate appropriate brand personality traits: Pioneering, Connected, Optimistic, and Professional. Full analysis of clarity, grammar, and brand voice alignment requires the complete implementation.",
issues=[]
)