File size: 671 Bytes
e7e1e90 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | from dataclasses import dataclass
from typing import Any, Callable
ToolContext = dict[str, Any]
ToolArgs = dict[str, Any]
ToolRunner = Callable[[ToolArgs, ToolContext], dict[str, Any]]
@dataclass(frozen=True)
class ToolSpec:
name: str
description: str
input_schema: dict[str, Any]
run: ToolRunner
enabled: bool = True
cost_level: str = "low"
def prompt_block(self) -> str:
enabled_text = "enabled" if self.enabled else "disabled"
return (
f"- {self.name} ({enabled_text}, cost={self.cost_level})\n"
f" description: {self.description}\n"
f" args_schema: {self.input_schema}"
)
|