Update app.py
Browse files
app.py
CHANGED
|
@@ -78,25 +78,27 @@ class BasicAgent:
|
|
| 78 |
else:
|
| 79 |
df = pd.read_excel(file_path)
|
| 80 |
return df.to_string()
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
""
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
| 96 |
#pdf_tool = load_tool(
|
| 97 |
#"matterattetatte/pdf-upload-extractor-tool",
|
| 98 |
# trust_remote_code = True
|
| 99 |
#)
|
|
|
|
| 100 |
self.agent = CodeAgent(
|
| 101 |
tools=[
|
| 102 |
DuckDuckGoSearchTool(),
|
|
@@ -110,7 +112,7 @@ class BasicAgent:
|
|
| 110 |
get_youtube_transcript,
|
| 111 |
],
|
| 112 |
model= InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct"),
|
| 113 |
-
additional_authorized_imports=["pandas", "requests", "re"],
|
| 114 |
#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.",
|
| 115 |
max_steps=20,
|
| 116 |
)
|
|
|
|
| 78 |
else:
|
| 79 |
df = pd.read_excel(file_path)
|
| 80 |
return df.to_string()
|
| 81 |
+
|
| 82 |
+
class ReadPDFTool(Tool):
|
| 83 |
+
name = "read_pdf"
|
| 84 |
+
description = "Extracts text from a PDF file."
|
| 85 |
+
inputs = {
|
| 86 |
+
"file_path": {
|
| 87 |
+
"type": "string",
|
| 88 |
+
"description": "Local path to the PDF file.",
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
output_type = "string"
|
| 92 |
+
|
| 93 |
+
def forward(self, file_path: str) -> str:
|
| 94 |
+
from pypdf import PdfReader
|
| 95 |
+
reader = PdfReader(file_path)
|
| 96 |
+
return "\n".join(page.extract_text() or "" for page in reader.pages)
|
| 97 |
#pdf_tool = load_tool(
|
| 98 |
#"matterattetatte/pdf-upload-extractor-tool",
|
| 99 |
# trust_remote_code = True
|
| 100 |
#)
|
| 101 |
+
read_pdf = ReadPDFTool()
|
| 102 |
self.agent = CodeAgent(
|
| 103 |
tools=[
|
| 104 |
DuckDuckGoSearchTool(),
|
|
|
|
| 112 |
get_youtube_transcript,
|
| 113 |
],
|
| 114 |
model= InferenceClientModel("Qwen/Qwen2.5-Coder-32B-Instruct"),
|
| 115 |
+
#additional_authorized_imports=["pandas", "requests", "re"],
|
| 116 |
#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.",
|
| 117 |
max_steps=20,
|
| 118 |
)
|