Files changed (1) hide show
  1. app.py +29 -4
app.py CHANGED
@@ -10,14 +10,39 @@ 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.")
 
 
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
  """
 
10
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
+ from openai import OpenAI
14
+
15
  class BasicAgent:
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
+ self.client = OpenAI()
19
+
20
  def __call__(self, question: str) -> str:
21
+
22
+ print(f"Agent received question: {question}")
23
+
24
+ prompt = f"""
25
+ Answer the question below.
26
+
27
+ Return ONLY the final answer.
28
+ Do not include explanations.
29
+
30
+ Question:
31
+ {question}
32
+ """
33
+
34
+ response = self.client.chat.completions.create(
35
+ model="gpt-4o-mini",
36
+ messages=[
37
+ {"role": "user", "content": prompt}
38
+ ]
39
+ )
40
+
41
+ answer = response.choices[0].message.content.strip()
42
+
43
+ print(f"Agent answer: {answer}")
44
+
45
+ return answer
46
 
47
  def run_and_submit_all( profile: gr.OAuthProfile | None):
48
  """