Add DuckDuckGoSearchTool and VisitWebpageTool to agent initialization in main.py. Update tools configuration to enhance agent functionality and enable visualization of tools used during execution.
Browse files
main.py
CHANGED
@@ -12,6 +12,10 @@ import litellm
|
|
12 |
from smolagents import CodeAgent, LiteLLMModel
|
13 |
from smolagents.memory import ActionStep, FinalAnswerStep
|
14 |
from smolagents.monitoring import LogLevel
|
|
|
|
|
|
|
|
|
15 |
|
16 |
litellm._turn_on_debug()
|
17 |
|
@@ -54,18 +58,29 @@ except Exception as e:
|
|
54 |
logger.error(f"Failed to initialize model: {str(e)}")
|
55 |
raise
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
# Initialize agent with error handling
|
58 |
try:
|
59 |
agent = CodeAgent(
|
60 |
-
add_base_tools=True,
|
61 |
additional_authorized_imports=["pandas", "numpy"],
|
62 |
max_steps=10,
|
63 |
model=model,
|
64 |
-
tools=
|
65 |
step_callbacks=None,
|
66 |
verbosity_level=LogLevel.ERROR,
|
67 |
)
|
68 |
agent.logger.console.width = 66
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
except Exception as e:
|
70 |
logger.error(f"Failed to initialize agent: {str(e)}")
|
71 |
raise
|
|
|
12 |
from smolagents import CodeAgent, LiteLLMModel
|
13 |
from smolagents.memory import ActionStep, FinalAnswerStep
|
14 |
from smolagents.monitoring import LogLevel
|
15 |
+
from smolagents.default_tools import (
|
16 |
+
DuckDuckGoSearchTool,
|
17 |
+
VisitWebpageTool,
|
18 |
+
)
|
19 |
|
20 |
litellm._turn_on_debug()
|
21 |
|
|
|
58 |
logger.error(f"Failed to initialize model: {str(e)}")
|
59 |
raise
|
60 |
|
61 |
+
tools = [
|
62 |
+
DuckDuckGoSearchTool(max_results=3),
|
63 |
+
# VisitWebpageTool(max_output_length=1000),
|
64 |
+
]
|
65 |
+
|
66 |
# Initialize agent with error handling
|
67 |
try:
|
68 |
agent = CodeAgent(
|
69 |
+
# add_base_tools=True,
|
70 |
additional_authorized_imports=["pandas", "numpy"],
|
71 |
max_steps=10,
|
72 |
model=model,
|
73 |
+
tools=tools,
|
74 |
step_callbacks=None,
|
75 |
verbosity_level=LogLevel.ERROR,
|
76 |
)
|
77 |
agent.logger.console.width = 66
|
78 |
+
|
79 |
+
agent.visualize()
|
80 |
+
|
81 |
+
tools = agent.tools
|
82 |
+
print(f"Tools: {tools}")
|
83 |
+
|
84 |
except Exception as e:
|
85 |
logger.error(f"Failed to initialize agent: {str(e)}")
|
86 |
raise
|