Module: Envoy::CompiledTool
- Defined in:
- lib/envoy/compiled_tool.rb
Class Method Summary collapse
-
.build(definition) ⇒ Object
Build (once) a RubyLLM::Tool subclass for a ToolDefinition.
Class Method Details
.build(definition) ⇒ Object
Build (once) a RubyLLM::Tool subclass for a ToolDefinition.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/envoy/compiled_tool.rb', line 6 def build(definition) definition.tool_class || begin klass = Class.new(RubyLLM::Tool) do @definition = definition class << self attr_reader :definition end description definition.description definition.params.each do |p| param p[:name], desc: p[:desc], type: p[:type], required: p[:required] end attr_reader :last_status def initialize(actor:) @actor = actor @last_status = nil end # RubyLLM derives the tool name from the class; override to the DSL name. def name self.class.definition.name end def execute(**args) out = Envoy::Guard.run(self.class.definition, actor: @actor, args: args) @last_status = out[:status] out[:value].to_json end end definition.tool_class = klass klass end end |