ruby_llm-schema 0.2.1 → 0.2.3
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/README.md +71 -0
- data/lib/ruby_llm/schema/dsl/complex_types.rb +4 -0
- data/lib/ruby_llm/schema/dsl/schema_builders.rb +9 -0
- data/lib/ruby_llm/schema/version.rb +1 -1
- data/lib/ruby_llm/schema.rb +1 -1
- data/lib/tasks/release.rake +27 -21
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47e7d91e407e2996b26bf9931b71a54b1218c64ec35051c30a22e874d85914f1
|
|
4
|
+
data.tar.gz: 0d31b92017e2578df488788129f17a4e5667877bf80f6bdaf1196895224e90f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2e0bfdb82d0b91cc0eb24b22aade5368237470c97de48682e5d21e9d7b4bfa9f6ea156abc2f12fec9a087ebe912b43cbabcdd0db597df3684e72467aafbe97b2
|
|
7
|
+
data.tar.gz: 5e4e43be22d16ef7a783c947761a3d7924b3939949852e13c278172d60cd5fcb2f053540707d3d8063a310bad2ce130ace41af39be192fe183e266db7e45ae5e
|
data/README.md
CHANGED
|
@@ -311,6 +311,77 @@ class CompanySchema < RubyLLM::Schema
|
|
|
311
311
|
PersonSchema.new
|
|
312
312
|
end
|
|
313
313
|
end
|
|
314
|
+
|
|
315
|
+
schema = CompanySchema.new
|
|
316
|
+
schema.to_json_schema
|
|
317
|
+
# =>
|
|
318
|
+
# {
|
|
319
|
+
# "name":"CompanySchema",
|
|
320
|
+
# "description":"nil",
|
|
321
|
+
# "schema":{
|
|
322
|
+
# "type":"object",
|
|
323
|
+
# "properties":{
|
|
324
|
+
# "ceo":{
|
|
325
|
+
# "type":"object",
|
|
326
|
+
# "properties":{
|
|
327
|
+
# "name":{
|
|
328
|
+
# "type":"string"
|
|
329
|
+
# },
|
|
330
|
+
# "age":{
|
|
331
|
+
# "type":"integer"
|
|
332
|
+
# }
|
|
333
|
+
# },
|
|
334
|
+
# "required":[
|
|
335
|
+
# :"name",
|
|
336
|
+
# :"age"
|
|
337
|
+
# ],
|
|
338
|
+
# "additionalProperties":false
|
|
339
|
+
# },
|
|
340
|
+
# "employees":{
|
|
341
|
+
# "type":"array",
|
|
342
|
+
# "items":{
|
|
343
|
+
# "type":"object",
|
|
344
|
+
# "properties":{
|
|
345
|
+
# "name":{
|
|
346
|
+
# "type":"string"
|
|
347
|
+
# },
|
|
348
|
+
# "age":{
|
|
349
|
+
# "type":"integer"
|
|
350
|
+
# }
|
|
351
|
+
# },
|
|
352
|
+
# "required":[
|
|
353
|
+
# :"name",
|
|
354
|
+
# :"age"
|
|
355
|
+
# ],
|
|
356
|
+
# "additionalProperties":false
|
|
357
|
+
# }
|
|
358
|
+
# },
|
|
359
|
+
# "founder":{
|
|
360
|
+
# "type":"object",
|
|
361
|
+
# "properties":{
|
|
362
|
+
# "name":{
|
|
363
|
+
# "type":"string"
|
|
364
|
+
# },
|
|
365
|
+
# "age":{
|
|
366
|
+
# "type":"integer"
|
|
367
|
+
# }
|
|
368
|
+
# },
|
|
369
|
+
# "required":[
|
|
370
|
+
# :"name",
|
|
371
|
+
# :"age"
|
|
372
|
+
# ],
|
|
373
|
+
# "additionalProperties":false
|
|
374
|
+
# }
|
|
375
|
+
# },
|
|
376
|
+
# "required":[
|
|
377
|
+
# :"ceo",
|
|
378
|
+
# :"employees",
|
|
379
|
+
# :"founder"
|
|
380
|
+
# ],
|
|
381
|
+
# "additionalProperties":false,
|
|
382
|
+
# "strict":true
|
|
383
|
+
# }
|
|
384
|
+
# }
|
|
314
385
|
```
|
|
315
386
|
|
|
316
387
|
## JSON Output
|
|
@@ -16,6 +16,10 @@ module RubyLLM
|
|
|
16
16
|
add_property(name, any_of_schema(description: description, **options, &block), required: required)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def one_of(name, description: nil, required: true, **options, &block)
|
|
20
|
+
add_property(name, one_of_schema(description: description, **options, &block), required: required)
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
def optional(name, description: nil, &block)
|
|
20
24
|
any_of(name, description: description) do
|
|
21
25
|
instance_eval(&block)
|
|
@@ -96,6 +96,15 @@ module RubyLLM
|
|
|
96
96
|
}.compact
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
def one_of_schema(description: nil, &block)
|
|
100
|
+
schemas = collect_schemas_from_block(&block)
|
|
101
|
+
|
|
102
|
+
{
|
|
103
|
+
description: description,
|
|
104
|
+
oneOf: schemas
|
|
105
|
+
}.compact
|
|
106
|
+
end
|
|
107
|
+
|
|
99
108
|
private
|
|
100
109
|
|
|
101
110
|
def determine_array_items(of, &)
|
data/lib/ruby_llm/schema.rb
CHANGED
|
@@ -84,7 +84,7 @@ module RubyLLM
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def respond_to_missing?(method_name, include_private = false)
|
|
87
|
-
%i[string number integer boolean array object any_of null].include?(method_name) || super
|
|
87
|
+
%i[string number integer boolean array object any_of one_of null].include?(method_name) || super
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
end
|
data/lib/tasks/release.rake
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
namespace :release do
|
|
2
|
-
desc "
|
|
3
|
-
task :
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
desc "Prepare and push the release branch to trigger the automated pipeline"
|
|
3
|
+
task :prepare do
|
|
4
|
+
abort "Git working directory not clean. Commit or stash changes first." unless `git status --porcelain`.strip.empty?
|
|
5
|
+
abort "Not on main branch. Releases must be run from main branch" unless `git rev-parse --abbrev-ref HEAD`.strip == "main"
|
|
6
|
+
|
|
7
|
+
require_relative "../ruby_llm/schema/version"
|
|
8
|
+
version = RubyLlm::Schema::VERSION or abort "Could not determine version"
|
|
9
|
+
|
|
10
|
+
branch = "release/#{version}"
|
|
11
|
+
|
|
12
|
+
if system("git rev-parse --quiet --verify refs/tags/v#{version} > /dev/null 2>&1")
|
|
13
|
+
abort "Tag v#{version} already exists. Bump the version first."
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if system("git show-ref --verify --quiet refs/heads/#{branch}")
|
|
17
|
+
abort "Local branch #{branch} already exists. Remove it or choose a new version."
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
sh "git fetch origin"
|
|
21
|
+
|
|
22
|
+
if system("git ls-remote --exit-code --heads origin #{branch} > /dev/null 2>&1")
|
|
23
|
+
abort "Release branch #{branch} already exists on origin. Remove it or choose a new version."
|
|
18
24
|
end
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
sh "git checkout -b #{branch}"
|
|
27
|
+
sh "git push -u origin #{branch}"
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
system "
|
|
29
|
+
puts "Release branch #{branch} pushed. GitHub Actions will run tests and publish if they pass."
|
|
30
|
+
ensure
|
|
31
|
+
system "git checkout main"
|
|
26
32
|
end
|
|
27
33
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_llm-schema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Friis
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-11 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: rspec
|
|
@@ -37,6 +38,7 @@ dependencies:
|
|
|
37
38
|
- - ">="
|
|
38
39
|
- !ruby/object:Gem::Version
|
|
39
40
|
version: '0'
|
|
41
|
+
description:
|
|
40
42
|
email:
|
|
41
43
|
- d@friis.me
|
|
42
44
|
executables: []
|
|
@@ -67,6 +69,7 @@ metadata:
|
|
|
67
69
|
source_code_uri: https://github.com/danielfriis/ruby_llm-schema
|
|
68
70
|
changelog_uri: https://github.com/danielfriis/ruby_llm-schema/blob/main/CHANGELOG.md
|
|
69
71
|
rubygems_mfa_required: 'true'
|
|
72
|
+
post_install_message:
|
|
70
73
|
rdoc_options: []
|
|
71
74
|
require_paths:
|
|
72
75
|
- lib
|
|
@@ -81,7 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
84
|
- !ruby/object:Gem::Version
|
|
82
85
|
version: '0'
|
|
83
86
|
requirements: []
|
|
84
|
-
rubygems_version: 3.
|
|
87
|
+
rubygems_version: 3.4.19
|
|
88
|
+
signing_key:
|
|
85
89
|
specification_version: 4
|
|
86
90
|
summary: A simple and clean Ruby DSL for creating JSON schemas.
|
|
87
91
|
test_files: []
|