Alexis-alexis commited on
Commit
2682793
·
verified ·
1 Parent(s): 81917a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -5
app.py CHANGED
@@ -10,14 +10,40 @@ 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 smolagents import CodeAgent, HfApiModel
14
+ from tools.gaia_tool import GaiaTool
15
+ from tools.final_answer import FinalAnswerTool
16
+ from tools.python_interpreter import PythonInterpreterTool
17
+
18
  class BasicAgent:
19
  def __init__(self):
20
+ print("Initializing smart CodeAgent...")
21
+
22
+ self.model = HfApiModel(
23
+ model_id="Qwen/Qwen2.5-Coder-32B-Instruct", # Можно заменить на другую модель
24
+ max_tokens=2048,
25
+ temperature=0.3,
26
+ )
27
+
28
+ self.agent = CodeAgent(
29
+ model=self.model,
30
+ tools=[
31
+ GaiaTool(), # Для получения формата задачи GAIA
32
+ PythonInterpreterTool(), # Для выполнения кода
33
+ FinalAnswerTool(), # Чтобы модель понимала, когда завершить
34
+ ],
35
+ max_steps=6,
36
+ verbosity_level=2,
37
+ name="GAIAAgent",
38
+ description="Agent that solves GAIA tasks",
39
+ )
40
+
41
  def __call__(self, question: str) -> str:
42
+ print(f"Agent received question: {question[:80]}...")
43
+ result = self.agent.run(question)
44
+ print(f"Agent result: {result}")
45
+ return result
46
+
47
 
48
  def run_and_submit_all( profile: gr.OAuthProfile | None):
49
  """