Module: DSPy::LM::MessageFactory
- Extended by:
- T::Sig
- Defined in:
- lib/dspy/lm/message.rb
Overview
Factory for creating Message objects from various formats
Class Method Summary collapse
Class Method Details
.create(message_data) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/dspy/lm/message.rb', line 102 def self.create() return nil if .nil? # Already a Message? Return as-is return if .is_a?(Message) # Convert to hash if needed if .respond_to?(:to_h) = .to_h end return nil unless .is_a?(Hash) # Normalize keys to symbols normalized = .transform_keys(&:to_sym) create_from_hash(normalized) end |
.create_many(messages) ⇒ Object
122 123 124 |
# File 'lib/dspy/lm/message.rb', line 122 def self.create_many() .compact.map { |m| create(m) }.compact end |