Sha256: e77d7cf63ce492a6805fc0f7224523f6a6cf031fbf4c63ea03262ed73ffbebe6

Contents?: true

Size: 892 Bytes

Versions: 5

Compression:

Stored size: 892 Bytes

Contents

# frozen_string_literal: true

module EasyTalk
  module Tools
    # 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.
    module FunctionBuilder
      # Creates a new function object based on the given model.
      #
      # @param [Model] model The EasyTalk model containing the function details.
      # @return [Hash] The function object.
      def self.new(model)
        {
          type: 'function',
          function: {
            name: model.function_name,
            description: generate_description(model),
            parameters: model.json_schema
          }
        }
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
easy_talk-0.2.1 lib/easy_talk/tools/function_builder.rb
easy_talk-0.2.0 lib/easy_talk/tools/function_builder.rb
easy_talk-0.1.10 lib/easy_talk/tools/function_builder.rb
easy_talk-0.1.9 lib/easy_talk/tools/function_builder.rb
easy_talk-0.1.8 lib/easy_talk/tools/function_builder.rb