raix 0.8.5 → 0.8.6

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: 71867dc17116a9f05ab15218ca05c1e76ab95a815e1613ba851ef71155f970c1
4
- data.tar.gz: 56987389b0e8e1282603bc08f2fba90b4fe444e2bc43d56a94edd1f7535d03dd
3
+ metadata.gz: f28d49373248dcc8209a5c4c3678c632953aab2282f3f71a887ee1e2b3e7d249
4
+ data.tar.gz: bacd7d9ef9b7aff8ab6b998d1ddb2efe3fd3dfa5855d8d5851161a271b056963
5
5
  SHA512:
6
- metadata.gz: 18f6a6ab84d743cd04621c39f30563692d048635496a3acfb3f5a20a27fb481cdfc90b116055516430213880c569c413a45752c6e9bdf841026e3311b8c49e9a
7
- data.tar.gz: 6c1ad1ec56508974471a24816ae460e0158f605e98d1725f6cef2069749c3d04e5199a5e2f403ad8133e4002ae34e8578abfc74818c30f2d991f0b651573d098
6
+ metadata.gz: a7a75b0c7c8f9ecfcbae002e6b5dfea7cee17be8d3d8825dacf2276f200f9bb542e0ccc4f7bb402b03b57d0240d84431bba3d749657a51ef4a90e937fd096633
7
+ data.tar.gz: b367bdd61f7c7fb269232387c0d31af1cb2315d9bed8abc16758931851dab4b849139cb23e1c2c4236f8e8ced55368726db8c2a308efa3b6db503290d07165c2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.8.6] - 2025-05-19
2
+ - add `required` and `optional` flags for parameters in `function` declarations
3
+
1
4
  ## [0.8.5] - 2025-05-08
2
5
  - renamed `tools` argument to `chat_completion` to `available_tools` to prevent shadowing the existing tool attribute (potentially breaking change to enhancement introduced in 0.8.1)
3
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raix (0.8.5)
4
+ raix (0.8.6)
5
5
  activesupport (>= 6.0)
6
6
  faraday-retry (~> 2.0)
7
7
  open_router (~> 0.2)
data/README.md CHANGED
@@ -116,7 +116,9 @@ class WhatIsTheWeather
116
116
  include Raix::ChatCompletion
117
117
  include Raix::FunctionDispatch
118
118
 
119
- function :check_weather, "Check the weather for a location", location: { type: "string" } do |arguments|
119
+ function :check_weather,
120
+ "Check the weather for a location",
121
+ location: { type: "string", required: true } do |arguments|
120
122
  "The weather in #{arguments[:location]} is hot and sunny"
121
123
  end
122
124
  end
@@ -132,6 +134,8 @@ RSpec.describe WhatIsTheWeather do
132
134
  end
133
135
  ```
134
136
 
137
+ Parameters are optional by default. Mark them as required with `required: true` or explicitly optional with `optional: true`.
138
+
135
139
  Note that for security reasons, dispatching functions only works with functions implemented using `Raix::FunctionDispatch#function` or directly on the class.
136
140
 
137
141
  #### Tool Filtering
@@ -46,11 +46,21 @@ module Raix
46
46
  def function(name, description = nil, **parameters, &block)
47
47
  @functions ||= []
48
48
  @functions << begin
49
- { name:, parameters: { type: "object", properties: {} } }.tap do |definition|
49
+ {
50
+ name:,
51
+ parameters: { type: "object", properties: {}, required: [] }
52
+ }.tap do |definition|
50
53
  definition[:description] = description if description.present?
51
- parameters.map do |key, value|
54
+ parameters.each do |key, value|
55
+ value = value.dup
56
+ required = value.delete(:required)
57
+ optional = value.delete(:optional)
52
58
  definition[:parameters][:properties][key] = value
59
+ if required || optional == false
60
+ definition[:parameters][:required] << key
61
+ end
53
62
  end
63
+ definition[:parameters].delete(:required) if definition[:parameters][:required].empty?
54
64
  end
55
65
  end
56
66
 
data/lib/raix/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Raix
4
- VERSION = "0.8.5"
4
+ VERSION = "0.8.6"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Obie Fernandez
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-08 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.6.2
118
+ rubygems_version: 3.6.8
119
119
  specification_version: 4
120
120
  summary: Ruby AI eXtensions
121
121
  test_files: []