dspy 0.15.3 → 0.15.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cc1edc860e1ab653456abf9dbeccd8b5229b17445e666ceecff554b17427094
4
- data.tar.gz: e5e595e5ff48a0f61ee6ecd1f3e537656d4b6c44d2ded5c270a7b8f040c9d6cb
3
+ metadata.gz: 51c3198b48fd7a13694d7da2cd2e59d08c20feade0fa96d07a2722a1e68847be
4
+ data.tar.gz: 868a767f203a12e03df15395a22c8308d0a1a5bcbae2faf298ae05f36c026460
5
5
  SHA512:
6
- metadata.gz: 9f4ec0f3c1b3e76e7bf0420c006f4b245f74d62118560de157742a5da9f60f3c2e669c0b3d9465982aa5d6770718e685595d54d451752e23869b83e2447e8c2b
7
- data.tar.gz: 4ba4df139927c765a31ab35235c9522c5d12c7052577501f588f6444c7dd9b3c03185250fad8a95ecd1083928b58142d9f772edde2b2f3fe8018e41c1c2c0320
6
+ metadata.gz: fa4b77bf91e75b93104a9059cf7549cb1d368f562dd5140a4e8bd57c923f1d9ad48a9cdc711829796a854f1f9bcb21339763015e6c498a65b925584e8e51fdd4
7
+ data.tar.gz: 234f127d1e947c824977b06a3d200f433316ef9900b2a666eac151987163e972493a7191eda45c1a2fa802accd5334f1e3154457d076b709f7f02b3fc500d1e6
data/README.md CHANGED
@@ -47,7 +47,7 @@ The result? LLM applications that actually scale and don't break when you sneeze
47
47
 
48
48
  ## Development Status
49
49
 
50
- DSPy.rb is actively developed and approaching stability at **v0.13.0**. The core framework is production-ready with comprehensive documentation, but I'm battle-testing features through the 0.x series before committing to a stable v1.0 API.
50
+ DSPy.rb is actively developed and approaching stability at **v0.15.4**. The core framework is production-ready with comprehensive documentation, but I'm battle-testing features through the 0.x series before committing to a stable v1.0 API.
51
51
 
52
52
  Real-world usage feedback is invaluable - if you encounter issues or have suggestions, please open a GitHub issue!
53
53
 
@@ -56,7 +56,7 @@ Real-world usage feedback is invaluable - if you encounter issues or have sugges
56
56
  ### Installation
57
57
 
58
58
  ```ruby
59
- gem 'dspy', '~> 0.13'
59
+ gem 'dspy', '~> 0.15'
60
60
  ```
61
61
 
62
62
  Or add to your Gemfile:
@@ -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
- # Create the struct instance
172
- return type.raw_type.new(**symbolized_hash)
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
@@ -388,7 +388,17 @@ module DSPy
388
388
  def needs_array_conversion?(type)
389
389
  case type
390
390
  when T::Types::TypedArray
391
- needs_struct_conversion?(type.type)
391
+ needs_struct_conversion?(type.type) || is_enum_type?(type.type)
392
+ when T::Types::Union
393
+ # Handle nilable arrays: T.nilable(T::Array[...])
394
+ if is_nilable_type?(type)
395
+ # Find the non-nil type in the union
396
+ non_nil_type = type.types.find { |t| t != T::Utils.coerce(NilClass) }
397
+ # Recursively check if it needs array conversion
398
+ needs_array_conversion?(non_nil_type)
399
+ else
400
+ false
401
+ end
392
402
  else
393
403
  false
394
404
  end
@@ -396,6 +406,13 @@ module DSPy
396
406
 
397
407
  sig { params(array: T::Array[T.untyped], type: T.untyped).returns(T::Array[T.untyped]) }
398
408
  def convert_array_elements(array, type)
409
+ # Handle nilable arrays: T.nilable(T::Array[...])
410
+ if type.is_a?(T::Types::Union) && is_nilable_type?(type)
411
+ # Find the non-nil type (should be TypedArray)
412
+ array_type = type.types.find { |t| t != T::Utils.coerce(NilClass) }
413
+ return convert_array_elements(array, array_type)
414
+ end
415
+
399
416
  return array unless type.is_a?(T::Types::TypedArray)
400
417
 
401
418
  element_type = type.type
data/lib/dspy/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSPy
4
- VERSION = "0.15.3"
4
+ VERSION = "0.15.5"
5
5
  end
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.3
4
+ version: 0.15.5
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-02 00:00:00.000000000 Z
10
+ date: 2025-08-03 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: dry-configurable