JuyeopDang commited on
Commit
fe079cc
·
verified ·
1 Parent(s): af0abee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -4,23 +4,34 @@ import requests
4
  import inspect
5
  import pandas as pd
6
  from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, InferenceClientModel, Tool, tool, VisitWebpageTool, HfApiModel
 
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
- HF_TOKEN = os.environ['HF_TOKEN']
12
 
13
  # --- Basic Agent Definition ---
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
15
  class BasicAgent:
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
- self.agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=InferenceClientModel())
19
 
20
  def __call__(self, question: str) -> str:
21
  print(f"Agent received question (first 50 chars): {question[:50]}...")
22
- #fixed_answer = "This is a default answer."
23
- answer = self.agent.run(question)
 
 
 
 
 
 
 
 
 
 
24
  print(f"Agent returning fixed answer: {answer}")
25
  return fixed_answer
26
 
 
4
  import inspect
5
  import pandas as pd
6
  from smolagents import CodeAgent, DuckDuckGoSearchTool, FinalAnswerTool, InferenceClientModel, Tool, tool, VisitWebpageTool, HfApiModel
7
+ from groq import Groq
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
11
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
12
+ GROQ_KEY = os.environ['GROQ_KEY']
13
 
14
  # --- Basic Agent Definition ---
15
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
16
  class BasicAgent:
17
  def __init__(self):
18
  print("BasicAgent initialized.")
19
+ self.client = Groq(api_key=GROQ_KEY)
20
 
21
  def __call__(self, question: str) -> str:
22
  print(f"Agent received question (first 50 chars): {question[:50]}...")
23
+ fixed_answer = "This is a default answer."
24
+ message = [{
25
+ "role": "user",
26
+ "content": question
27
+ }]
28
+ completion = client.chat.completions.create(
29
+ messages=message
30
+ # Change model to compound-beta to use agentic tooling
31
+ # model: "llama-3.3-70b-versatile",
32
+ model="compound-beta-mini",
33
+ )
34
+ print(completion.choices[0].message.content)
35
  print(f"Agent returning fixed answer: {answer}")
36
  return fixed_answer
37