ruby_llm-schema 0.2.4 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04e8a7c652e5fa46b0dff7bd8d7dacd68909e8ada67cb8545a2e71513ecd8b22
4
- data.tar.gz: efea7f81c24d44ec25afa91164119983edf4eae98c52efabb324d35f18ac30a3
3
+ metadata.gz: 228903cdd6e6080b7c687147ecc609349601d315da71e861b1d900f7c252ac00
4
+ data.tar.gz: ecdc3e346f33710ceff0d68c8eb13266956bddc1a36852f02128e3d3f2d94ff5
5
5
  SHA512:
6
- metadata.gz: 52f173eda29165f70ee8ea99748ad51ec3614aea99cbe2fe04f32f3908aeca913985dc0c7655ef5dc87ae0513cf766e999f5f4b25465be7d588ca4616776e67d
7
- data.tar.gz: 4a117fa0fffa4f4bdad9df1a55420c555a667ab962f158642329f84ce5228232d2a53041ca2fc6aa1853c317e0836d599ab78c244ae1e82fdd3951d046a0ae51
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLlm
4
4
  class Schema
5
- VERSION = "0.2.4"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
@@ -34,6 +34,13 @@ module RubyLLM
34
34
  @definitions ||= {}
35
35
  end
36
36
 
37
+ def name(name = nil)
38
+ @schema_name = name if name
39
+ return @schema_name if defined?(@schema_name)
40
+
41
+ super()
42
+ end
43
+
37
44
  def description(description = nil)
38
45
  @description = description if description
39
46
  @description
@@ -44,11 +51,12 @@ module RubyLLM
44
51
  @additional_properties = value
45
52
  end
46
53
 
47
- def strict(value = nil)
48
- if value.nil?
49
- return @strict.nil? ? (@strict = true) : @strict
54
+ def strict(*args)
55
+ if args.empty?
56
+ instance_variable_defined?(:@strict) ? @strict : true
57
+ else
58
+ @strict = args.first
50
59
  end
51
- @strict = value
52
60
  end
53
61
 
54
62
  def validate!
@@ -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.2.4
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: 2025-11-11 00:00:00.000000000 Z
11
+ date: 2026-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec