Module: EasyTalk::Tools::FunctionBuilder

Defined in:
lib/easy_talk/tools/function_builder.rb

Overview

FunctionBuilder is a module that builds a hash with the function type and function details. The return value is typically passed as argument to LLM function calling APIs.

Class Method Summary collapse

Class Method Details

.generate_description(model) ⇒ Object



23
24
25
# File 'lib/easy_talk/tools/function_builder.rb', line 23

def self.generate_description(model)
  "Correctly extracted `#{model.name}` with all the required parameters with correct types"
end

.new(model) ⇒ Hash

Creates a new function object based on the given model.

Parameters:

  • model (Model)

    The EasyTalk model containing the function details.

Returns:

  • (Hash)

    The function object.



12
13
14
15
16
17
18
19
20
21
# File 'lib/easy_talk/tools/function_builder.rb', line 12

def self.new(model)
  {
    type: 'function',
    function: {
      name: model.function_name,
      description: generate_description(model),
      parameters: model.json_schema
    }
  }
end