llm.rb 4.16.0 → 4.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +1 -1
- data/lib/llm/active_record/acts_as_llm.rb +3 -4
- data/lib/llm/context.rb +9 -6
- data/lib/llm/sequel/plugin.rb +3 -4
- data/lib/llm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6119e0673d055f50139fd33a4523bd99ffabb0fc2688a361f23297ef9ac428fd
|
|
4
|
+
data.tar.gz: bfa5943241a2e9944245f0976458cfdd4895e7b72dbb83fd186f9d7ad2b987ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e139622d5cbaa8f42a1a6739b9792119f9086ae0b11ae896794953d9bb0fa9ed46159da7f10f7a8b619ef468404ae425b2158b359c940a11220dd48b0b230e2e
|
|
7
|
+
data.tar.gz: 563f48928b6836d2bbcbc8d72bd594aa265fa285ad99cb8ff0c9574f9e67b7da60f9d42c2eeb1bddce0ba72e1425dab260bc65670fa7d812f7a77dc8016262d7
|
data/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
Changes since `v4.16.1`.
|
|
6
|
+
|
|
7
|
+
## v4.16.1
|
|
8
|
+
|
|
5
9
|
Changes since `v4.16.0`.
|
|
6
10
|
|
|
11
|
+
This release tightens ORM persistence by removing an unnecessary JSON
|
|
12
|
+
round-trip when restoring structured `:json` and `:jsonb` context
|
|
13
|
+
payloads.
|
|
14
|
+
|
|
15
|
+
### Change
|
|
16
|
+
|
|
17
|
+
* **Restore structured ORM payloads directly** <br>
|
|
18
|
+
Teach `LLM::Context#restore` to accept parsed data payloads and use
|
|
19
|
+
that path from the ActiveRecord and Sequel persistence wrappers for
|
|
20
|
+
`format: :json` and `:jsonb`, avoiding a redundant
|
|
21
|
+
`Hash -> JSON string -> Hash` round-trip on restore.
|
|
22
|
+
|
|
7
23
|
## v4.16.0
|
|
8
24
|
|
|
9
25
|
Changes since `v4.15.0`.
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<p align="center">
|
|
5
5
|
<a href="https://0x1eef.github.io/x/llm.rb?rebuild=1"><img src="https://img.shields.io/badge/docs-0x1eef.github.io-blue.svg" alt="RubyDoc"></a>
|
|
6
6
|
<a href="https://opensource.org/license/0bsd"><img src="https://img.shields.io/badge/License-0BSD-orange.svg?" alt="License"></a>
|
|
7
|
-
<a href="https://github.com/llmrb/llm.rb/tags"><img src="https://img.shields.io/badge/version-4.16.
|
|
7
|
+
<a href="https://github.com/llmrb/llm.rb/tags"><img src="https://img.shields.io/badge/version-4.16.1-green.svg?" alt="Version"></a>
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
10
|
## About
|
|
@@ -167,12 +167,11 @@ module LLM::ActiveRecord
|
|
|
167
167
|
if data.nil? || data == ""
|
|
168
168
|
ctx
|
|
169
169
|
else
|
|
170
|
-
|
|
171
|
-
when :string then data
|
|
172
|
-
when :json, :jsonb then
|
|
170
|
+
case options[:format]
|
|
171
|
+
when :string then ctx.restore(string: data)
|
|
172
|
+
when :json, :jsonb then ctx.restore(data:)
|
|
173
173
|
else raise ArgumentError, "Unknown format: #{options[:format].inspect}"
|
|
174
174
|
end
|
|
175
|
-
ctx.restore(string:)
|
|
176
175
|
end
|
|
177
176
|
end
|
|
178
177
|
end
|
data/lib/llm/context.rb
CHANGED
|
@@ -307,18 +307,21 @@ module LLM
|
|
|
307
307
|
# The path to a JSON file
|
|
308
308
|
# @param [String, nil] string
|
|
309
309
|
# A raw JSON string
|
|
310
|
+
# @param [Hash, nil] data
|
|
311
|
+
# A parsed context payload
|
|
310
312
|
# @raise [SystemCallError]
|
|
311
313
|
# Might raise a number of SystemCallError subclasses
|
|
312
314
|
# @return [LLM::Context]
|
|
313
|
-
def deserialize(path: nil, string: nil)
|
|
314
|
-
|
|
315
|
-
|
|
315
|
+
def deserialize(path: nil, string: nil, data: nil)
|
|
316
|
+
ctx = if data
|
|
317
|
+
data
|
|
318
|
+
elsif path.nil? and string.nil?
|
|
319
|
+
raise ArgumentError, "a path, string, or data payload is required"
|
|
316
320
|
elsif path
|
|
317
|
-
::File.binread(path)
|
|
321
|
+
LLM.json.load(::File.binread(path))
|
|
318
322
|
else
|
|
319
|
-
string
|
|
323
|
+
LLM.json.load(string)
|
|
320
324
|
end
|
|
321
|
-
ctx = LLM.json.load(payload)
|
|
322
325
|
@messages.concat [*ctx["messages"]].map { deserialize_message(_1) }
|
|
323
326
|
self
|
|
324
327
|
end
|
data/lib/llm/sequel/plugin.rb
CHANGED
|
@@ -185,12 +185,11 @@ module LLM::Sequel
|
|
|
185
185
|
if data.nil? || data == ""
|
|
186
186
|
ctx
|
|
187
187
|
else
|
|
188
|
-
|
|
189
|
-
when :string then data
|
|
190
|
-
when :json, :jsonb then
|
|
188
|
+
case options[:format]
|
|
189
|
+
when :string then ctx.restore(string: data)
|
|
190
|
+
when :json, :jsonb then ctx.restore(data:)
|
|
191
191
|
else raise ArgumentError, "Unknown format: #{options[:format].inspect}"
|
|
192
192
|
end
|
|
193
|
-
ctx.restore(string:)
|
|
194
193
|
end
|
|
195
194
|
end
|
|
196
195
|
end
|
data/lib/llm/version.rb
CHANGED