diff options
Diffstat (limited to 'logic/providers/openai')
-rw-r--r-- | logic/providers/openai/tokens.rb | 16 | ||||
-rw-r--r-- | logic/providers/openai/tools.rb | 7 |
2 files changed, 22 insertions, 1 deletions
diff --git a/logic/providers/openai/tokens.rb b/logic/providers/openai/tokens.rb new file mode 100644 index 0000000..60efa60 --- /dev/null +++ b/logic/providers/openai/tokens.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +require 'openai' + +module NanoBot + module Logic + module OpenAI + module Tokens + def self.apply_policies!(_cartridge, payload) + payload[:messages] = payload[:messages].map { |message| message.except(:_meta) } + payload + end + end + end + end +end diff --git a/logic/providers/openai/tools.rb b/logic/providers/openai/tools.rb index 1b2882a..f00176c 100644 --- a/logic/providers/openai/tools.rb +++ b/logic/providers/openai/tools.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'json' +require 'babosa' require_relative '../../helpers/hash' @@ -17,7 +18,10 @@ module NanoBot 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 = {} @@ -27,6 +31,7 @@ module NanoBot applies << { id: tool[:id], + label: candidate[:name], name: tool[:function][:name], type: 'function', parameters: JSON.parse(tool[:function][:arguments]), |