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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/raix/function_dispatch.rb +12 -2
- data/lib/raix/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f28d49373248dcc8209a5c4c3678c632953aab2282f3f71a887ee1e2b3e7d249
|
4
|
+
data.tar.gz: bacd7d9ef9b7aff8ab6b998d1ddb2efe3fd3dfa5855d8d5851161a271b056963
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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,
|
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
|
-
{
|
49
|
+
{
|
50
|
+
name:,
|
51
|
+
parameters: { type: "object", properties: {}, required: [] }
|
52
|
+
}.tap do |definition|
|
50
53
|
definition[:description] = description if description.present?
|
51
|
-
parameters.
|
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
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.
|
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:
|
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.
|
118
|
+
rubygems_version: 3.6.8
|
119
119
|
specification_version: 4
|
120
120
|
summary: Ruby AI eXtensions
|
121
121
|
test_files: []
|