Class: DeepAgents::ToolRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/deepagents/tools.rb

Overview

ToolRegistry class for managing tools

Instance Method Summary collapse

Constructor Details

#initializeToolRegistry



38
39
40
# File 'lib/deepagents/tools.rb', line 38

def initialize
  @tools = {}
end

Instance Method Details

#get(name) ⇒ Object

Raises:



47
48
49
50
51
# File 'lib/deepagents/tools.rb', line 47

def get(name)
  tool = @tools[name]
  raise ToolNotFoundError.new(name) unless tool
  tool
end

#listObject



53
54
55
# File 'lib/deepagents/tools.rb', line 53

def list
  @tools.values
end

#namesObject



57
58
59
# File 'lib/deepagents/tools.rb', line 57

def names
  @tools.keys
end

#register(tool) ⇒ Object

Raises:

  • (ArgumentError)


42
43
44
45
# File 'lib/deepagents/tools.rb', line 42

def register(tool)
  raise ArgumentError, "Tool must be a Tool instance" unless tool.is_a?(Tool)
  @tools[tool.name] = tool
end

#to_hObject



61
62
63
# File 'lib/deepagents/tools.rb', line 61

def to_h
  @tools.transform_values(&:to_h)
end