| from typing import Dict, Any |
| from .base_agent import LLMAgent |
|
|
|
|
| class ContentValidationAgent(LLMAgent): |
| name = "content_validation_agent" |
| description = "Validates PDF content quality and integrity - checks for errors, inconsistencies, and completeness" |
|
|
| def build_prompt(self, text_data: Dict[str, Any]) -> str: |
| text = text_data.get("text", "")[:1500] |
| return f"""Validate the content quality of this PDF text: |
| |
| {text} |
| |
| Check for: |
| 1. Are there obvious OCR errors or garbage text? |
| 2. Is the content coherent and readable? |
| 3. Are there any missing sections or truncated text? |
| 4. Does the content match expectations for a PDF document? |
| 5. Any red flags suggesting corrupted or incomplete data? |
| |
| Provide a validation verdict with specific issues found.""" |
|
|
| def execute(self, text_data: Dict[str, Any], reasoning: str) -> Dict[str, Any]: |
| return { |
| "is_valid": "garbage" not in reasoning.lower() |
| and "corrupt" not in reasoning.lower(), |
| "validation_errors": self._extract_errors(reasoning), |
| "validated": True, |
| "confidence": 0.85, |
| "reasoning": reasoning, |
| } |
|
|
| def _extract_errors(self, reasoning: str) -> list: |
| errors = [] |
| if "garble" in reasoning.lower(): |
| errors.append("Potential OCR errors detected") |
| if "truncat" in reasoning.lower(): |
| errors.append("Content may be truncated") |
| return errors |
|
|