Class: Kward::Tools::Base
- Inherits:
-
Object
- Object
- Kward::Tools::Base
- Defined in:
- lib/kward/tools/base.rb
Overview
Base class for model-callable tools and their JSON schemas.
Concrete built-in tools initialize this class with their model-facing name,
description, and strict argument schema, then implement call to perform
the operation. Tool execution is coordinated by Kward::ToolRegistry.
Direct Known Subclasses
AskUserQuestion, CodeSearch, ContextBudgetStats, ContextForTask, EditFile, FetchContent, FetchRaw, ListDirectory, MCPTool, ReadFile, ReadSkill, RetrieveToolOutput, RunShellCommand, SummarizeFileStructure, WebSearch, WriteFile
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Function name exposed to the model.
Instance Method Summary collapse
-
#initialize(name, description, properties: {}, required: []) ⇒ Base
constructor
Creates a tool schema definition shared by all concrete tool wrappers.
-
#schema ⇒ Hash
Returns the strict JSON schema advertised to model providers.
Constructor Details
#initialize(name, description, properties: {}, required: []) ⇒ Base
Creates a tool schema definition shared by all concrete tool wrappers.
22 23 24 25 26 27 |
# File 'lib/kward/tools/base.rb', line 22 def initialize(name, description, properties: {}, required: []) @name = name @description = description @properties = properties @required = required end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns function name exposed to the model.
14 15 16 |
# File 'lib/kward/tools/base.rb', line 14 def name @name end |
Instance Method Details
#schema ⇒ Hash
Returns the strict JSON schema advertised to model providers.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kward/tools/base.rb', line 33 def schema { type: "function", function: { name: @name, description: @description, parameters: { type: "object", properties: sorted_properties, required: @required.sort, additionalProperties: false } } } end |