Documentation
¶
Overview ¶
Package tooldef provides JSON Schema tool definitions for AI agent frameworks.
These definitions are compatible with OpenAI function-calling, Anthropic tool_use, Google Gemini function declarations, and any framework that accepts JSON Schema (LangChain, Vercel AI SDK, Semantic Kernel, etc.).
Usage:
tools := tooldef.AllTools() // Register with your agent framework's tool system
Index ¶
- func ValidateParams(def ToolDef, params map[string]interface{}) error
- type Schema
- type ToolDef
- func AllTools() []ToolDef
- func DesignVoice() ToolDef
- func EditImage() ToolDef
- func EditVideo() ToolDef
- func Generate3D() ToolDef
- func GenerateImage() ToolDef
- func GenerateMusic() ToolDef
- func GenerateVideo() ToolDef
- func TextToSpeech() ToolDef
- func ToolsFor(categories ...string) []ToolDef
- func TranscribeAudio() ToolDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateParams ¶ added in v0.5.0
ValidateParams checks parameter values against the tool's schema constraints (enums, required fields). Returns an error describing the first invalid parameter found, or nil if all values are valid.
Types ¶
type Schema ¶
type Schema struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Properties map[string]Schema `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
Enum []string `json:"enum,omitempty"`
Default string `json:"default,omitempty"`
Items *Schema `json:"items,omitempty"`
OneOf [][]string `json:"-"`
}
Schema is a minimal JSON Schema representation.
OneOf encodes mutually-exclusive property groups. Each inner slice is a set of property names where exactly one MUST be provided. This is a pragmatic subset of JSON Schema's full `oneOf` (which takes sub-schemas) — sufficient for our XOR-style tool inputs (e.g. `prompt` vs `image_url` vs `image_urls`) without dragging in a full schema validator.
type ToolDef ¶
type ToolDef struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters Schema `json:"parameters"`
Category string `json:"category,omitempty"` // media type category: "image", "video", "audio", "3d", "music", "voice"
}
ToolDef describes a callable tool with its JSON Schema parameters.
func DesignVoice ¶
func DesignVoice() ToolDef
DesignVoice returns the tool definition for custom voice creation.
func EditVideo ¶ added in v0.7.0
func EditVideo() ToolDef
EditVideo returns the tool definition for video editing.
func Generate3D ¶ added in v0.14.0
func Generate3D() ToolDef
Generate3D returns the tool definition for 3D model generation.
Inputs are mutually exclusive: provide one of `prompt`, `image_url`, or `image_urls` (multi-image, 2-4 entries). Tripo-style providers also accept `texture_quality` and `geometry_quality` for fidelity tuning.
func GenerateImage ¶
func GenerateImage() ToolDef
GenerateImage returns the tool definition for image generation.
func GenerateMusic ¶ added in v0.10.0
func GenerateMusic() ToolDef
GenerateMusic returns the tool definition for AI music generation.
func GenerateVideo ¶
func GenerateVideo() ToolDef
GenerateVideo returns the tool definition for video generation.
func TextToSpeech ¶
func TextToSpeech() ToolDef
TextToSpeech returns the tool definition for text-to-speech synthesis.
func ToolsFor ¶ added in v0.15.0
ToolsFor returns tools matching the given category (e.g., "image", "video", "audio", "3d", "music"). Multiple categories can be passed; tools matching any of them are included.
func TranscribeAudio ¶
func TranscribeAudio() ToolDef
TranscribeAudio returns the tool definition for audio transcription.