Sha256: 4f12f7dcd5ce64c2003211ac17f40d934270f66ac87c1caff056578e4733b495

Contents?: true

Size: 625 Bytes

Versions: 7

Compression:

Stored size: 625 Bytes

Contents

# frozen_string_literal: true

module GenAI
  class Chat
    class OpenAI < Base
      SYSTEM_ROLE = 'system'

      private

      def build_history(messages, context, examples)
        history = []
        history << { role: SYSTEM_ROLE, content: context } if context
        history.concat(examples)
        history.concat(messages)
        history
      end

      def role(message)
        message[:role]
      end

      def transform_message(message)
        message
      end

      def append_to_message(message)
        @history.last[:content] = "#{@history.last[:content]}\n#{message}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gen-ai-0.4.3 lib/gen_ai/chat/open_ai.rb
gen-ai-0.4.2 lib/gen_ai/chat/open_ai.rb
gen-ai-0.4.1 lib/gen_ai/chat/open_ai.rb
gen-ai-0.4.0 lib/gen_ai/chat/open_ai.rb
gen-ai-0.4.0.alpha.3 lib/gen_ai/chat/open_ai.rb
gen-ai-0.4.0.alpha.2 lib/gen_ai/chat/open_ai.rb
gen-ai-0.4.0.alpha.1 lib/gen_ai/chat/open_ai.rb