raix 0.8.1 → 0.8.2

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: 2de11b289a7c245c49e865735e1abc67ff671f02a9f23fb89d262d3ff83e6157
4
- data.tar.gz: f8cd493f6f018ddd6b981f944786635b6800ca9beac4480e0a4c3c08bb7b8392
3
+ metadata.gz: 04e086a8f8f010507fef64ba8f2a1fa7c4508b34d85b39d8d045088410ba041c
4
+ data.tar.gz: b6ddc5948d4d71a967321cfe664a6fb2ad6f38833c7067e0915216ce7fc64646
5
5
  SHA512:
6
- metadata.gz: 4d26f6ffad99abb7eaf6c8ef072393d75625e4762206d0d1f94c811e9d44747fa2e9048d5a8951484ded2861ecd5ebac69ea39bf6163432a411e2f9e427b0533
7
- data.tar.gz: 893d062ab1f23b6c6a47dc715a7c98a3886dbe092645642e74bdb97ad80b2b4f637305b95acc6e6a8984cfe6defcdf020410233f5f818cba16bbbd0c5f49b5ed
6
+ metadata.gz: 1558de827080ea2fb1c0ab0a953ae4d4cb1a9f8ad1aaae0690942f78bfde31275739857948b064721aa83b0f9b963c91c4bcb8dc5be460283e88ee2294e10e64
7
+ data.tar.gz: 001c63730739473375f0bff5c7e4edb78e4247000825799cff5cd98f9ae56bf6f2a5c436f1334b03e05de3257ef081498e2c456567a70e65417c19b70ab8918b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.8.2] - 2025-04-29
2
+ - Extracts function call dispatch into a public `dispatch_tool_function` that can be overridden in subclasses
3
+ - Uses `public_send` instead of `send` for better security and explicitness
4
+
1
5
  ## [0.8.1] - 2025-04-24
2
6
  Added ability to filter tool functions (or disable completely) when calling `chat_completion`. Thanks to @parruda for the contribution.
3
7
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raix (0.8.1)
4
+ raix (0.8.2)
5
5
  activesupport (>= 6.0)
6
6
  faraday-retry (~> 2.0)
7
7
  open_router (~> 0.2)
data/README.md CHANGED
@@ -206,6 +206,28 @@ example.invocations
206
206
  # => [:first, :second]
207
207
  ```
208
208
 
209
+ #### Customizing Function Dispatch
210
+
211
+ You can customize how function calls are handled by overriding the `dispatch_tool_function` in your class. This is useful if you need to add logging, caching, error handling, or other custom behavior around function calls.
212
+
213
+ ```ruby
214
+ class CustomDispatchExample
215
+ include Raix::ChatCompletion
216
+ include Raix::FunctionDispatch
217
+
218
+ function :example_tool do |arguments|
219
+ "Result from example tool"
220
+ end
221
+
222
+ def dispatch_tool_function(function_name, arguments)
223
+ puts "Calling #{function_name} with #{arguments}"
224
+ result = super
225
+ puts "Result: #{result}"
226
+ result
227
+ end
228
+ end
229
+ ```
230
+
209
231
  #### Manually Stopping a Loop
210
232
 
211
233
  To loop AI components that don't interact with end users, at least one function block should invoke `stop_looping!` whenever you're ready to stop processing.
@@ -132,7 +132,7 @@ module Raix
132
132
  function_name = tool_call["function"]["name"]
133
133
  raise "Unauthorized function call: #{function_name}" unless self.class.functions.map { |f| f[:name].to_sym }.include?(function_name.to_sym)
134
134
 
135
- send(function_name, arguments.with_indifferent_access)
135
+ dispatch_tool_function(function_name, arguments.with_indifferent_access)
136
136
  end
137
137
  end
138
138
 
@@ -189,6 +189,16 @@ module Raix
189
189
  @transcript ||= []
190
190
  end
191
191
 
192
+ # Dispatches a tool function call with the given function name and arguments.
193
+ # This method can be overridden in subclasses to customize how function calls are handled.
194
+ #
195
+ # @param function_name [String] The name of the function to call
196
+ # @param arguments [Hash] The arguments to pass to the function
197
+ # @return [Object] The result of the function call
198
+ def dispatch_tool_function(function_name, arguments)
199
+ public_send(function_name, arguments)
200
+ end
201
+
192
202
  private
193
203
 
194
204
  def filtered_tools(tool_names)
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.1"
4
+ VERSION = "0.8.2"
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.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Obie Fernandez
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-25 00:00:00.000000000 Z
10
+ date: 2025-04-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport