Update app.py
#401
by UrielTorresPeralta - opened
app.py
CHANGED
|
@@ -10,14 +10,33 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 10 |
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
|
|
|
| 13 |
class BasicAgent:
|
| 14 |
def __init__(self):
|
| 15 |
-
print("
|
|
|
|
| 16 |
def __call__(self, question: str) -> str:
|
| 17 |
-
print(f"
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 23 |
"""
|
|
|
|
| 10 |
|
| 11 |
# --- Basic Agent Definition ---
|
| 12 |
# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
|
| 13 |
+
|
| 14 |
class BasicAgent:
|
| 15 |
def __init__(self):
|
| 16 |
+
print("✅ Smart Agent initialized.")
|
| 17 |
+
|
| 18 |
def __call__(self, question: str) -> str:
|
| 19 |
+
print(f"🧠 Question: {question[:80]}...")
|
| 20 |
+
|
| 21 |
+
# 🔹 Ejemplo: lógica muy simple (puedes mejorarla después)
|
| 22 |
+
question_lower = question.lower()
|
| 23 |
+
|
| 24 |
+
try:
|
| 25 |
+
# Caso matemático básico
|
| 26 |
+
if "what is" in question_lower:
|
| 27 |
+
expression = question_lower.replace("what is", "").strip()
|
| 28 |
+
return str(eval(expression))
|
| 29 |
+
|
| 30 |
+
# Caso conteo
|
| 31 |
+
if "how many" in question_lower:
|
| 32 |
+
return "1" # placeholder (mejorar luego)
|
| 33 |
+
|
| 34 |
+
# Caso genérico
|
| 35 |
+
return question.strip().split()[-1] # devuelve última palabra (dummy)
|
| 36 |
+
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f"⚠️ Error: {e}")
|
| 39 |
+
return "0"
|
| 40 |
|
| 41 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
| 42 |
"""
|