gMAS / src /tools /__init__.py
ะั€ั‚ั‘ะผ ะ‘ะพัั€ัะบะธั…
chore: initial commit
3193174
"""
Tools for agents.
If an agent has tools โ€” they are ALWAYS used on every LLM call.
Tools are passed via the API (the `tools` parameter), not in the prompt text.
Supported tools:
- shell: Shell command execution
- code_interpreter: Python code execution in a sandbox
- file_search: File and content search
- web_search: Information search on the internet (DuckDuckGo, Serper, etc.)
- Any custom functions via the @tool decorator
Usage example:
from tools import tool, get_registry, CodeInterpreterTool
from core.agent import AgentProfile
from execution import MACPRunner
# 1. Register tools (globally or via the registry)
@tool
def fibonacci(n: int) -> str:
'''Calculate n-th Fibonacci number.'''
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return str(a)
# 2. Create an agent with tools
agent = AgentProfile(
agent_id="math",
display_name="Math Agent",
persona="a helpful math assistant",
tools=["fibonacci", "code_interpreter"], # <-- tools here!
)
# 3. Run via runner โ€” tools are used automatically
runner = MACPRunner(llm_caller=my_caller)
result = runner.run_round(graph)
"""
from .base import (
BaseTool,
ToolCall,
ToolRegistry,
ToolResult,
create_tool_from_config,
get_registry,
register_tool,
register_tool_factory,
tool,
)
from .code_interpreter import CodeInterpreterTool
from .file_search import FileSearchTool
from .function_calling import FunctionTool, FunctionWrapper
from .llm_integration import (
LLMResponse,
LLMToolCall,
# New unified caller (recommended)
OpenAICaller,
# Aliases for backward compatibility
OpenAIToolsCaller,
create_openai_caller,
create_openai_tools_caller,
parse_anthropic_response,
parse_openai_response,
)
from .shell import ShellTool
from .web_search import (
DuckDuckGoProvider,
SearchProvider,
SeleniumFetcher,
SerperProvider,
TavilyProvider,
URLFetcher,
WebSearchTool,
)
__all__ = [
# Base classes
"BaseTool",
"CodeInterpreterTool",
"DuckDuckGoProvider",
"FileSearchTool",
"FunctionTool",
"FunctionWrapper",
# Native function calling (recommended)
"LLMResponse",
"LLMToolCall",
"OpenAICaller", # Unified caller โ€” works with and without tools
# Backward compatibility aliases
"OpenAIToolsCaller", # = OpenAICaller
# Web search providers and utilities
"SearchProvider",
"SeleniumFetcher",
"SerperProvider",
# Built-in tools
"ShellTool",
"TavilyProvider",
"ToolCall",
"ToolRegistry",
"ToolResult",
"URLFetcher",
"WebSearchTool",
"create_openai_caller", # Recommended way to create a caller
"create_openai_tools_caller", # = create_openai_caller
"create_tool_from_config",
# Global registry helpers
"get_registry",
"parse_anthropic_response",
"parse_openai_response",
"register_tool",
"register_tool_factory",
"tool",
]