Class: DeepAgents::ToolRegistry
- Inherits:
-
Object
- Object
- DeepAgents::ToolRegistry
- Defined in:
- lib/deepagents/tools.rb
Overview
ToolRegistry class for managing tools
Instance Method Summary collapse
- #get(name) ⇒ Object
-
#initialize ⇒ ToolRegistry
constructor
A new instance of ToolRegistry.
- #list ⇒ Object
- #names ⇒ Object
- #register(tool) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ ToolRegistry
38 39 40 |
# File 'lib/deepagents/tools.rb', line 38 def initialize @tools = {} end |
Instance Method Details
#get(name) ⇒ Object
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 |
#list ⇒ Object
53 54 55 |
# File 'lib/deepagents/tools.rb', line 53 def list @tools.values end |
#names ⇒ Object
57 58 59 |
# File 'lib/deepagents/tools.rb', line 57 def names @tools.keys end |
#register(tool) ⇒ Object
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_h ⇒ Object
61 62 63 |
# File 'lib/deepagents/tools.rb', line 61 def to_h @tools.transform_values(&:to_h) end |