Class: ChatMessage
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ChatMessage
- Defined in:
- lib/generators/langsmithrb_rails/demo/templates/chat_message.rb
Overview
Model for storing chat messages
Class Method Summary collapse
-
.conversation_history(limit = 10) ⇒ Array<Hash>
Get the conversation history as an array of messages.
Class Method Details
.conversation_history(limit = 10) ⇒ Array<Hash>
Get the conversation history as an array of messages
16 17 18 19 20 21 22 23 |
# File 'lib/generators/langsmithrb_rails/demo/templates/chat_message.rb', line 16 def self.conversation_history(limit = 10) recent.limit(limit).map do || { role: .is_user? ? "user" : "assistant", content: .content } end.reverse end |