Example calculator tool.
| 89 | |
| 90 | |
| 91 | class CalculatorTool(Tool): |
| 92 | """Example calculator tool.""" |
| 93 | |
| 94 | @property |
| 95 | def name(self) -> str: |
| 96 | return "calculator" |
| 97 | |
| 98 | @property |
| 99 | def description(self) -> str: |
| 100 | return "Perform arithmetic calculations" |
| 101 | |
| 102 | @property |
| 103 | def parameters(self) -> dict[str, Any]: |
| 104 | return { |
| 105 | "type": "object", |
| 106 | "properties": { |
| 107 | "expression": { |
| 108 | "type": "string", |
| 109 | "description": "Mathematical expression to evaluate, e.g. '2 + 2' or '10 * 5'", |
| 110 | } |
| 111 | }, |
| 112 | "required": ["expression"], |
| 113 | } |
| 114 | |
| 115 | async def execute(self, **kwargs) -> ToolResult: |
| 116 | """Mock execute method.""" |
| 117 | return ToolResult(success=True, content="Calculation result") |
| 118 | |
| 119 | |
| 120 | class TranslateTool(Tool): |
no outgoing calls
no test coverage detected