Spaces:
Runtime error
Runtime error
fixing
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import tempfile
|
|
10 |
import urllib.parse
|
11 |
from pathlib import Path
|
12 |
from duckduckgo_search import DDGS
|
|
|
13 |
|
14 |
|
15 |
# --- Constants ---
|
@@ -30,7 +31,7 @@ class HfApiModel:
|
|
30 |
outputs = self.pipe(prompt, max_new_tokens=512, do_sample=True)
|
31 |
return outputs[0]["generated_text"]
|
32 |
|
33 |
-
class PythonInterpreterTool:
|
34 |
name = "python_interpreter"
|
35 |
description = "Evaluate Python code for logic, data, and math."
|
36 |
|
@@ -43,7 +44,7 @@ class PythonInterpreterTool:
|
|
43 |
return f"Python execution error: {e}"
|
44 |
|
45 |
|
46 |
-
class DuckDuckGoSearchTool:
|
47 |
name = "duckduckgo_search"
|
48 |
description = "Use DuckDuckGo to search the web."
|
49 |
|
@@ -59,7 +60,7 @@ class DuckDuckGoSearchTool:
|
|
59 |
|
60 |
|
61 |
# --- Custom Tools ---
|
62 |
-
class SerperSearchTool:
|
63 |
"""Enhanced search tool using Serper API for more reliable results"""
|
64 |
|
65 |
name = "serper_search"
|
@@ -110,7 +111,7 @@ class SerperSearchTool:
|
|
110 |
print(f"Serper search error: {e}")
|
111 |
return f"Search error for '{query}': {str(e)}"
|
112 |
|
113 |
-
class MathCalculatorTool:
|
114 |
"""Tool for mathematical calculations and computations"""
|
115 |
|
116 |
name = "math_calculator"
|
@@ -141,7 +142,7 @@ class MathCalculatorTool:
|
|
141 |
except Exception as e:
|
142 |
return f"Math calculation error: {str(e)}"
|
143 |
|
144 |
-
class FileProcessorTool:
|
145 |
"""Tool for processing various file formats"""
|
146 |
|
147 |
name = "file_processor"
|
|
|
10 |
import urllib.parse
|
11 |
from pathlib import Path
|
12 |
from duckduckgo_search import DDGS
|
13 |
+
from smolagents.schema import Tool
|
14 |
|
15 |
|
16 |
# --- Constants ---
|
|
|
31 |
outputs = self.pipe(prompt, max_new_tokens=512, do_sample=True)
|
32 |
return outputs[0]["generated_text"]
|
33 |
|
34 |
+
class PythonInterpreterTool(Tool):
|
35 |
name = "python_interpreter"
|
36 |
description = "Evaluate Python code for logic, data, and math."
|
37 |
|
|
|
44 |
return f"Python execution error: {e}"
|
45 |
|
46 |
|
47 |
+
class DuckDuckGoSearchTool(Tool):
|
48 |
name = "duckduckgo_search"
|
49 |
description = "Use DuckDuckGo to search the web."
|
50 |
|
|
|
60 |
|
61 |
|
62 |
# --- Custom Tools ---
|
63 |
+
class SerperSearchTool(Tool):
|
64 |
"""Enhanced search tool using Serper API for more reliable results"""
|
65 |
|
66 |
name = "serper_search"
|
|
|
111 |
print(f"Serper search error: {e}")
|
112 |
return f"Search error for '{query}': {str(e)}"
|
113 |
|
114 |
+
class MathCalculatorTool(Tool):
|
115 |
"""Tool for mathematical calculations and computations"""
|
116 |
|
117 |
name = "math_calculator"
|
|
|
142 |
except Exception as e:
|
143 |
return f"Math calculation error: {str(e)}"
|
144 |
|
145 |
+
class FileProcessorTool(Tool):
|
146 |
"""Tool for processing various file formats"""
|
147 |
|
148 |
name = "file_processor"
|