Spaces:
Runtime error
Runtime error
Leonardo
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ from scripts.text_web_browser import (
|
|
| 19 |
VisitTool,
|
| 20 |
)
|
| 21 |
from scripts.visual_qa import visualizer
|
|
|
|
| 22 |
|
| 23 |
from smolagents import (
|
| 24 |
CodeAgent,
|
|
@@ -169,6 +170,15 @@ class ToolRegistry:
|
|
| 169 |
print(f"✗ Couldn't initialize image generation tool: {e}")
|
| 170 |
raise
|
| 171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
# ------------------------ Agent Creation and Execution ------------------------
|
| 174 |
def create_agent():
|
|
@@ -186,9 +196,10 @@ def create_agent():
|
|
| 186 |
# Collect all tools in a single list
|
| 187 |
web_tools = ToolRegistry.load_web_tools(model, browser, text_limit)
|
| 188 |
image_generator = ToolRegistry.load_image_generation_tools()
|
|
|
|
| 189 |
|
| 190 |
# Combine all tools into a single list (not a tuple)
|
| 191 |
-
all_tools = [visualizer] + web_tools + [image_generator]
|
| 192 |
|
| 193 |
# Validate tools before creating agent
|
| 194 |
for tool in all_tools:
|
|
|
|
| 19 |
VisitTool,
|
| 20 |
)
|
| 21 |
from scripts.visual_qa import visualizer
|
| 22 |
+
from scripts.text_cleaner import TextCleanerTool
|
| 23 |
|
| 24 |
from smolagents import (
|
| 25 |
CodeAgent,
|
|
|
|
| 170 |
print(f"✗ Couldn't initialize image generation tool: {e}")
|
| 171 |
raise
|
| 172 |
|
| 173 |
+
@staticmethod
|
| 174 |
+
def load_clean_text_tool():
|
| 175 |
+
"""Initialize and return image generation tools."""
|
| 176 |
+
try:
|
| 177 |
+
return TextCleanerTool
|
| 178 |
+
except Exception as e:
|
| 179 |
+
print(f"✗ Couldn't initialize clean text tool: {e}")
|
| 180 |
+
raise
|
| 181 |
+
|
| 182 |
|
| 183 |
# ------------------------ Agent Creation and Execution ------------------------
|
| 184 |
def create_agent():
|
|
|
|
| 196 |
# Collect all tools in a single list
|
| 197 |
web_tools = ToolRegistry.load_web_tools(model, browser, text_limit)
|
| 198 |
image_generator = ToolRegistry.load_image_generation_tools()
|
| 199 |
+
clean_text = ToolRegistry.load_clean_text_tool()
|
| 200 |
|
| 201 |
# Combine all tools into a single list (not a tuple)
|
| 202 |
+
all_tools = [visualizer] + web_tools + [image_generator] + clean_text
|
| 203 |
|
| 204 |
# Validate tools before creating agent
|
| 205 |
for tool in all_tools:
|