app/models/ruby_conversations/concerns/message_api_attributes.rb



# frozen_string_literal: true

module RubyConversations
  module Concerns
    # Handles API-related attribute functionality for Message
    module MessageApiAttributes
      extend ActiveSupport::Concern

      def message_attributes_for_api
        {
          request: request,
          response: response,
          model_identifier: model_identifier,
          change_description: change_description,
          llm: llm
        }.compact
      end

      def message_base_attributes
        {
          'request' => request,
          'response' => response,
          'model_identifier' => model_identifier,
          'change_description' => change_description
        }
      end

      def remote_attributes
        base_attributes.compact
      end

      private

      def base_attributes
        RubyConversations::Concerns::MessageAttributes::ATTRIBUTE_NAMES.each_with_object({}) do |attr_name, attrs|
          attrs[attr_name] = public_send(attr_name)
        end
      end
    end
  end
end