Class: LlmGateway::Tool
- Inherits:
-
Object
- Object
- LlmGateway::Tool
- Defined in:
- lib/llm_gateway/tool.rb
Class Method Summary collapse
- .cache(value = nil) ⇒ Object
- .definition ⇒ Object
- .description(value = nil) ⇒ Object
- .input_schema(value = nil) ⇒ Object
- .name(value = nil) ⇒ Object
- .tool_name ⇒ Object
Instance Method Summary collapse
- #execute(input) ⇒ Object
-
#initialize(*args) ⇒ Tool
constructor
A new instance of Tool.
Constructor Details
#initialize(*args) ⇒ Tool
Returns a new instance of Tool.
5 6 7 |
# File 'lib/llm_gateway/tool.rb', line 5 def initialize(*args) # Empty constructor to allow subclasses to call super end |
Class Method Details
.cache(value = nil) ⇒ Object
24 25 26 27 |
# File 'lib/llm_gateway/tool.rb', line 24 def self.cache(value = nil) @cache = value if value @cache end |
.definition ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/llm_gateway/tool.rb', line 29 def self.definition { name: @name, description: @description, input_schema: @input_schema, cache_control: @cache ? { type: "ephemeral" } : nil }.compact end |
.description(value = nil) ⇒ Object
14 15 16 17 |
# File 'lib/llm_gateway/tool.rb', line 14 def self.description(value = nil) @description = value if value @description end |
.input_schema(value = nil) ⇒ Object
19 20 21 22 |
# File 'lib/llm_gateway/tool.rb', line 19 def self.input_schema(value = nil) @input_schema = value if value @input_schema end |
.name(value = nil) ⇒ Object
9 10 11 12 |
# File 'lib/llm_gateway/tool.rb', line 9 def self.name(value = nil) @name = value if value @name end |
.tool_name ⇒ Object
38 39 40 |
# File 'lib/llm_gateway/tool.rb', line 38 def self.tool_name definition[:name] end |
Instance Method Details
#execute(input) ⇒ Object
42 43 44 |
# File 'lib/llm_gateway/tool.rb', line 42 def execute(input) raise NotImplementedError, "Subclasses must implement execute" end |