logic/providers/openai/tools.rb in nano-bots-1.1.2 vs logic/providers/openai/tools.rb in nano-bots-1.2.0

- old
+ new

@@ -1,8 +1,9 @@ # frozen_string_literal: true require 'json' +require 'babosa' require_relative '../../helpers/hash' module NanoBot module Logic @@ -15,19 +16,23 @@ tools.each do |tool| tool = Helpers::Hash.symbolize_keys(tool) cartridge.each do |candidate| - next unless tool[:function][:name] == candidate[:name] + candidate_key = candidate[:name].to_slug.normalize.gsub('-', '_') + tool_key = tool[:function][:name].to_slug.normalize.gsub('-', '_') + next unless candidate_key == tool_key + source = {} source[:clojure] = candidate[:clojure] if candidate[:clojure] source[:fennel] = candidate[:fennel] if candidate[:fennel] source[:lua] = candidate[:lua] if candidate[:lua] applies << { id: tool[:id], + label: candidate[:name], name: tool[:function][:name], type: 'function', parameters: JSON.parse(tool[:function][:arguments]), source: }