Module: Agents::Helpers::MessageExtractor
- Defined in:
- lib/agents/helpers/message_extractor.rb
Class Method Summary collapse
-
.content_empty?(content) ⇒ Boolean
Check if content is considered empty (handles both String and Hash content).
-
.extract_messages(chat, current_agent) ⇒ Array<Hash>
Extract messages from a chat object for conversation history persistence.
Class Method Details
.content_empty?(content) ⇒ Boolean
Check if content is considered empty (handles both String and Hash content)
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/agents/helpers/message_extractor.rb', line 27 def content_empty?(content) case content when String content.strip.empty? when Hash content.empty? else content.nil? end end |
.extract_messages(chat, current_agent) ⇒ Array<Hash>
Extract messages from a chat object for conversation history persistence
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/agents/helpers/message_extractor.rb', line 43 def (chat, current_agent) return [] unless chat.respond_to?(:messages) chat..filter_map do |msg| case msg.role when :user, :assistant (msg, current_agent) when :tool (msg) end end end |