BenjaminKaindu0506 commited on
Commit
ea16981
·
verified ·
1 Parent(s): 127ed31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -4,6 +4,7 @@ import requests
4
  import inspect
5
  import pandas as pd
6
  from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool, Tool, tool, VisitWebpageTool
 
7
 
8
  # (Keep Constants as is)
9
  # --- Constants ---
@@ -98,16 +99,22 @@ class BasicAgent:
98
  "to inspect it before answering. Use DuckDuckGoSearchTool only "
99
  "when the question needs current or external information."
100
  ),"""
101
-
 
 
 
 
102
  self.agent = CodeAgent(
103
  tools=[
104
  DuckDuckGoSearchTool(),
105
  VisitWebpageTool(),
 
106
  fetch_task_file,
107
  read_spreadsheet,
108
  get_youtube_transcript,
109
  #os.environ["HF_TOKEN"] = "hf_token",
110
  #image_analysis_tool,
 
111
  ],
112
  model=InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct"),
113
  max_steps=20,
 
4
  import inspect
5
  import pandas as pd
6
  from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool, Tool, tool, VisitWebpageTool
7
+ from smolagents.prompts import CODE_SYSTEM_PROMPT
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
 
99
  "to inspect it before answering. Use DuckDuckGoSearchTool only "
100
  "when the question needs current or external information."
101
  ),"""
102
+ pdf_tool = load_tool(
103
+ "matterattetatte/pdf-upload-extractor-tool",
104
+ trust_remote_code = True
105
+ )
106
+ modified_system_message = CODE_SYSTEM_PROMPT + "If the question includes a task_id and mentions a file, call fetch_task_file first; route YouTube URLs to get_youtube_transcript, other URLs to visit_webpage, PDFs to pdf_tool, and spreadsheets to read_spreadsheet, using web_search only when no URL or file is given — then respond with only the exact final answer value, no explanation, no prefix.
107
  self.agent = CodeAgent(
108
  tools=[
109
  DuckDuckGoSearchTool(),
110
  VisitWebpageTool(),
111
+ pdf_tool,
112
  fetch_task_file,
113
  read_spreadsheet,
114
  get_youtube_transcript,
115
  #os.environ["HF_TOKEN"] = "hf_token",
116
  #image_analysis_tool,
117
+ modified_system_message
118
  ],
119
  model=InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct"),
120
  max_steps=20,