Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import gradio as gr
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
-
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool, Tool, tool, VisitWebpageTool, load_tool
|
| 7 |
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
|
@@ -88,14 +88,16 @@ class BasicAgent:
|
|
| 88 |
#trust_remote_code=True,
|
| 89 |
#)
|
| 90 |
|
| 91 |
-
|
| 92 |
"matterattetatte/pdf-upload-extractor-tool",
|
| 93 |
trust_remote_code = True
|
| 94 |
-
)
|
| 95 |
self.agent = CodeAgent(
|
| 96 |
tools=[
|
| 97 |
DuckDuckGoSearchTool(),
|
| 98 |
VisitWebpageTool(),
|
|
|
|
|
|
|
| 99 |
#pdf_tool,
|
| 100 |
fetch_task_file,
|
| 101 |
read_spreadsheet,
|
|
@@ -103,16 +105,6 @@ class BasicAgent:
|
|
| 103 |
#os.environ["HF_TOKEN"] = "hf_token",
|
| 104 |
#image_analysis_tool,
|
| 105 |
],
|
| 106 |
-
additional_authorized_imports=[
|
| 107 |
-
"pypdf", # basic text extraction
|
| 108 |
-
"pdfplumber", # better for tables/layout inside PDFs
|
| 109 |
-
"fitz", # PyMuPDF — fast, handles images + text well
|
| 110 |
-
"io", # often needed for BytesIO when handling file bytes
|
| 111 |
-
"requests", # for fetch_task_file
|
| 112 |
-
"pandas", # for read_spreadsheet
|
| 113 |
-
"openpyxl", # backend pandas needs for .xlsx
|
| 114 |
-
"bs4", # for parsing HTML from VisitWebpageTool output if needed
|
| 115 |
-
]
|
| 116 |
model= InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct"),
|
| 117 |
#instructions = "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.",
|
| 118 |
max_steps=20,
|
|
|
|
| 3 |
import requests
|
| 4 |
import inspect
|
| 5 |
import pandas as pd
|
| 6 |
+
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool, Tool, tool,PythonInterpreterTool, VisitWebpageTool, FinalAnswerTool, load_tool
|
| 7 |
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
|
|
|
| 88 |
#trust_remote_code=True,
|
| 89 |
#)
|
| 90 |
|
| 91 |
+
pdf_tool = load_tool(
|
| 92 |
"matterattetatte/pdf-upload-extractor-tool",
|
| 93 |
trust_remote_code = True
|
| 94 |
+
)
|
| 95 |
self.agent = CodeAgent(
|
| 96 |
tools=[
|
| 97 |
DuckDuckGoSearchTool(),
|
| 98 |
VisitWebpageTool(),
|
| 99 |
+
PythonInterpreterTool(),
|
| 100 |
+
FinalAnswerTool(),
|
| 101 |
#pdf_tool,
|
| 102 |
fetch_task_file,
|
| 103 |
read_spreadsheet,
|
|
|
|
| 105 |
#os.environ["HF_TOKEN"] = "hf_token",
|
| 106 |
#image_analysis_tool,
|
| 107 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
model= InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct"),
|
| 109 |
#instructions = "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.",
|
| 110 |
max_steps=20,
|