Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -65,15 +65,52 @@ class BasicAgent:
|
|
65 |
def handle_logic_riddles(self, question: str) -> str | None:
|
66 |
q = question.lower().strip()
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
return None
|
76 |
|
|
|
77 |
def __call__(self, question: str, video_path: str = None) -> str:
|
78 |
print(f"Agent received question: {question[:60]}...")
|
79 |
|
|
|
65 |
def handle_logic_riddles(self, question: str) -> str | None:
|
66 |
q = question.lower().strip()
|
67 |
|
68 |
+
logic_patterns = [
|
69 |
+
{
|
70 |
+
"pattern": r"opposite of the word ['\"]?left['\"]?",
|
71 |
+
"answer": "right"
|
72 |
+
},
|
73 |
+
{
|
74 |
+
"pattern": r"what comes after ['\"]?a['\"]?",
|
75 |
+
"answer": "b"
|
76 |
+
},
|
77 |
+
{
|
78 |
+
"pattern": r"first letter of the alphabet",
|
79 |
+
"answer": "a"
|
80 |
+
},
|
81 |
+
{
|
82 |
+
"pattern": r"what is the color of the clear sky",
|
83 |
+
"answer": "blue"
|
84 |
+
},
|
85 |
+
{
|
86 |
+
"pattern": r"how many sides does a triangle have",
|
87 |
+
"answer": "3"
|
88 |
+
},
|
89 |
+
{
|
90 |
+
"pattern": r"how many legs does a spider have",
|
91 |
+
"answer": "8"
|
92 |
+
},
|
93 |
+
{
|
94 |
+
"pattern": r"what is 2 \+ 2",
|
95 |
+
"answer": "4"
|
96 |
+
},
|
97 |
+
{
|
98 |
+
"pattern": r"what is the opposite of ['\"]?up['\"]?",
|
99 |
+
"answer": "down"
|
100 |
+
},
|
101 |
+
{
|
102 |
+
"pattern": r"if you understand this sentence.*opposite.*left",
|
103 |
+
"answer": "right"
|
104 |
+
}
|
105 |
+
]
|
106 |
+
|
107 |
+
for item in logic_patterns:
|
108 |
+
if re.search(item["pattern"], q):
|
109 |
+
return item["answer"]
|
110 |
|
111 |
return None
|
112 |
|
113 |
+
|
114 |
def __call__(self, question: str, video_path: str = None) -> str:
|
115 |
print(f"Agent received question: {question[:60]}...")
|
116 |
|