Hanson commited on
Commit
f123926
·
1 Parent(s): 735d45f

fix: complete code replacement to eliminate import error

Browse files
Files changed (1) hide show
  1. app.py +1 -17
app.py CHANGED
@@ -11,8 +11,6 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  from smolagents import CodeAgent, OpenAIServerModel, DuckDuckGoSearchTool, VisitWebpageTool
14
- # 💡 導入 smolagents 內建的系統提示詞結構
15
- from smolagents.agents import SYSTEM_PROMPT_WITH_CODE
16
  import os
17
  import spaces
18
 
@@ -37,24 +35,10 @@ class BasicAgent:
37
  visit_tool = VisitWebpageTool()
38
  tools = [search_tool, visit_tool]
39
 
40
- # 💡 精準修正:灌輸 Agent 解題邏輯,並提醒它留意當前目錄下的附加檔案(如 .xlsx, .mp3, .py 等)
41
- custom_prompt = (
42
- "You are an expert AI Assistant capable of running Python code and web searches to solve complex tasks.\n"
43
- "When a question requires factual data, always double check the facts using search tools.\n"
44
- "If the first search yields no good results, try different keywords.\n"
45
- "If the question mentions an attached file (e.g., .mp3, .xlsx, .py), check the current directory, "
46
- "and write Python code to read/analyze the file content directly.\n"
47
- "Be concise and output only the final correct answer without unnecessary prose."
48
- )
49
-
50
- # 💡 正確傳遞 Prompt 的方式:替換預設的 system_prompt 範本
51
- prompt_templates = {"system_prompt": SYSTEM_PROMPT_WITH_CODE + "\n\nSpecific Rules:\n" + custom_prompt}
52
-
53
  agent = CodeAgent(
54
  tools=tools,
55
  model=model,
56
- max_steps=8,
57
- prompt_templates=prompt_templates # 💡 修正參數名稱
58
  )
59
 
60
  return str(agent.run(question))
 
11
  # --- Basic Agent Definition ---
12
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
13
  from smolagents import CodeAgent, OpenAIServerModel, DuckDuckGoSearchTool, VisitWebpageTool
 
 
14
  import os
15
  import spaces
16
 
 
35
  visit_tool = VisitWebpageTool()
36
  tools = [search_tool, visit_tool]
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  agent = CodeAgent(
39
  tools=tools,
40
  model=model,
41
+ max_steps=6
 
42
  )
43
 
44
  return str(agent.run(question))