Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
from
|
| 7 |
-
import calendar
|
| 8 |
-
import re
|
| 9 |
|
| 10 |
# (Keep Constants as is)
|
| 11 |
# --- Constants ---
|
|
@@ -15,27 +13,15 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 15 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 16 |
class BasicAgent:
|
| 17 |
def __init__(self):
|
| 18 |
-
print("Tool-
|
| 19 |
|
| 20 |
def __call__(self, question: str) -> str:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
except Exception as e:
|
| 28 |
-
print(f"[Math Error] {e}")
|
| 29 |
-
|
| 30 |
-
# 2. Datumsfragen erkennen
|
| 31 |
-
if "what day" in question_lower or "which day" in question_lower or "day of the week" in question_lower:
|
| 32 |
-
try:
|
| 33 |
-
return self.solve_date(question)
|
| 34 |
-
except Exception as e:
|
| 35 |
-
print(f"[Date Error] {e}")
|
| 36 |
-
|
| 37 |
-
# 3. Fallback
|
| 38 |
-
return "I don't know."
|
| 39 |
|
| 40 |
def solve_math(self, question: str) -> str:
|
| 41 |
print(f"Solving math: {question}")
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from agent import agent_executor
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
|
|
|
| 13 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 14 |
class BasicAgent:
|
| 15 |
def __init__(self):
|
| 16 |
+
print("LLM Tool-Enhanced Agent initialized.")
|
| 17 |
|
| 18 |
def __call__(self, question: str) -> str:
|
| 19 |
+
try:
|
| 20 |
+
result = agent_executor.run(question)
|
| 21 |
+
return result.strip()
|
| 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}")
|