25 lines
586 B
Python
25 lines
586 B
Python
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any
|
|
|
|
from app.core.contracts import ToolResult, UserTask
|
|
|
|
|
|
class BaseTool(ABC):
|
|
name: str = ""
|
|
description: str = ""
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return getattr(self, '_name', self.__class__.__name__.replace('Tool', '').lower())
|
|
|
|
@property
|
|
def description(self) -> str:
|
|
return getattr(self, '_description', "")
|
|
|
|
@abstractmethod
|
|
def execute(self, task: UserTask, args: dict[str, Any]) -> ToolResult:
|
|
raise NotImplementedError
|
|
|