Michael commited on
Commit
37769c1
·
1 Parent(s): 81917a3

baseline gpt-40-mini

Browse files
Files changed (2) hide show
  1. app.py +22 -4
  2. requirements.txt +2 -1
app.py CHANGED
@@ -1,9 +1,14 @@
1
  import os
 
2
  import gradio as gr
3
- import requests
4
- import inspect
5
  import pandas as pd
 
 
6
 
 
 
 
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
9
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -13,11 +18,24 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
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
  """
 
1
  import os
2
+
3
  import gradio as gr
 
 
4
  import pandas as pd
5
+ import requests
6
+ from smolagents import CodeAgent, OpenAIModel
7
 
8
+ # Read any API keys
9
+ openai_api_key = os.environ["OPENAI_API_KEY"]
10
+
11
+ #z
12
  # (Keep Constants as is)
13
  # --- Constants ---
14
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
18
  class BasicAgent:
19
  def __init__(self):
20
  print("BasicAgent initialized.")
21
+
22
+ model = OpenAIModel(
23
+ model_id="gpt-4o-mini",
24
+ api_key=openai_api_key,
25
+ )
26
+
27
+ self.agent = CodeAgent(
28
+ model=model,
29
+ )
30
+
31
  def __call__(self, question: str) -> str:
32
  print(f"Agent received question (first 50 chars): {question[:50]}...")
33
+ answer = self.agent.run(question)
34
  print(f"Agent returning fixed answer: {fixed_answer}")
35
+ return answer
36
+
37
+
38
+
39
 
40
  def run_and_submit_all( profile: gr.OAuthProfile | None):
41
  """
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  gradio
2
- requests
 
 
1
  gradio
2
+ requests
3
+ smolagents