QuickAgent / ValidationAgent /tools /GapIdentificationTool.py
varun324242's picture
Upload 20 files
eceb45a verified
from agency_swarm.tools import BaseTool
from pydantic import Field
import re
class GapIdentificationTool(BaseTool):
"""
This tool analyzes the report to find any logical gaps or inconsistencies in the data or narrative.
"""
report_content: str = Field(
..., description="The content of the report to be analyzed for logical gaps or inconsistencies."
)
def run(self):
"""
Analyzes the report content to identify logical gaps or inconsistencies in the data or narrative.
"""
# Define patterns or keywords that might indicate logical gaps or inconsistencies
gap_indicators = [
"however", "but", "although", "nevertheless", "in contrast", "on the other hand"
]
# Find sentences with potential logical gaps
potential_gaps = []
sentences = re.split(r'(?<=[.!?]) +', self.report_content)
for sentence in sentences:
if any(indicator in sentence for indicator in gap_indicators):
potential_gaps.append(sentence)
# Check for inconsistencies in data (e.g., conflicting numbers)
# This is a simple example using regex to find numbers
numbers = re.findall(r'\b\d+\b', self.report_content)
inconsistencies = []
if len(set(numbers)) != len(numbers):
inconsistencies.append("Conflicting numerical data found.")
# Compile the analysis results
analysis_results = {
"potential_gaps": potential_gaps,
"inconsistencies": inconsistencies
}
# Return the analysis results as a string
return f"Analysis Results: {analysis_results}"