Spaces:
Sleeping
Sleeping
fix
Browse files
app.py
CHANGED
|
@@ -28,20 +28,19 @@ class TrickQuestionDetector(Tool):
|
|
| 28 |
"""Detects and handles trick questions"""
|
| 29 |
|
| 30 |
def __init__(self):
|
| 31 |
-
super().__init__(
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
fn=self.detect_trick
|
| 35 |
-
)
|
| 36 |
|
| 37 |
def detect_trick(self, question: str) -> str:
|
| 38 |
"""Detect common trick question patterns"""
|
| 39 |
q_lower = question.lower()
|
| 40 |
|
| 41 |
-
# Reverse text tricks
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
if
|
|
|
|
| 45 |
return f"TRICK DETECTED: This appears to be reversed text. Decoded: '{reversed_q}'"
|
| 46 |
|
| 47 |
# Word puzzles
|
|
@@ -63,11 +62,9 @@ class StepByStepReasoner(Tool):
|
|
| 63 |
"""Breaks down complex questions into steps"""
|
| 64 |
|
| 65 |
def __init__(self):
|
| 66 |
-
super().__init__(
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
fn=self.reason_steps
|
| 70 |
-
)
|
| 71 |
|
| 72 |
def reason_steps(self, question: str) -> str:
|
| 73 |
"""Break question into reasoning steps"""
|
|
@@ -98,11 +95,9 @@ class FactChecker(Tool):
|
|
| 98 |
"""Validates factual claims and provides confidence levels"""
|
| 99 |
|
| 100 |
def __init__(self):
|
| 101 |
-
super().__init__(
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
fn=self.check_facts
|
| 105 |
-
)
|
| 106 |
|
| 107 |
def check_facts(self, claim: str) -> str:
|
| 108 |
"""Assess factual accuracy of a claim"""
|
|
@@ -130,11 +125,9 @@ class AnswerValidator(Tool):
|
|
| 130 |
"""Validates if an answer makes sense for the question"""
|
| 131 |
|
| 132 |
def __init__(self):
|
| 133 |
-
super().__init__(
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
fn=self.validate_answer
|
| 137 |
-
)
|
| 138 |
|
| 139 |
def validate_answer(self, question: str, answer: str) -> str:
|
| 140 |
"""Check if answer is reasonable for the question"""
|
|
|
|
| 28 |
"""Detects and handles trick questions"""
|
| 29 |
|
| 30 |
def __init__(self):
|
| 31 |
+
super().__init__()
|
| 32 |
+
self.name = "trick_detector"
|
| 33 |
+
self.description = "Analyze if a question is a trick question and provide guidance"
|
|
|
|
|
|
|
| 34 |
|
| 35 |
def detect_trick(self, question: str) -> str:
|
| 36 |
"""Detect common trick question patterns"""
|
| 37 |
q_lower = question.lower()
|
| 38 |
|
| 39 |
+
# Reverse text tricks - check if question might be reversed
|
| 40 |
+
reversed_q = question[::-1]
|
| 41 |
+
if len(question) > 5 and any(c.isalpha() for c in question):
|
| 42 |
+
# Simple heuristic: if reversed version has common English patterns
|
| 43 |
+
if any(word in reversed_q.lower() for word in ['the', 'and', 'what', 'how', 'when', 'where']):
|
| 44 |
return f"TRICK DETECTED: This appears to be reversed text. Decoded: '{reversed_q}'"
|
| 45 |
|
| 46 |
# Word puzzles
|
|
|
|
| 62 |
"""Breaks down complex questions into steps"""
|
| 63 |
|
| 64 |
def __init__(self):
|
| 65 |
+
super().__init__()
|
| 66 |
+
self.name = "step_reasoner"
|
| 67 |
+
self.description = "Break down complex questions into logical steps"
|
|
|
|
|
|
|
| 68 |
|
| 69 |
def reason_steps(self, question: str) -> str:
|
| 70 |
"""Break question into reasoning steps"""
|
|
|
|
| 95 |
"""Validates factual claims and provides confidence levels"""
|
| 96 |
|
| 97 |
def __init__(self):
|
| 98 |
+
super().__init__()
|
| 99 |
+
self.name = "fact_checker"
|
| 100 |
+
self.description = "Check factual accuracy and provide confidence assessment"
|
|
|
|
|
|
|
| 101 |
|
| 102 |
def check_facts(self, claim: str) -> str:
|
| 103 |
"""Assess factual accuracy of a claim"""
|
|
|
|
| 125 |
"""Validates if an answer makes sense for the question"""
|
| 126 |
|
| 127 |
def __init__(self):
|
| 128 |
+
super().__init__()
|
| 129 |
+
self.name = "answer_validator"
|
| 130 |
+
self.description = "Validate if an answer is reasonable for the given question"
|
|
|
|
|
|
|
| 131 |
|
| 132 |
def validate_answer(self, question: str, answer: str) -> str:
|
| 133 |
"""Check if answer is reasonable for the question"""
|