from agency_swarm.tools import BaseTool from pydantic import Field import re class ReportReviewTool(BaseTool): """ This tool analyzes the content of draft reports, checking for completeness, accuracy, and quality. It identifies any missing sections or errors in the report. """ report_content: str = Field( ..., description="The content of the draft report to be analyzed." ) def run(self): """ Analyzes the report content for completeness, accuracy, and quality. Identifies missing sections or errors in the report. """ # Define the expected sections in a report expected_sections = [ "Introduction", "Methodology", "Results", "Discussion", "Conclusion" ] # Check for missing sections missing_sections = [ section for section in expected_sections if section not in self.report_content ] # Check for common errors (e.g., spelling mistakes) # This is a simple example using regex to find repeated words errors = re.findall(r'\b(\w+)\s+\1\b', self.report_content) # Check for quality (e.g., length of the report) quality_issues = [] if len(self.report_content.split()) < 500: quality_issues.append("The report is too short, consider adding more content.") # Compile the analysis results analysis_results = { "missing_sections": missing_sections, "errors": errors, "quality_issues": quality_issues } # Return the analysis results as a string return f"Analysis Results: {analysis_results}"