Skip to content

Commit 9aca26d

Browse files
committed
removed old tools
1 parent 7fbd942 commit 9aca26d

14 files changed

Lines changed: 30 additions & 1219 deletions

examples/5_a_day_benchmark/five_a_day_benchmark.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -232,23 +232,21 @@ def create_tools(self) -> list:
232232
return tools_list
233233

234234
def _convert_tool(self, base_tool):
235-
"""Convert BaseTool to framework-specific tool type.
235+
"""Convert BaseTool to framework-specific tool adapter.
236236
237237
Args:
238238
base_tool: BaseTool instance
239239
240240
Returns:
241-
Framework-specific tool object with tracing preserved
241+
Tool adapter with gather_traces() for tracing support.
242+
For smolagents: SmolagentsToolAdapter (has .tool attribute for raw Tool)
243+
For langgraph: LangGraphToolAdapter (has .tool attribute for StructuredTool)
244+
For llamaindex: LlamaIndexToolAdapter (has .tool attribute for FunctionTool)
242245
"""
243246
if self.framework == "smolagents":
244-
adapter = base_tool.to_smolagents()
245-
# Return the actual tool, not the adapter
246-
# The adapter has a .tool attribute with the smolagents Tool instance
247-
return adapter.tool if hasattr(adapter, "tool") else adapter
247+
return base_tool.to_smolagents()
248248
elif self.framework == "langgraph":
249-
adapter = base_tool.to_langgraph()
250-
# LangGraph adapter already returns the StructuredTool directly
251-
return adapter
249+
return base_tool.to_langgraph()
252250
elif self.framework == "llamaindex":
253251
return base_tool.to_llamaindex()
254252
else:
@@ -339,7 +337,7 @@ def _setup_single_agent(
339337
temperature: float,
340338
) -> tuple[List[AgentAdapter], Dict[str, AgentAdapter]]:
341339
"""Setup a single agent with all tools."""
342-
tools = environment.get_tools()
340+
tool_adapters = environment.get_tools()
343341
agent_spec = agent_data["agent"]
344342

345343
# Sanitize agent name to be a valid Python identifier for smolagents
@@ -351,6 +349,9 @@ def _setup_single_agent(
351349
# Create smolagents model
352350
model = get_model(model_id, framework, temperature)
353351

352+
# Extract raw smolagents Tool objects from adapters
353+
tools = [adapter.tool for adapter in tool_adapters]
354+
354355
# Create agent
355356
agent = ToolCallingAgent(
356357
model=model,
@@ -375,6 +376,9 @@ def _setup_single_agent(
375376
# Create LangChain model
376377
model = get_model(model_id, framework, temperature)
377378

379+
# Extract raw LangChain StructuredTool objects from adapters
380+
tools = [adapter.tool for adapter in tool_adapters]
381+
378382
# Create agent graph
379383
class AgentState(TypedDict):
380384
messages: Annotated[List[Any], add_messages]
@@ -412,6 +416,9 @@ def call_model(state: AgentState):
412416
# Create LlamaIndex LiteLLM model (supports Gemini via 'gemini/' prefix)
413417
model = get_model(model_id, framework, temperature)
414418

419+
# Extract raw LlamaIndex FunctionTool objects from adapters
420+
tools = [adapter.tool for adapter in tool_adapters]
421+
415422
# Create ReActAgent with tools
416423
agent = ReActAgent.from_tools(
417424
tools=tools,
@@ -463,7 +470,8 @@ def _setup_multi_agent(
463470

464471
# Create specialist agents
465472
specialist_agents = []
466-
all_tools = environment.get_tools()
473+
all_tool_adapters = environment.get_tools()
474+
all_tools = [adapter.tool for adapter in all_tool_adapters]
467475

468476
for agent_spec in specialist_specs:
469477
# Get tools for this specialist
@@ -521,7 +529,8 @@ class MultiAgentState(TypedDict):
521529
messages: Annotated[List[Any], add_messages]
522530
next_agent: str
523531

524-
all_tools = environment.get_tools()
532+
all_tool_adapters = environment.get_tools()
533+
all_tools = [adapter.tool for adapter in all_tool_adapters]
525534

526535
# Create specialist agent nodes
527536
specialist_nodes = {}
@@ -628,7 +637,8 @@ def route_to_specialist(state: MultiAgentState) -> Literal["orchestrator", "__en
628637
# Create LlamaIndex LiteLLM model (supports Gemini via 'gemini/' prefix)
629638
model = get_model(model_id, framework, temperature)
630639

631-
all_tools = environment.get_tools()
640+
all_tool_adapters = environment.get_tools()
641+
all_tools = [adapter.tool for adapter in all_tool_adapters]
632642

633643
# Create specialist agents
634644
specialist_agents_dict = {}

examples/5_a_day_benchmark/tools/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from .calendar import CalendarToolCollection
1111
from .fitness import RunningAppToolCollection, GymTrackerToolCollection
1212
from .hotel_search import HotelSearchToolCollection
13-
from .factory import ToolFactory
1413
from .mcp_calendar import MCPCalendarToolCollection
1514

1615
__all__ = [
@@ -27,6 +26,5 @@
2726
"RunningAppToolCollection",
2827
"GymTrackerToolCollection",
2928
"HotelSearchToolCollection",
30-
"ToolFactory",
3129
"MCPCalendarToolCollection",
3230
]

examples/5_a_day_benchmark/tools/banking_old.py

Lines changed: 0 additions & 130 deletions
This file was deleted.

examples/5_a_day_benchmark/tools/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def to_langgraph(self) -> Any:
197197
except ImportError as e:
198198
raise ImportError("langchain is not installed. Install it with: pip install maseval[langgraph]") from e
199199

200-
return LangGraphToolAdapter(self).tool
200+
return LangGraphToolAdapter(self)
201201

202202
def to_llamaindex(self) -> Any:
203203
"""Convert to LlamaIndex FunctionTool."""
@@ -206,7 +206,7 @@ def to_llamaindex(self) -> Any:
206206
except ImportError as e:
207207
raise ImportError("llamaindex is not installed. Install it with: pip install llama-index-core") from e
208208

209-
return LlamaIndexToolAdapter(self).tool
209+
return LlamaIndexToolAdapter(self)
210210

211211

212212
class SmolagentsToolAdapter(TraceableMixin, ConfigurableMixin):
@@ -224,9 +224,13 @@ def __init__(self, base_tool: BaseTool):
224224

225225
self.base_tool = base_tool
226226

227+
# Sanitize tool name to be a valid Python identifier for smolagents
228+
# Replace dots with underscores (email.get_inbox -> email_get_inbox)
229+
sanitized_tool_name = base_tool.name.replace(".", "_").replace("-", "_")
230+
227231
# Create a dynamic smolagents Tool class
228232
class DynamicSmolagentsTool(SmolagentsTool):
229-
name = base_tool.name
233+
name = sanitized_tool_name
230234
description = base_tool.description
231235
# Use specific tool arguments (excluding 'action' which is smolagents internal)
232236
inputs = base_tool.tool_args

examples/5_a_day_benchmark/tools/calculator_old.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)