Class: OmniAgent::Tool
- Inherits:
-
Object
- Object
- OmniAgent::Tool
- Defined in:
- lib/omni_agent/tool.rb,
lib/omni_agent/tool/schema_builder.rb
Defined Under Namespace
Classes: SchemaBuilder
Class Method Summary collapse
- .configured_tags ⇒ Object
- .description(text = nil) ⇒ Object
- .input(&block) ⇒ Object
- .invoke(arguments_hash) ⇒ Object
- .json_schema ⇒ Object
- .metadata(options = nil) ⇒ Object
- .tags(*tag_names) ⇒ Object
Instance Method Summary collapse
Class Method Details
.configured_tags ⇒ Object
21 22 23 |
# File 'lib/omni_agent/tool.rb', line 21 def end |
.description(text = nil) ⇒ Object
5 6 7 8 |
# File 'lib/omni_agent/tool.rb', line 5 def description(text = nil) @description = text if text @description || "No description provided." end |
.input(&block) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/omni_agent/tool.rb', line 25 def input(&block) if block_given? builder = SchemaBuilder.new builder.instance_eval(&block) @properties = builder.properties @required = builder.required_fields end end |
.invoke(arguments_hash) ⇒ Object
44 45 46 47 |
# File 'lib/omni_agent/tool.rb', line 44 def invoke(arguments_hash) kwargs = arguments_hash.transform_keys(&:to_sym) new.execute(**kwargs) end |
.json_schema ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/omni_agent/tool.rb', line 35 def json_schema { type: "object", properties: @properties || {}, required: @required || [], additionalProperties: false } end |
.metadata(options = nil) ⇒ Object
10 11 12 13 |
# File 'lib/omni_agent/tool.rb', line 10 def ( = nil) @metadata = if @metadata || {} end |
.tags(*tag_names) ⇒ Object
15 16 17 18 19 |
# File 'lib/omni_agent/tool.rb', line 15 def (*tag_names) return @tags || [] if tag_names.empty? @tags = ( + (tag_names)).uniq end |
Instance Method Details
#execute(**args) ⇒ Object
64 65 66 |
# File 'lib/omni_agent/tool.rb', line 64 def execute(**args) raise NotImplementedError, "#{self.class.name} must implement #execute" end |