Module: ToolMeta
Overview
ToolMeta defines a DSL for annotating service classes that represent tools.
The metadata collected here becomes the source of truth for non-type
attributes such as names, descriptions, and examples.
Defined Under Namespace
Classes: MissingSignatureError
Constant Summary
collapse
- ParamMetadata =
T.type_alias do
T::Hash[Symbol, T.untyped]
end
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.clear_registry ⇒ Object
32
33
34
|
# File 'app/lib/tool_meta.rb', line 32
def self.clear_registry
@registry = []
end
|
.extended(base) ⇒ Object
19
20
21
22
23
24
|
# File 'app/lib/tool_meta.rb', line 19
def self.extended(base)
registry << base unless registry.include?(base)
base.instance_variable_set(:@tool_params, T.let([], T::Array[ParamMetadata]))
base.instance_variable_set(:@tool_name, nil)
base.instance_variable_set(:@tool_description, nil)
end
|
.registry ⇒ Object
27
28
29
|
# File 'app/lib/tool_meta.rb', line 27
def self.registry
@registry ||= []
end
|
Instance Method Details
42
43
44
|
# File 'app/lib/tool_meta.rb', line 42
def tool_description(description)
@tool_description = description
end
|
#tool_entrypoint ⇒ Object
66
67
68
|
# File 'app/lib/tool_meta.rb', line 66
def tool_entrypoint
'call'
end
|
71
72
73
74
75
76
77
78
|
# File 'app/lib/tool_meta.rb', line 71
def tool_metadata
{
name: @tool_name || default_tool_name,
description: @tool_description || '',
params: @tool_params,
entrypoint: tool_entrypoint
}
end
|
37
38
39
|
# File 'app/lib/tool_meta.rb', line 37
def tool_name(name)
@tool_name = name
end
|
55
56
57
58
59
60
61
62
63
|
# File 'app/lib/tool_meta.rb', line 55
def tool_param(name, description: nil, required: true, example: nil, enum: nil)
@tool_params << {
name: name.to_sym,
description: description,
required: required,
example: example,
enum: enum
}
end
|