Module: Olyx::Guardrails::MessageContent
- Defined in:
- lib/olyx/guardrails/message_content.rb
Overview
Reads role and text from String or content-block chat messages.
Class Method Summary collapse
Class Method Details
.role(message) ⇒ Object
17 18 19 |
# File 'lib/olyx/guardrails/message_content.rb', line 17 def role() (['role'] || [:role]).to_s.downcase end |
.text(message) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/olyx/guardrails/message_content.rb', line 9 def text() content = ['content'] || [:content] return content if content.is_a?(String) return content.filter_map { |block| block_text(block) }.join(' ') if content.is_a?(Array) '' end |