Class: OmniAgent::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/omni_agent/tool.rb,
lib/omni_agent/tool/schema_builder.rb

Defined Under Namespace

Classes: SchemaBuilder

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configured_tagsObject



21
22
23
# File 'lib/omni_agent/tool.rb', line 21

def configured_tags
  tags
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_schemaObject



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 (options = nil)
  @metadata = options if options
  @metadata || {}
end

.tags(*tag_names) ⇒ Object



15
16
17
18
19
# File 'lib/omni_agent/tool.rb', line 15

def tags(*tag_names)
  return @tags || [] if tag_names.empty?

  @tags = (tags + normalize_tags(tag_names)).uniq
end

Instance Method Details

#execute(**args) ⇒ Object

Raises:

  • (NotImplementedError)


64
65
66
# File 'lib/omni_agent/tool.rb', line 64

def execute(**args)
  raise NotImplementedError, "#{self.class.name} must implement #execute"
end