dspy 0.15.3 → 0.15.4
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 +18 -4
- data/lib/dspy/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: e7154d8c22730a4216467c15a71d3adf4e2826e49211dfde7fd20e20344e4d4b
|
4
|
+
data.tar.gz: 4e3450f2b5d9e8acf2a5b583a3180bec0608b4c948a9b860bcd8bd387dc0bb7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36f07d86290d95e91ac8842807739d9edd566e3b9694413060181266611ea6fa1de941a509feb4518dfd3cf97f922689f8f15df7f6d3182cae0bef1b94b785cb
|
7
|
+
data.tar.gz: ad2a480af294da127d6fc6b54c56f66e9c59829e86c4dab70c6427d5b9dc6a7a9e26381f35448e9a8b514326169784ba160a92ba488fc06a9e47fcdacd2a2814
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# typed: strict
|
1
|
+
54 # typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'sorbet-runtime'
|
@@ -168,8 +168,22 @@ module DSPy
|
|
168
168
|
symbolized_hash = value.transform_keys(&:to_sym)
|
169
169
|
symbolized_hash.delete(:_type)
|
170
170
|
|
171
|
-
#
|
172
|
-
|
171
|
+
# Coerce struct field values based on their types
|
172
|
+
struct_class = type.raw_type
|
173
|
+
struct_props = struct_class.props
|
174
|
+
|
175
|
+
coerced_hash = {}
|
176
|
+
symbolized_hash.each do |key, val|
|
177
|
+
if struct_props[key]
|
178
|
+
prop_type = struct_props[key][:type_object] || struct_props[key][:type]
|
179
|
+
coerced_hash[key] = coerce_value_to_type(val, prop_type)
|
180
|
+
else
|
181
|
+
coerced_hash[key] = val
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Create the struct instance with coerced values
|
186
|
+
return struct_class.new(**coerced_hash)
|
173
187
|
end
|
174
188
|
end
|
175
189
|
end
|
@@ -183,4 +197,4 @@ module DSPy
|
|
183
197
|
end
|
184
198
|
end
|
185
199
|
end
|
186
|
-
end
|
200
|
+
end
|
data/lib/dspy/version.rb
CHANGED