desiru 0.1.0
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 +7 -0
- data/.rspec +1 -0
- data/.rubocop.yml +55 -0
- data/CLAUDE.md +22 -0
- data/Gemfile +36 -0
- data/Gemfile.lock +255 -0
- data/LICENSE +21 -0
- data/README.md +343 -0
- data/Rakefile +18 -0
- data/desiru.gemspec +44 -0
- data/examples/README.md +55 -0
- data/examples/async_processing.rb +135 -0
- data/examples/few_shot_learning.rb +66 -0
- data/examples/graphql_api.rb +190 -0
- data/examples/graphql_integration.rb +114 -0
- data/examples/rag_retrieval.rb +80 -0
- data/examples/simple_qa.rb +31 -0
- data/examples/typed_signatures.rb +45 -0
- data/lib/desiru/async_capable.rb +170 -0
- data/lib/desiru/cache.rb +116 -0
- data/lib/desiru/configuration.rb +40 -0
- data/lib/desiru/field.rb +171 -0
- data/lib/desiru/graphql/data_loader.rb +210 -0
- data/lib/desiru/graphql/executor.rb +115 -0
- data/lib/desiru/graphql/schema_generator.rb +301 -0
- data/lib/desiru/jobs/async_predict.rb +52 -0
- data/lib/desiru/jobs/base.rb +53 -0
- data/lib/desiru/jobs/batch_processor.rb +71 -0
- data/lib/desiru/jobs/optimizer_job.rb +45 -0
- data/lib/desiru/models/base.rb +112 -0
- data/lib/desiru/models/raix_adapter.rb +210 -0
- data/lib/desiru/module.rb +204 -0
- data/lib/desiru/modules/chain_of_thought.rb +106 -0
- data/lib/desiru/modules/predict.rb +142 -0
- data/lib/desiru/modules/retrieve.rb +199 -0
- data/lib/desiru/optimizers/base.rb +130 -0
- data/lib/desiru/optimizers/bootstrap_few_shot.rb +212 -0
- data/lib/desiru/program.rb +106 -0
- data/lib/desiru/registry.rb +74 -0
- data/lib/desiru/signature.rb +322 -0
- data/lib/desiru/version.rb +5 -0
- data/lib/desiru.rb +67 -0
- metadata +184 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 483d9107e403dc8c29d5b3621ca65876eaf4b4fb19fadd5b59bc39a12b005e5f
|
4
|
+
data.tar.gz: 58b101dc3f69a6c215a6edda23b4895eaa92007dcf2fbe3710705349c8e48f78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1c90f98e10e42dc1bd59631bb5498c35368a46c4db01bb62fafadeb8cb36f4977d2e58ef1af8b23242428047fc10ea1b9edb3cfe2f139173c0405e22040ee74
|
7
|
+
data.tar.gz: b2060d56c756f30218ab977a0c45d59294d231c5d7b179cadb19483a2af144537e45b40d8f57821f045f23b0e5072ec2086e69bb8e2e04a03f13210d0c6e6494
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.4
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
Exclude:
|
6
|
+
- 'vendor/**/*'
|
7
|
+
- 'tmp/**/*'
|
8
|
+
- 'bin/**/*'
|
9
|
+
- 'spec/fixtures/**/*'
|
10
|
+
|
11
|
+
require:
|
12
|
+
- rubocop-rake
|
13
|
+
- rubocop-rspec
|
14
|
+
|
15
|
+
# Relaxed metrics for DSL-heavy library code
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 20
|
18
|
+
Exclude:
|
19
|
+
- 'spec/**/*'
|
20
|
+
|
21
|
+
Metrics/ClassLength:
|
22
|
+
Max: 150
|
23
|
+
Exclude:
|
24
|
+
- 'spec/**/*'
|
25
|
+
|
26
|
+
Metrics/BlockLength:
|
27
|
+
Max: 30
|
28
|
+
Exclude:
|
29
|
+
- 'spec/**/*'
|
30
|
+
- '*.gemspec'
|
31
|
+
|
32
|
+
Metrics/AbcSize:
|
33
|
+
Max: 25
|
34
|
+
|
35
|
+
Metrics/CyclomaticComplexity:
|
36
|
+
Max: 10
|
37
|
+
|
38
|
+
Metrics/ParameterLists:
|
39
|
+
Max: 6
|
40
|
+
|
41
|
+
# Documentation is nice but not required for internal classes
|
42
|
+
Style/Documentation:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/StringLiterals:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Allow longer lines for readability
|
49
|
+
Layout/LineLength:
|
50
|
+
Max: 120
|
51
|
+
Exclude:
|
52
|
+
- 'spec/**/*'
|
53
|
+
|
54
|
+
Gemspec/RequireMFA:
|
55
|
+
Enabled: false
|
data/CLAUDE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# CLAUDE.md
|
2
|
+
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
4
|
+
|
5
|
+
## Project Overview
|
6
|
+
|
7
|
+
Desiru (Declarative Self-Improving Ruby) - A Ruby implementation of DSPy for programming language models.
|
8
|
+
|
9
|
+
## Development Environment
|
10
|
+
|
11
|
+
- Use the `be` alias for `bundle exec`
|
12
|
+
|
13
|
+
## Project Status
|
14
|
+
|
15
|
+
This project is in its initial setup phase. When implementing features:
|
16
|
+
- Create appropriate directory structure as needed (lib/, spec/, bin/, etc.)
|
17
|
+
- Follow Ruby community conventions for project organization
|
18
|
+
- Set up bundler with a Gemfile when adding dependencies
|
19
|
+
|
20
|
+
## Workflow Guidance
|
21
|
+
|
22
|
+
- For maximum efficiency, whenever you need to perform multiple independent operations, invoke all relevant tools simultaneously rather than sequentially.
|
data/Gemfile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
ruby '~> 3.4.2'
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in desiru.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'pry', '~> 0.14'
|
12
|
+
gem 'pry-byebug', '~> 3.10'
|
13
|
+
gem 'rake', '~> 13.0'
|
14
|
+
gem 'rspec', '~> 3.0'
|
15
|
+
gem 'rubocop', '~> 1.21'
|
16
|
+
gem 'rubocop-rake', '~> 0.6'
|
17
|
+
gem 'rubocop-rspec', '~> 2.0'
|
18
|
+
gem 'simplecov', '~> 0.22', require: false
|
19
|
+
gem 'yard', '~> 0.9'
|
20
|
+
end
|
21
|
+
|
22
|
+
# LLM interaction dependencies
|
23
|
+
gem 'faraday', '~> 2.0'
|
24
|
+
gem 'faraday-retry', '~> 2.0'
|
25
|
+
gem 'raix', '~> 0.4'
|
26
|
+
|
27
|
+
# GraphQL support
|
28
|
+
gem 'graphql', '~> 2.0'
|
29
|
+
|
30
|
+
# Optional dependencies for enhanced functionality
|
31
|
+
group :optional do
|
32
|
+
gem 'async', '~> 2.0' # For concurrent operations
|
33
|
+
gem 'dry-struct', '~> 1.0' # For type safety
|
34
|
+
gem 'dry-validation', '~> 1.0' # For validation
|
35
|
+
gem 'redis', '~> 5.0' # For caching
|
36
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
desiru (0.1.0)
|
5
|
+
forwardable (~> 1.3)
|
6
|
+
redis (~> 5.0)
|
7
|
+
sidekiq (~> 7.2)
|
8
|
+
singleton (~> 0.1)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (8.0.2)
|
14
|
+
base64
|
15
|
+
benchmark (>= 0.3)
|
16
|
+
bigdecimal
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
18
|
+
connection_pool (>= 2.2.5)
|
19
|
+
drb
|
20
|
+
i18n (>= 1.6, < 2)
|
21
|
+
logger (>= 1.4.2)
|
22
|
+
minitest (>= 5.1)
|
23
|
+
securerandom (>= 0.3)
|
24
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
25
|
+
uri (>= 0.13.1)
|
26
|
+
ast (2.4.3)
|
27
|
+
async (2.25.0)
|
28
|
+
console (~> 1.29)
|
29
|
+
fiber-annotation
|
30
|
+
io-event (~> 1.11)
|
31
|
+
metrics (~> 0.12)
|
32
|
+
traces (~> 0.15)
|
33
|
+
base64 (0.3.0)
|
34
|
+
benchmark (0.4.1)
|
35
|
+
bigdecimal (3.2.2)
|
36
|
+
byebug (12.0.0)
|
37
|
+
coderay (1.1.3)
|
38
|
+
concurrent-ruby (1.3.5)
|
39
|
+
connection_pool (2.5.3)
|
40
|
+
console (1.31.0)
|
41
|
+
fiber-annotation
|
42
|
+
fiber-local (~> 1.1)
|
43
|
+
json
|
44
|
+
diff-lcs (1.6.2)
|
45
|
+
docile (1.4.1)
|
46
|
+
dotenv (3.1.8)
|
47
|
+
drb (2.2.3)
|
48
|
+
dry-configurable (1.3.0)
|
49
|
+
dry-core (~> 1.1)
|
50
|
+
zeitwerk (~> 2.6)
|
51
|
+
dry-core (1.1.0)
|
52
|
+
concurrent-ruby (~> 1.0)
|
53
|
+
logger
|
54
|
+
zeitwerk (~> 2.6)
|
55
|
+
dry-inflector (1.2.0)
|
56
|
+
dry-initializer (3.2.0)
|
57
|
+
dry-logic (1.6.0)
|
58
|
+
bigdecimal
|
59
|
+
concurrent-ruby (~> 1.0)
|
60
|
+
dry-core (~> 1.1)
|
61
|
+
zeitwerk (~> 2.6)
|
62
|
+
dry-schema (1.14.1)
|
63
|
+
concurrent-ruby (~> 1.0)
|
64
|
+
dry-configurable (~> 1.0, >= 1.0.1)
|
65
|
+
dry-core (~> 1.1)
|
66
|
+
dry-initializer (~> 3.2)
|
67
|
+
dry-logic (~> 1.5)
|
68
|
+
dry-types (~> 1.8)
|
69
|
+
zeitwerk (~> 2.6)
|
70
|
+
dry-struct (1.8.0)
|
71
|
+
dry-core (~> 1.1)
|
72
|
+
dry-types (~> 1.8, >= 1.8.2)
|
73
|
+
ice_nine (~> 0.11)
|
74
|
+
zeitwerk (~> 2.6)
|
75
|
+
dry-types (1.8.3)
|
76
|
+
bigdecimal (~> 3.0)
|
77
|
+
concurrent-ruby (~> 1.0)
|
78
|
+
dry-core (~> 1.0)
|
79
|
+
dry-inflector (~> 1.0)
|
80
|
+
dry-logic (~> 1.4)
|
81
|
+
zeitwerk (~> 2.6)
|
82
|
+
dry-validation (1.11.1)
|
83
|
+
concurrent-ruby (~> 1.0)
|
84
|
+
dry-core (~> 1.1)
|
85
|
+
dry-initializer (~> 3.2)
|
86
|
+
dry-schema (~> 1.14)
|
87
|
+
zeitwerk (~> 2.6)
|
88
|
+
event_stream_parser (1.0.0)
|
89
|
+
faraday (2.13.1)
|
90
|
+
faraday-net_http (>= 2.0, < 3.5)
|
91
|
+
json
|
92
|
+
logger
|
93
|
+
faraday-multipart (1.1.0)
|
94
|
+
multipart-post (~> 2.0)
|
95
|
+
faraday-net_http (3.4.1)
|
96
|
+
net-http (>= 0.5.0)
|
97
|
+
faraday-retry (2.3.1)
|
98
|
+
faraday (~> 2.0)
|
99
|
+
fiber-annotation (0.2.0)
|
100
|
+
fiber-local (1.1.0)
|
101
|
+
fiber-storage
|
102
|
+
fiber-storage (1.0.1)
|
103
|
+
forwardable (1.3.3)
|
104
|
+
graphql (2.5.9)
|
105
|
+
base64
|
106
|
+
fiber-storage
|
107
|
+
logger
|
108
|
+
i18n (1.14.7)
|
109
|
+
concurrent-ruby (~> 1.0)
|
110
|
+
ice_nine (0.11.2)
|
111
|
+
io-event (1.11.0)
|
112
|
+
json (2.12.2)
|
113
|
+
language_server-protocol (3.17.0.5)
|
114
|
+
lint_roller (1.1.0)
|
115
|
+
logger (1.7.0)
|
116
|
+
method_source (1.1.0)
|
117
|
+
metrics (0.12.2)
|
118
|
+
minitest (5.25.5)
|
119
|
+
multipart-post (2.4.1)
|
120
|
+
net-http (0.6.0)
|
121
|
+
uri
|
122
|
+
open_router (0.3.3)
|
123
|
+
activesupport (>= 6.0)
|
124
|
+
dotenv (>= 2)
|
125
|
+
faraday (>= 1)
|
126
|
+
faraday-multipart (>= 1)
|
127
|
+
ostruct (0.6.1)
|
128
|
+
parallel (1.27.0)
|
129
|
+
parser (3.3.8.0)
|
130
|
+
ast (~> 2.4.1)
|
131
|
+
racc
|
132
|
+
prism (1.4.0)
|
133
|
+
pry (0.15.2)
|
134
|
+
coderay (~> 1.1)
|
135
|
+
method_source (~> 1.0)
|
136
|
+
pry-byebug (3.11.0)
|
137
|
+
byebug (~> 12.0)
|
138
|
+
pry (>= 0.13, < 0.16)
|
139
|
+
racc (1.8.1)
|
140
|
+
rack (3.1.16)
|
141
|
+
rainbow (3.1.1)
|
142
|
+
raix (0.9.2)
|
143
|
+
activesupport (>= 6.0)
|
144
|
+
faraday-retry (~> 2.0)
|
145
|
+
open_router (~> 0.2)
|
146
|
+
ostruct
|
147
|
+
ruby-openai (~> 7)
|
148
|
+
rake (13.3.0)
|
149
|
+
redis (5.4.0)
|
150
|
+
redis-client (>= 0.22.0)
|
151
|
+
redis-client (0.25.0)
|
152
|
+
connection_pool
|
153
|
+
regexp_parser (2.10.0)
|
154
|
+
rspec (3.13.1)
|
155
|
+
rspec-core (~> 3.13.0)
|
156
|
+
rspec-expectations (~> 3.13.0)
|
157
|
+
rspec-mocks (~> 3.13.0)
|
158
|
+
rspec-core (3.13.4)
|
159
|
+
rspec-support (~> 3.13.0)
|
160
|
+
rspec-expectations (3.13.5)
|
161
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
162
|
+
rspec-support (~> 3.13.0)
|
163
|
+
rspec-mocks (3.13.5)
|
164
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
165
|
+
rspec-support (~> 3.13.0)
|
166
|
+
rspec-support (3.13.4)
|
167
|
+
rubocop (1.76.2)
|
168
|
+
json (~> 2.3)
|
169
|
+
language_server-protocol (~> 3.17.0.2)
|
170
|
+
lint_roller (~> 1.1.0)
|
171
|
+
parallel (~> 1.10)
|
172
|
+
parser (>= 3.3.0.2)
|
173
|
+
rainbow (>= 2.2.2, < 4.0)
|
174
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
175
|
+
rubocop-ast (>= 1.45.1, < 2.0)
|
176
|
+
ruby-progressbar (~> 1.7)
|
177
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
178
|
+
rubocop-ast (1.45.1)
|
179
|
+
parser (>= 3.3.7.2)
|
180
|
+
prism (~> 1.4)
|
181
|
+
rubocop-capybara (2.22.1)
|
182
|
+
lint_roller (~> 1.1)
|
183
|
+
rubocop (~> 1.72, >= 1.72.1)
|
184
|
+
rubocop-factory_bot (2.27.1)
|
185
|
+
lint_roller (~> 1.1)
|
186
|
+
rubocop (~> 1.72, >= 1.72.1)
|
187
|
+
rubocop-rake (0.7.1)
|
188
|
+
lint_roller (~> 1.1)
|
189
|
+
rubocop (>= 1.72.1)
|
190
|
+
rubocop-rspec (2.31.0)
|
191
|
+
rubocop (~> 1.40)
|
192
|
+
rubocop-capybara (~> 2.17)
|
193
|
+
rubocop-factory_bot (~> 2.22)
|
194
|
+
rubocop-rspec_rails (~> 2.28)
|
195
|
+
rubocop-rspec_rails (2.29.1)
|
196
|
+
rubocop (~> 1.61)
|
197
|
+
ruby-openai (7.4.0)
|
198
|
+
event_stream_parser (>= 0.3.0, < 2.0.0)
|
199
|
+
faraday (>= 1)
|
200
|
+
faraday-multipart (>= 1)
|
201
|
+
ruby-progressbar (1.13.0)
|
202
|
+
securerandom (0.4.1)
|
203
|
+
sidekiq (7.3.9)
|
204
|
+
base64
|
205
|
+
connection_pool (>= 2.3.0)
|
206
|
+
logger
|
207
|
+
rack (>= 2.2.4)
|
208
|
+
redis-client (>= 0.22.2)
|
209
|
+
simplecov (0.22.0)
|
210
|
+
docile (~> 1.1)
|
211
|
+
simplecov-html (~> 0.11)
|
212
|
+
simplecov_json_formatter (~> 0.1)
|
213
|
+
simplecov-html (0.13.1)
|
214
|
+
simplecov_json_formatter (0.1.4)
|
215
|
+
singleton (0.3.0)
|
216
|
+
traces (0.15.2)
|
217
|
+
tzinfo (2.0.6)
|
218
|
+
concurrent-ruby (~> 1.0)
|
219
|
+
unicode-display_width (3.1.4)
|
220
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
221
|
+
unicode-emoji (4.0.4)
|
222
|
+
uri (1.0.3)
|
223
|
+
yard (0.9.37)
|
224
|
+
zeitwerk (2.7.3)
|
225
|
+
|
226
|
+
PLATFORMS
|
227
|
+
arm64-darwin-23
|
228
|
+
ruby
|
229
|
+
|
230
|
+
DEPENDENCIES
|
231
|
+
async (~> 2.0)
|
232
|
+
bundler (~> 2.0)
|
233
|
+
desiru!
|
234
|
+
dry-struct (~> 1.0)
|
235
|
+
dry-validation (~> 1.0)
|
236
|
+
faraday (~> 2.0)
|
237
|
+
faraday-retry (~> 2.0)
|
238
|
+
graphql (~> 2.0)
|
239
|
+
pry (~> 0.14)
|
240
|
+
pry-byebug (~> 3.10)
|
241
|
+
raix (~> 0.4)
|
242
|
+
rake (~> 13.0)
|
243
|
+
redis (~> 5.0)
|
244
|
+
rspec (~> 3.0)
|
245
|
+
rubocop (~> 1.21)
|
246
|
+
rubocop-rake (~> 0.6)
|
247
|
+
rubocop-rspec (~> 2.0)
|
248
|
+
simplecov (~> 0.22)
|
249
|
+
yard (~> 0.9)
|
250
|
+
|
251
|
+
RUBY VERSION
|
252
|
+
ruby 3.4.2p28
|
253
|
+
|
254
|
+
BUNDLED WITH
|
255
|
+
2.6.8
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Obie Fernandez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|