Class: SolidLoop::Dialects::ReasoningPacker
- Inherits:
-
Object
- Object
- SolidLoop::Dialects::ReasoningPacker
- Defined in:
- app/services/solid_loop/dialects/reasoning_packer.rb
Class Method Summary collapse
Class Method Details
.apply_xml!(msg, reasoning) ⇒ Object
32 33 34 |
# File 'app/services/solid_loop/dialects/reasoning_packer.rb', line 32 def self.apply_xml!(msg, reasoning) msg[:content] = "<think>\n#{reasoning}\n</think>\n#{msg[:content]}" end |
.pack(msg, strategies) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/solid_loop/dialects/reasoning_packer.rb', line 6 def self.pack(msg, strategies) reasoning = msg.delete(:_sl_reasoning) signature = msg.delete(:_sl_signature) return if reasoning.blank? # 1. Determine if we have any native/specific strategies present in the array # Excluding XML and string-based fields has_native_strategy = strategies.any? { |s| s == :gemini_signed } strategies.each do |strategy| case strategy when :xml # Apply universal fallback ONLY if no native strategy is active apply_xml!(msg, reasoning) unless has_native_strategy when :xml! # FORCE XML wrapping regardless of other strategies apply_xml!(msg, reasoning) when :gemini_signed msg[:thought] = reasoning msg[:thought_signature] = signature if signature.present? when String msg[strategy.to_sym] = reasoning end end end |