Module: RubyLLM::SemanticCache::Serializer
- Defined in:
- lib/ruby_llm/semantic_cache/serializer.rb
Overview
Handles serialization/deserialization of cached responses
Class Method Summary collapse
Class Method Details
.deserialize(data) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruby_llm/semantic_cache/serializer.rb', line 16 def deserialize(data) return data unless data.is_a?(Hash) type = data[:type] || data["type"] value = data[:value] || data["value"] case type when "rubyllm_message" (value) when "string", "hash", "object" value when "nil" nil else value end end |
.serialize(response) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/ruby_llm/semantic_cache/serializer.rb', line 8 def serialize(response) if defined?(RubyLLM::Message) && response.is_a?(RubyLLM::Message) (response) else serialize_basic(response) end end |