Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,25 +22,7 @@ class BasicAgent:
|
|
| 22 |
except Exception as e:
|
| 23 |
print(f"Agent error: {e}")
|
| 24 |
return "I don't know."
|
| 25 |
-
|
| 26 |
-
def solve_math(self, question: str) -> str:
|
| 27 |
-
print(f"Solving math: {question}")
|
| 28 |
-
expression = self.extract_math_expression(question)
|
| 29 |
-
if not expression:
|
| 30 |
-
raise ValueError("No valid expression found.")
|
| 31 |
-
result = eval(expression)
|
| 32 |
-
return str(result)
|
| 33 |
-
|
| 34 |
-
def extract_math_expression(self, question: str) -> str:
|
| 35 |
-
expression = re.sub(r"[^0-9\.\+\-\*\/\(\)]", "", question)
|
| 36 |
-
return expression
|
| 37 |
-
|
| 38 |
-
def solve_date(self, question: str) -> str:
|
| 39 |
-
print(f"Solving date: {question}")
|
| 40 |
-
parsed_date = date_parser.parse(question, fuzzy=True)
|
| 41 |
-
weekday = calendar.day_name[parsed_date.weekday()]
|
| 42 |
-
return weekday
|
| 43 |
-
|
| 44 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 45 |
"""
|
| 46 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
|
| 22 |
except Exception as e:
|
| 23 |
print(f"Agent error: {e}")
|
| 24 |
return "I don't know."
|
| 25 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 27 |
"""
|
| 28 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|