25 lines
625 B
Python
25 lines
625 B
Python
from abc import ABC, abstractmethod
|
|
from typing import Any
|
|
|
|
|
|
class Tool(ABC):
|
|
name: str
|
|
description: str
|
|
|
|
def definition(self) -> dict[str, Any]:
|
|
return {
|
|
"type": "function",
|
|
"function": {
|
|
"name": self.name,
|
|
"description": self.description,
|
|
"parameters": self.parameters_schema(),
|
|
},
|
|
}
|
|
|
|
def parameters_schema(self) -> dict[str, Any]:
|
|
return {"type": "object", "properties": {}}
|
|
|
|
@abstractmethod
|
|
async def run(self, payload: dict[str, Any]) -> dict[str, Any]:
|
|
raise NotImplementedError
|