Visionkambanje commited on
Commit
9ca6d70
·
verified ·
1 Parent(s): b1078e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py CHANGED
@@ -10,6 +10,47 @@ 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("BasicAgent initialized.")
 
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
+ import math
14
+
15
+ class BasicAgent:
16
+ def __init__(self):
17
+ print("✅ BasicAgent initialized.")
18
+
19
+ def __call__(self, question: str) -> str:
20
+ print(f"🤔 Agent received question (first 50 chars): {question[:50]}...")
21
+
22
+ q = question.lower().strip()
23
+
24
+ # --- Simple math checks ---
25
+ if "2+2" in q or "two plus two" in q:
26
+ return "4"
27
+ if "sqrt" in q:
28
+ try:
29
+ # extract number after 'sqrt'
30
+ num = [int(s) for s in q.split() if s.isdigit()][0]
31
+ return str(math.isqrt(num))
32
+ except Exception:
33
+ return "The square root depends on the number provided."
34
+
35
+ # --- Geography checks ---
36
+ if "capital of france" in q:
37
+ return "Paris"
38
+ if "capital of germany" in q:
39
+ return "Berlin"
40
+ if "capital of italy" in q:
41
+ return "Rome"
42
+ if "capital of spain" in q:
43
+ return "Madrid"
44
+
45
+ # --- History / generic fallback ---
46
+ if "who wrote" in q:
47
+ return "It depends on the book or text mentioned."
48
+ if "who is" in q:
49
+ return "That depends on the person you are asking about."
50
+
51
+ # --- Default fallback ---
52
+ return f"I'm not fully sure, but here's my guess: {question}"
53
+
54
  class BasicAgent:
55
  def __init__(self):
56
  print("BasicAgent initialized.")