Module: OllamaAgent::ChatStreamThinkingFormat
- Defined in:
- lib/ollama_agent/chat_stream_thinking_format.rb
Overview
Coerces streamed message.thinking payloads to a String before ollama-client appends with full_thinking << thinking (which raises TypeError on Hash/Array for some models/APIs).
Class Method Summary collapse
Class Method Details
.coerce_thinking_to_string(raw) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ollama_agent/chat_stream_thinking_format.rb', line 18 def coerce_thinking_to_string(raw) case raw when String then raw when Array then raw.map { |elem| coerce_thinking_to_string(elem) }.join else JSON.generate(raw) end rescue JSON::GeneratorError, TypeError raw.to_s end |
.normalize_message_thinking!(message_hash) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/ollama_agent/chat_stream_thinking_format.rb', line 9 def () return unless .is_a?(Hash) raw = ["thinking"] return if raw.nil? || raw.is_a?(String) ["thinking"] = coerce_thinking_to_string(raw) end |