repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | """Base tool classes for Solana Trading Agent""" |
| #2 | |
| #3 | from typing import Any, Optional |
| #4 | from pydantic import BaseModel |
| #5 | |
| #6 | |
| #7 | class ToolResult(BaseModel): |
| #8 | """Tool execution result.""" |
| #9 | success: bool |
| #10 | content: str = "" |
| #11 | error: Optional[str] = None |
| #12 | |
| #13 | |
| #14 | class Tool: |
| #15 | """Base class for all tools.""" |
| #16 | |
| #17 | @property |
| #18 | def name(self) -> str: |
| #19 | """Tool name - must be unique.""" |
| #20 | raise NotImplementedError |
| #21 | |
| #22 | @property |
| #23 | def description(self) -> str: |
| #24 | """Tool description for the LLM.""" |
| #25 | raise NotImplementedError |
| #26 | |
| #27 | @property |
| #28 | def parameters(self) -> dict[str, Any]: |
| #29 | """Tool parameters schema (JSON Schema format).""" |
| #30 | raise NotImplementedError |
| #31 | |
| #32 | async def execute(self, *args, **kwargs) -> ToolResult: |
| #33 | """Execute the tool with arbitrary arguments.""" |
| #34 | raise NotImplementedError |
| #35 | |
| #36 | def to_schema(self) -> dict[str, Any]: |
| #37 | """Convert tool to Anthropic tool schema.""" |
| #38 | return { |
| #39 | "name": self.name, |
| #40 | "description": self.description, |
| #41 | "input_schema": self.parameters, |
| #42 | } |
| #43 | |
| #44 | def to_openai_schema(self) -> dict[str, Any]: |
| #45 | """Convert tool to OpenAI tool schema.""" |
| #46 | return { |
| #47 | "type": "function", |
| #48 | "function": { |
| #49 | "name": self.name, |
| #50 | "description": self.description, |
| #51 | "parameters": self.parameters, |
| #52 | }, |
| #53 | } |
| #54 |