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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/lib/dspy_rb/execution/program.rb +12 -4
- data/lib/dspy_rb/version.rb +1 -1
- data/python/dspy_rb/wire/shapes.py +1 -1
- data/python/dspy_rb/wire/wire.json +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0a0ffbb25ea9cd287b7a1d5b17e198a6fefec4f77659a6ab183b2f15643e511
|
|
4
|
+
data.tar.gz: 35c38084ace06fb4814c895402ac852ee45ba34b4add3a1f5c38592e6a1e6910
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
data/lib/dspy_rb/version.rb
CHANGED
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.
|
|
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:
|
|
83
|
-
|
|
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:
|
|
229
|
+
summary: Build LLM apps, agents and evals in Ruby with DSPy.
|
|
230
230
|
test_files: []
|