Module: LLM::Context::Deserializer Private
- Included in:
- LLM::Context
- Defined in:
- lib/llm/context/deserializer.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#deserialize(path: nil, string: nil, data: nil) ⇒ LLM::Context
(also: #restore)
private
Restore a saved context state.
Instance Method Details
#deserialize(path: nil, string: nil, data: nil) ⇒ LLM::Context Also known as: restore
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Restore a saved context state
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/llm/context/deserializer.rb', line 18 def deserialize(path: nil, string: nil, data: nil) ctx = if data data elsif path.nil? and string.nil? raise ArgumentError, "a path, string, or data payload is required" elsif path LLM.json.load(::File.binread(path)) else LLM.json.load(string) end @messages.concat [*ctx["messages"]].map { (_1) } @compacted = !!ctx["compacted"] self end |