ruby_llm-schema 0.2.5 → 0.3.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 +4 -4
- data/README.md +19 -0
- data/lib/ruby_llm/schema/json_output.rb +3 -2
- data/lib/ruby_llm/schema/version.rb +1 -1
- data/lib/ruby_llm/schema.rb +5 -4
- data/lib/tasks/release.rake +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 228903cdd6e6080b7c687147ecc609349601d315da71e861b1d900f7c252ac00
|
|
4
|
+
data.tar.gz: ecdc3e346f33710ceff0d68c8eb13266956bddc1a36852f02128e3d3f2d94ff5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ca4ee64989087583e4a15e3b608b7e867034f0682a5f67753efeedee2f98bdc60ce933ff9a0823c93a633d43a9258e550c51b4d3fdbcddc0b3b2462ff40c5586
|
|
7
|
+
data.tar.gz: 03affcdc52ba81f9c7c5d62fcd23e58f800dad7be7580df6c73d6c00b7d1941db0eacd867c83e075aee51090d52e418159472fe72b456533d4cbf1c1141c5ecc
|
data/README.md
CHANGED
|
@@ -51,6 +51,25 @@ schema = PersonSchema.new
|
|
|
51
51
|
puts schema.to_json
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
### Most common use case with RubyLLM
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
class PersonSchema < RubyLLM::Schema
|
|
58
|
+
string :name, description: "Person's full name"
|
|
59
|
+
integer :age, description: "Person's age in years"
|
|
60
|
+
string :city, required: false, description: "City where they live"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Use it natively with RubyLLM
|
|
64
|
+
chat = RubyLLM.chat
|
|
65
|
+
response = chat.with_schema(PersonSchema)
|
|
66
|
+
.ask("Generate a person named Alice who is 30 years old and lives in New York")
|
|
67
|
+
|
|
68
|
+
# The response is automatically parsed from JSON
|
|
69
|
+
puts response.content # => {"name" => "Alice", "age" => 30}
|
|
70
|
+
puts response.content.class # => Hash
|
|
71
|
+
```
|
|
72
|
+
|
|
54
73
|
## Installation
|
|
55
74
|
|
|
56
75
|
Add this line to your application's Gemfile:
|
|
@@ -10,10 +10,11 @@ module RubyLLM
|
|
|
10
10
|
type: "object",
|
|
11
11
|
properties: self.class.properties,
|
|
12
12
|
required: self.class.required_properties,
|
|
13
|
-
additionalProperties: self.class.additional_properties
|
|
14
|
-
strict: self.class.strict
|
|
13
|
+
additionalProperties: self.class.additional_properties
|
|
15
14
|
}
|
|
16
15
|
|
|
16
|
+
schema_hash[:strict] = self.class.strict unless self.class.strict.nil?
|
|
17
|
+
|
|
17
18
|
# Only include $defs if there are definitions
|
|
18
19
|
schema_hash["$defs"] = self.class.definitions unless self.class.definitions.empty?
|
|
19
20
|
|
data/lib/ruby_llm/schema.rb
CHANGED
|
@@ -51,11 +51,12 @@ module RubyLLM
|
|
|
51
51
|
@additional_properties = value
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
def strict(
|
|
55
|
-
if
|
|
56
|
-
|
|
54
|
+
def strict(*args)
|
|
55
|
+
if args.empty?
|
|
56
|
+
instance_variable_defined?(:@strict) ? @strict : true
|
|
57
|
+
else
|
|
58
|
+
@strict = args.first
|
|
57
59
|
end
|
|
58
|
-
@strict = value
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
def validate!
|
data/lib/tasks/release.rake
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# 1. Bump the version
|
|
2
|
+
# Update VERSION in lib/ruby_llm/schema/version.rb
|
|
3
|
+
|
|
4
|
+
# 2. Update Gemfile.lock
|
|
5
|
+
# bundle install
|
|
6
|
+
|
|
7
|
+
# 3. Commit everything
|
|
8
|
+
# git add .
|
|
9
|
+
# git commit -m "Bump version to X.Y.Z"
|
|
10
|
+
|
|
11
|
+
# 4. Push to main
|
|
12
|
+
# git push origin main
|
|
13
|
+
|
|
14
|
+
# 5. Trigger the release
|
|
15
|
+
# bundle exec rake release:prepare
|
|
16
|
+
|
|
17
|
+
# 6. Delete the release branch locally and remotely
|
|
18
|
+
# git branch -d release/X.Y.Z
|
|
19
|
+
# git push origin --delete release/X.Y.Z
|
|
20
|
+
|
|
1
21
|
namespace :release do
|
|
2
22
|
desc "Prepare and push the release branch to trigger the automated pipeline"
|
|
3
23
|
task :prepare do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_llm-schema
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Friis
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|