Omnitopia commited on
Commit
e76edee
·
verified ·
1 Parent(s): c5cb1b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -10,14 +10,22 @@ 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
+
14
+ from smolagents import CodeAgent
15
+ from smolagents.models import OpenAIChat
16
+ from my_tools import my_tool_list # 你需要新建/补全这个模块和列表
17
+
18
  class BasicAgent:
19
  def __init__(self):
20
+ model = OpenAIChat(model="gpt-4.1")
21
+ self.agent = CodeAgent(model=model, tools=my_tool_list, max_steps=6)
22
+
23
  def __call__(self, question: str) -> str:
24
+ print(f"Agent received question: {question[:80]}...")
25
+ try:
26
+ return self.agent.run(question)
27
+ except Exception as e:
28
+ return f"[Agent Error: {e}]"
29
 
30
  def run_and_submit_all( profile: gr.OAuthProfile | None):
31
  """