From d9a5079555d24a88f68a79dd84207e9cfb034e3c Mon Sep 17 00:00:00 2001 From: icebaker Date: Fri, 29 Dec 2023 16:10:42 -0300 Subject: adding support to cohere --- logic/cartridge/streaming.rb | 2 +- logic/providers/cohere/tokens.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 logic/providers/cohere/tokens.rb (limited to 'logic') diff --git a/logic/cartridge/streaming.rb b/logic/cartridge/streaming.rb index 0b9b19f..23e88ac 100644 --- a/logic/cartridge/streaming.rb +++ b/logic/cartridge/streaming.rb @@ -8,7 +8,7 @@ module NanoBot module Streaming def self.enabled?(cartridge, interface) provider_stream = case Helpers::Hash.fetch(cartridge, %i[provider id]) - when 'openai', 'mistral' + when 'openai', 'mistral', 'cohere' Helpers::Hash.fetch(cartridge, %i[provider settings stream]) when 'google' Helpers::Hash.fetch(cartridge, %i[provider options stream]) diff --git a/logic/providers/cohere/tokens.rb b/logic/providers/cohere/tokens.rb new file mode 100644 index 0000000..f7d3f55 --- /dev/null +++ b/logic/providers/cohere/tokens.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module NanoBot + module Logic + module Cohere + module Tokens + def self.apply_policies!(_cartridge, payload) + if payload[:chat_history] + payload[:chat_history] = payload[:chat_history].map { |message| message.except(:_meta) } + end + + payload + end + end + end + end +end -- cgit v1.2.3