citationEdge / tools /base_tool.py
omkarkudalkar222's picture
Fresh deployment without history
0e38162
Raw
History Blame Contribute Delete
661 Bytes
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Any, Dict, Optional
@dataclass
class ToolResult:
success: bool
data: Any
error: Optional[str] = None
class BaseTool(ABC):
"""Abstract base for all agent tools."""
name: str = "base_tool"
description: str = ""
@abstractmethod
async def run(self, **kwargs) -> ToolResult:
"""Execute the tool and return a ToolResult."""
def _ok(self, data: Any) -> ToolResult:
return ToolResult(success=True, data=data)
def _err(self, error: str) -> ToolResult:
return ToolResult(success=False, data=None, error=error)