Class: LlmGateway::Tool
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*_args, **_kwargs) ⇒ Tool
Returns a new instance of Tool.
7
8
9
|
# File 'lib/llm_gateway/tool.rb', line 7
def initialize(*_args, **_kwargs)
end
|
Class Method Details
.cache(value = nil) ⇒ Object
26
27
28
29
|
# File 'lib/llm_gateway/tool.rb', line 26
def self.cache(value = nil)
@cache = value if value
@cache
end
|
.definition ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/llm_gateway/tool.rb', line 31
def self.definition
{
name: @name,
description: @description,
input_schema: @input_schema,
cache_control: @cache ? { type: "ephemeral" } : nil
}.compact
end
|
.description(value = nil) ⇒ Object
16
17
18
19
|
# File 'lib/llm_gateway/tool.rb', line 16
def self.description(value = nil)
@description = value if value
@description
end
|
21
22
23
24
|
# File 'lib/llm_gateway/tool.rb', line 21
def self.input_schema(value = nil)
@input_schema = value if value
@input_schema
end
|
.name(value = nil) ⇒ Object
11
12
13
14
|
# File 'lib/llm_gateway/tool.rb', line 11
def self.name(value = nil)
@name = value if value
@name
end
|
40
41
42
|
# File 'lib/llm_gateway/tool.rb', line 40
def self.tool_name
definition[:name]
end
|
Instance Method Details
#execute(input, tool_use_id:) ⇒ Object
51
52
53
|
# File 'lib/llm_gateway/tool.rb', line 51
def execute(input, tool_use_id:)
raise NotImplementedError, "Subclasses must implement execute"
end
|
44
45
46
47
48
49
|
# File 'lib/llm_gateway/tool.rb', line 44
def tool_result(content, tool_use_id:)
LlmGateway::Agents::Event::ToolCallResult.new(
tool_use_id: tool_use_id,
content: content
)
end
|