Class: OpenRouter::Tool::ToolBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/open_router/tool.rb

Overview

Internal class for building tool definitions with DSL

Instance Method Summary collapse

Constructor Details

#initializeToolBuilder

Returns a new instance of ToolBuilder.



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/open_router/tool.rb', line 65

def initialize
  @definition = {
    name: nil,
    description: nil,
    parameters: {
      type: "object",
      properties: {},
      required: []
    }
  }
end

Instance Method Details

#description(value) ⇒ Object



81
82
83
# File 'lib/open_router/tool.rb', line 81

def description(value)
  @definition[:description] = value
end

#name(value) ⇒ Object



77
78
79
# File 'lib/open_router/tool.rb', line 77

def name(value)
  @definition[:name] = value
end

#parameters(&block) ⇒ Object



85
86
87
88
# File 'lib/open_router/tool.rb', line 85

def parameters(&block)
  param_builder = ParametersBuilder.new(@definition[:parameters])
  param_builder.instance_eval(&block) if block_given?
end

#to_hObject



90
91
92
# File 'lib/open_router/tool.rb', line 90

def to_h
  @definition
end