mgthepro001 commited on
Commit
bc3317c
·
verified ·
1 Parent(s): 3def899

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -6,7 +6,7 @@ import inspect
6
  import pandas as pd
7
  from io import BytesIO
8
 
9
- from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, InferenceClientModel
10
 
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -38,16 +38,17 @@ class BasicAgent:
38
 
39
  def __init__(self):
40
  print("BasicAgent initialized.")
41
- hf_token = os.getenv("HF_TOKEN")
42
- if not hf_token:
43
- print(
44
- "WARNING: HF_TOKEN not found in environment. "
45
- "Add it as a Space secret (Settings > Variables and secrets) "
46
- "or the model calls will fail with an auth error."
47
  )
48
- self.model = InferenceClientModel(
49
- model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
50
- token=hf_token,
 
51
  )
52
  self.agent = CodeAgent(
53
  tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],
 
6
  import pandas as pd
7
  from io import BytesIO
8
 
9
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, OpenAIServerModel
10
 
11
  # --- Constants ---
12
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
38
 
39
  def __init__(self):
40
  print("BasicAgent initialized.")
41
+ groq_key = os.getenv("GROQ_API_KEY")
42
+ if not groq_key:
43
+ raise ValueError(
44
+ "GROQ_API_KEY not found in environment. "
45
+ "Add it as a Space secret (Settings > Variables and secrets). "
46
+ "Get a free key at https://console.groq.com"
47
  )
48
+ self.model = OpenAIServerModel(
49
+ model_id="llama-3.3-70b-versatile",
50
+ api_base="https://api.groq.com/openai/v1",
51
+ api_key=groq_key,
52
  )
53
  self.agent = CodeAgent(
54
  tools=[DuckDuckGoSearchTool(), VisitWebpageTool()],