cgoncalves commited on
Commit
7a5d389
·
verified ·
1 Parent(s): ae7fe00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -12,11 +12,12 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
  # --- Basic Agent Definition ---
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
- def __init__(self):
 
16
  print("BasicAgent initialized.")
17
  # Initialize the model
18
  #model = HfApiModel()
19
- model = OpenAIServerModel(model_id="gpt-4.1")
20
  # Initialize the search tool
21
  search_tool = DuckDuckGoSearchTool()
22
  # Initialize Agent
@@ -30,7 +31,7 @@ class BasicAgent:
30
  print(f"Agent returning fixed answer: {fixed_answer}")
31
  return fixed_answer
32
 
33
- def run_and_submit_all( profile: gr.OAuthProfile | None):
34
  """
35
  Fetches all questions, runs the BasicAgent on them, submits all answers,
36
  and displays the results.
@@ -51,7 +52,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
51
 
52
  # 1. Instantiate Agent ( modify this part to create your agent)
53
  try:
54
- agent = BasicAgent()
55
  except Exception as e:
56
  print(f"Error instantiating agent: {e}")
57
  return f"Error initializing agent: {e}", None
 
12
  # --- Basic Agent Definition ---
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
+ def __init__(self, openai_key):
16
+ self.openai_key = openai_key
17
  print("BasicAgent initialized.")
18
  # Initialize the model
19
  #model = HfApiModel()
20
+ model = OpenAIServerModel(model_id="gpt-4.1", api_key=self.openai_key)
21
  # Initialize the search tool
22
  search_tool = DuckDuckGoSearchTool()
23
  # Initialize Agent
 
31
  print(f"Agent returning fixed answer: {fixed_answer}")
32
  return fixed_answer
33
 
34
+ def run_and_submit_all(profile: gr.OAuthProfile | None, openai_key: str):
35
  """
36
  Fetches all questions, runs the BasicAgent on them, submits all answers,
37
  and displays the results.
 
52
 
53
  # 1. Instantiate Agent ( modify this part to create your agent)
54
  try:
55
+ agent = BasicAgent(openai_key)
56
  except Exception as e:
57
  print(f"Error instantiating agent: {e}")
58
  return f"Error initializing agent: {e}", None