module RubyLLM::ActiveRecord::MessageMethods
Methods mixed into message models.
Public Instance Methods
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 50 def cache_read_tokens cached_value end
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 54 def cache_write_tokens cache_creation_value end
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 46 def cost RubyLLM::Cost.new(tokens:, model: model_association) end
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 29 def thinking RubyLLM::Thinking.build( text: thinking_text_value, signature: thinking_signature_value ) end
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 17 def to_llm RubyLLM::Message.new( role: role.to_sym, content: extract_content, thinking: thinking, tokens: tokens, tool_calls: extract_tool_calls, tool_call_id: extract_tool_call_id, model_id: model_association&.model_id ) end
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 58 def to_partial_path partial_prefix = self.class.name.underscore.pluralize role_partial = if to_llm.tool_call? 'tool_calls' elsif role.to_s == 'tool' 'tool' else role.to_s.presence || 'assistant' end "#{partial_prefix}/#{role_partial}" end
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 36 def tokens RubyLLM::Tokens.build( input: input_tokens, output: output_tokens, cached: cached_value, cache_creation: cache_creation_value, thinking: thinking_tokens_value ) end
Source
# File lib/ruby_llm/active_record/message_methods.rb, line 70 def tool_error_message payload_error_message(content) end