dspy 0.15.5 → 0.15.6
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/lib/dspy/mixins/type_coercion.rb +4 -5
- data/lib/dspy/prediction.rb +16 -6
- data/lib/dspy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23a6a17123d707111960517ebbb8d7accb947bbd2c199aaa9dd6c2173b52a67a
|
4
|
+
data.tar.gz: b1a403bd0e4abd30e331fa2d0f84da4bef2a2078bf94d3a69481b93d40fd4d34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 955a457ef9f0a391d73212274287ef731c80861d9eb06eec34fa0bca6812a423aa1e759a454f8a1da6d8681ce4485495768cc6c94c7c3633c4b2a94ec8d16551
|
7
|
+
data.tar.gz: 90719fda7971c93494494edec7dc69de72208494153b89b67828491740a84c16aded9a8c0f1bde57ded5f22e00ca04934d583053691f53f3d4908137c00c375a
|
@@ -172,13 +172,12 @@ module DSPy
|
|
172
172
|
struct_class = type.raw_type
|
173
173
|
struct_props = struct_class.props
|
174
174
|
|
175
|
+
# ONLY include fields that exist in the struct
|
175
176
|
coerced_hash = {}
|
176
|
-
|
177
|
-
if
|
177
|
+
struct_props.each_key do |key|
|
178
|
+
if symbolized_hash.key?(key)
|
178
179
|
prop_type = struct_props[key][:type_object] || struct_props[key][:type]
|
179
|
-
coerced_hash[key] = coerce_value_to_type(
|
180
|
-
else
|
181
|
-
coerced_hash[key] = val
|
180
|
+
coerced_hash[key] = coerce_value_to_type(symbolized_hash[key], prop_type)
|
182
181
|
end
|
183
182
|
end
|
184
183
|
|
data/lib/dspy/prediction.rb
CHANGED
@@ -280,8 +280,20 @@ module DSPy
|
|
280
280
|
struct_class = type_mapping[discriminator_str]
|
281
281
|
return value unless struct_class
|
282
282
|
|
283
|
-
#
|
284
|
-
struct_class.
|
283
|
+
# Filter to only include fields defined in the struct
|
284
|
+
struct_props = struct_class.props
|
285
|
+
filtered_hash = {}
|
286
|
+
|
287
|
+
value.each do |k, v|
|
288
|
+
# Skip _type field and any fields not defined in the struct
|
289
|
+
next if k == :_type || k == "_type"
|
290
|
+
next unless struct_props.key?(k.to_sym)
|
291
|
+
|
292
|
+
filtered_hash[k.to_sym] = v
|
293
|
+
end
|
294
|
+
|
295
|
+
# Convert the filtered Hash to the appropriate struct type
|
296
|
+
struct_class.new(**filtered_hash)
|
285
297
|
rescue TypeError, ArgumentError
|
286
298
|
# If conversion fails, return the original value
|
287
299
|
value
|
@@ -335,9 +347,8 @@ module DSPy
|
|
335
347
|
else
|
336
348
|
converted_hash[k] = v
|
337
349
|
end
|
338
|
-
else
|
339
|
-
converted_hash[k] = v
|
340
350
|
end
|
351
|
+
# Skip fields not defined in the struct
|
341
352
|
end
|
342
353
|
begin
|
343
354
|
struct_class.new(**converted_hash)
|
@@ -487,9 +498,8 @@ module DSPy
|
|
487
498
|
else
|
488
499
|
converted_hash[k] = v
|
489
500
|
end
|
490
|
-
else
|
491
|
-
converted_hash[k] = v
|
492
501
|
end
|
502
|
+
# Skip fields not defined in the struct
|
493
503
|
end
|
494
504
|
return struct_class.new(**converted_hash)
|
495
505
|
rescue TypeError, ArgumentError
|
data/lib/dspy/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dspy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vicente Reig Rincón de Arellano
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-08-
|
10
|
+
date: 2025-08-05 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: dry-configurable
|