Rename app.py to appfinal.py

#476
by joudbaz77 - opened
Files changed (1) hide show
  1. app.py β†’ appfinal.py +18 -5
app.py β†’ appfinal.py RENAMED
@@ -12,12 +12,25 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  class BasicAgent:
14
  def __init__(self):
15
- print("BasicAgent initialized.")
 
16
  def __call__(self, question: str) -> str:
17
- print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
 
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  class BasicAgent:
14
  def __init__(self):
15
+ print("Agent initialized")
16
+
17
  def __call__(self, question: str) -> str:
18
+ try:
19
+ result = real_agent.run(
20
+ "Answer only with the final short exact result. No explanation. No words. Only the final answer.\n\nQuestion:\n"
21
+ + question
22
+ )
23
+
24
+ result = str(result).strip()
25
+
26
+ # VERY IMPORTANT: keep only last line (often the real answer)
27
+ result = result.split("\n")[-1]
28
+
29
+ return result
30
+
31
+ except Exception as e:
32
+ print(f"Agent error: {e}")
33
+ return "unknown"
34
 
35
  def run_and_submit_all( profile: gr.OAuthProfile | None):
36
  """