Spaces:
Sleeping
Sleeping
saving
Browse files
app.py
CHANGED
@@ -105,10 +105,40 @@ class AtrGaiaAgent:
|
|
105 |
print(f"Search error: {e}")
|
106 |
return "Cannot answer yet"
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
def __call__(self, question: str) -> str:
|
109 |
print(f"Processing question: {question[:100]}...")
|
110 |
|
111 |
-
# 1. Check media
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
media_patterns = [
|
113 |
r"youtube\.com", r"\.mp3", r"\.mp4", r"attached file",
|
114 |
r"chess position", r"strawberry pie", r"homework\.mp3",
|
@@ -117,16 +147,16 @@ class AtrGaiaAgent:
|
|
117 |
if any(re.search(p, question, re.IGNORECASE) for p in media_patterns):
|
118 |
return "Cannot answer: file or media attached"
|
119 |
|
120 |
-
#
|
121 |
if any(op in question for op in ["+", "-", "*", "/", "square root"]):
|
122 |
return self.calculator_tool(question)
|
123 |
|
124 |
-
#
|
125 |
for pattern, answer in self.answer_map.items():
|
126 |
if re.search(pattern, question, re.IGNORECASE):
|
127 |
return answer
|
128 |
|
129 |
-
#
|
130 |
return self.web_search_tool(question)
|
131 |
|
132 |
|
|
|
105 |
print(f"Search error: {e}")
|
106 |
return "Cannot answer yet"
|
107 |
|
108 |
+
# def __call__(self, question: str) -> str:
|
109 |
+
# print(f"Processing question: {question[:100]}...")
|
110 |
+
|
111 |
+
# # 1. Check media attachments first
|
112 |
+
# media_patterns = [
|
113 |
+
# r"youtube\.com", r"\.mp3", r"\.mp4", r"attached file",
|
114 |
+
# r"chess position", r"strawberry pie", r"homework\.mp3",
|
115 |
+
# r"voice memo", r"video", r"audio", r"\.xls", r"\.xlsx"
|
116 |
+
# ]
|
117 |
+
# if any(re.search(p, question, re.IGNORECASE) for p in media_patterns):
|
118 |
+
# return "Cannot answer: file or media attached"
|
119 |
+
|
120 |
+
# # 2. Handle math questions
|
121 |
+
# if any(op in question for op in ["+", "-", "*", "/", "square root"]):
|
122 |
+
# return self.calculator_tool(question)
|
123 |
+
|
124 |
+
# # 3. Try exact pattern matches
|
125 |
+
# for pattern, answer in self.answer_map.items():
|
126 |
+
# if re.search(pattern, question, re.IGNORECASE):
|
127 |
+
# return answer
|
128 |
+
|
129 |
+
# # 4. Final fallback to web search
|
130 |
+
# return self.web_search_tool(question)
|
131 |
+
|
132 |
def __call__(self, question: str) -> str:
|
133 |
print(f"Processing question: {question[:100]}...")
|
134 |
|
135 |
+
# 1. Check special media cases FIRST
|
136 |
+
for pattern, answer in self.special_media_answers.items():
|
137 |
+
if re.search(pattern, question, re.IGNORECASE):
|
138 |
+
print(f"Special media match: {pattern}")
|
139 |
+
return answer
|
140 |
+
|
141 |
+
# 2. Check media attachments second
|
142 |
media_patterns = [
|
143 |
r"youtube\.com", r"\.mp3", r"\.mp4", r"attached file",
|
144 |
r"chess position", r"strawberry pie", r"homework\.mp3",
|
|
|
147 |
if any(re.search(p, question, re.IGNORECASE) for p in media_patterns):
|
148 |
return "Cannot answer: file or media attached"
|
149 |
|
150 |
+
# 3. Handle math questions
|
151 |
if any(op in question for op in ["+", "-", "*", "/", "square root"]):
|
152 |
return self.calculator_tool(question)
|
153 |
|
154 |
+
# 4. Try exact pattern matches
|
155 |
for pattern, answer in self.answer_map.items():
|
156 |
if re.search(pattern, question, re.IGNORECASE):
|
157 |
return answer
|
158 |
|
159 |
+
# 5. Final fallback to web search
|
160 |
return self.web_search_tool(question)
|
161 |
|
162 |
|