ruby-on-dspy 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01f33b3f2af5d12139c99b94900a553e6c15f7b61c8dad532712c2351b59f8ef
4
- data.tar.gz: deaa48594386a9769b3082e27b736403afb69814b0ba0585a6cb050398a5155c
3
+ metadata.gz: e0a0ffbb25ea9cd287b7a1d5b17e198a6fefec4f77659a6ab183b2f15643e511
4
+ data.tar.gz: 35c38084ace06fb4814c895402ac852ee45ba34b4add3a1f5c38592e6a1e6910
5
5
  SHA512:
6
- metadata.gz: 853231fb8fdbeab947e974ed85a5cd2f5443c1133740b66204b708f63ef5c583d5abeb97d41f507b06ba012132af10952f8cf11d6f4c66db46f87d975bf876bc
7
- data.tar.gz: a3cecf8020abd882e1b8906198accf86062285ca08fd65ffc158ea6cb3424df0ef9c5685eebc7bc254f0cdfd770d05c8435282b6035ed1849410fde1f3ff5da7
6
+ metadata.gz: a2c14836562e25cc5c71a340752ca4cf490d603c49018a33604ec91505a04190ab2c475f61a016b290aadc008295c67c6c5afadfa5f0db3ef5d2045e9d987a7e
7
+ data.tar.gz: f9f48a1abc6f246175a0a714d69356437f2eeb8a5d220da55f2a5b1ce40437b5b6faeeb097d3541afe28c584d9e81097f70b4a525b5af7aff7574118f7c2e5c7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1 (2026-12-01)
4
+
5
+ - `save` and `load` take a `Pathname`, such as `Rails.root.join("answer.json")`, as well as a String. Saving into a folder that doesn't exist raises `DSPyRb::Error`; create the folder first.
6
+
3
7
  ## 0.1.0 (2026-12-01)
4
8
 
5
9
  The first release, under active development. Ruby on DSPy gives you DSPy's API in Ruby, and the real DSPy 3.5.0 runs it.
data/README.md CHANGED
@@ -4,7 +4,7 @@ Ruby bindings for [DSPy](https://dspy.ai).
4
4
 
5
5
  > **Under active development.** Until 1.0, a minor release may change the API; the [CHANGELOG](CHANGELOG.md) says what changed and what to do.
6
6
 
7
- Ruby on DSPy (`ruby-on-dspy`) gives you DSPy's API in Ruby. Signatures, predictors, programs, tools and evaluations are Ruby classes, and the real DSPy 3.5.0 runs them, so you get DSPy's exact prompts, behaviour and results without leaving Ruby.
7
+ Ruby on DSPy (`ruby-on-dspy`) gives you DSPy's API in Ruby. Signatures, predictors, programs, tools and evaluations are Ruby classes, and the real DSPy 3.5.0 runs them, so your programs get DSPy's own prompts, adapters and optimizers without leaving Ruby.
8
8
 
9
9
  Unlike [DSPy.rb](https://github.com/vicentereig/dspy.rb), a Ruby reimplementation, it runs DSPy itself.
10
10
 
@@ -324,7 +324,7 @@ compiled.save("answer.json")
324
324
  Answer.new.load("answer.json") # in place, as in DSPy; it returns the program
325
325
  ```
326
326
 
327
- A predictor's `load` returns a copy. The path ends in `.json`; pickles are never read or written.
327
+ A predictor's `load` returns a copy. The path, a String or a Pathname, ends in `.json` in a folder that exists; pickles are never read or written.
328
328
 
329
329
  ## Usage and cost
330
330
 
@@ -29,7 +29,13 @@ module DSPyRb
29
29
 
30
30
  raise Error, "#{place} saves DSPy's JSON state, never a pickle: save_program: true is refused" if save_program
31
31
 
32
- Context.reply(Wire::SaveState, Wire::StateSaved, program: description, path: json_file(path, place, "writes"))
32
+ file = json_file(path, place, "writes")
33
+ folder = File.dirname(file)
34
+
35
+ # DSPy doesn't make the folder, and its error then suggests a pickle (base_module.py:228-239).
36
+ raise Error, "#{place} finds no folder for the path: create it first" unless File.directory?(folder)
37
+
38
+ Context.reply(Wire::SaveState, Wire::StateSaved, program: description, path: file)
33
39
 
34
40
  nil
35
41
  end
@@ -108,14 +114,16 @@ module DSPyRb
108
114
 
109
115
  # The file at `path` in full, as the wire takes it; only .json, which DSPy reads as JSON, so never a pickle.
110
116
  def json_file(path, place, verb)
111
- raise Error, "#{place} takes a path as a String, not #{Error.class_of(path)}" unless path.is_a?(::String)
117
+ unless path.respond_to?(:to_path) || path.respond_to?(:to_str)
118
+ raise Error, "#{place} takes a path as a String or a Pathname, not #{Error.class_of(path)}"
119
+ end
112
120
 
113
- file = Wire::Types::Path[path]
121
+ file = Wire::Types::Path[File.path(path)]
114
122
 
115
123
  return file if File.extname(file) == ".json"
116
124
 
117
125
  raise Error, "#{place} #{verb} DSPy's JSON state: the path must end in .json"
118
- rescue Dry::Types::CoercionError
126
+ rescue ArgumentError, Dry::Types::CoercionError
119
127
  why = "it starts with a ~ that can't be expanded, or holds a null byte"
120
128
 
121
129
  # No cause: Ruby's error quotes the path, which can hold a user's name.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DSPyRb
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
 
6
6
  # Must match python/pyproject.toml's pin.
7
7
  DSPY_VERSION = "3.5.0"
@@ -9,7 +9,7 @@ if TYPE_CHECKING:
9
9
  from _typeshed import DataclassInstance
10
10
 
11
11
  PROTOCOL: Final = 4
12
- PACKAGE: Final = "0.1.0"
12
+ PACKAGE: Final = "0.1.1"
13
13
  REQUESTS_FD: Final = 3
14
14
  REPLIES_FD: Final = 4
15
15
  ALIVE_INTERVAL: Final = 1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "protocol": 4,
3
- "package": "0.1.0",
3
+ "package": "0.1.1",
4
4
  "requests_fd": 3,
5
5
  "replies_fd": 4,
6
6
  "alive_interval": 1,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-on-dspy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Ralak
@@ -79,8 +79,8 @@ dependencies:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '2.13'
82
- description: DSPy's API in Ruby. Signatures, predictors and modules are Ruby classes;
83
- the real DSPy 3.5.0 runs them, in a Python process the gem installs and manages.
82
+ description: Write programs in Ruby and tune them with DSPy's own optimizers. The
83
+ real DSPy runs them, installed and managed by the gem.
84
84
  executables:
85
85
  - ruby-on-dspy
86
86
  extensions: []
@@ -226,5 +226,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
226
  requirements: []
227
227
  rubygems_version: 4.0.3
228
228
  specification_version: 4
229
- summary: 'Ruby on DSPy: Ruby bindings for DSPy'
229
+ summary: Build LLM apps, agents and evals in Ruby with DSPy.
230
230
  test_files: []