raix 0.8.4 → 0.8.5

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: 77197d6de1d77373260029d955fd0110990b7c562a279d887130ee4f95909377
4
- data.tar.gz: d811d21316bba7c92797dff98c044871ec4382998b77090f29348217156698df
3
+ metadata.gz: 71867dc17116a9f05ab15218ca05c1e76ab95a815e1613ba851ef71155f970c1
4
+ data.tar.gz: 56987389b0e8e1282603bc08f2fba90b4fe444e2bc43d56a94edd1f7535d03dd
5
5
  SHA512:
6
- metadata.gz: 9a513c9c82ef57ba4beb9681a02111a5207c9418b6f0b26015e9ad299d889b8a65644d594c11246ff7c70a5354419fc3932a8a776072757e615b8afbfc48ca98
7
- data.tar.gz: ab0743ed3d99efd20886053b2d7648fc6dec7b551d48c5f86fee9689441dfbda0280e0c693766fa8f03c944f7dbfc459c8301f2b3bb969de47e3f4bbfbf23d0b
6
+ metadata.gz: 18f6a6ab84d743cd04621c39f30563692d048635496a3acfb3f5a20a27fb481cdfc90b116055516430213880c569c413a45752c6e9bdf841026e3311b8c49e9a
7
+ data.tar.gz: 6c1ad1ec56508974471a24816ae460e0158f605e98d1725f6cef2069749c3d04e5199a5e2f403ad8133e4002ae34e8578abfc74818c30f2d991f0b651573d098
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.8.5] - 2025-05-08
2
+ - 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
+
4
+ ## [0.8.4] - 2025-05-07
5
+ - Calls strip instead of squish on response of chat_completion in order to not clobber linebreaks
6
+
1
7
  ## [0.8.3] - 2025-04-30
2
8
  - Adds optional ActiveSupport Cache parameter to `dispatch_tool_function` for caching tool calls
3
9
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raix (0.8.4)
4
+ raix (0.8.5)
5
5
  activesupport (>= 6.0)
6
6
  faraday-retry (~> 2.0)
7
7
  open_router (~> 0.2)
data/README.md CHANGED
@@ -136,7 +136,7 @@ Note that for security reasons, dispatching functions only works with functions
136
136
 
137
137
  #### Tool Filtering
138
138
 
139
- You can control which tools are available to the AI on a given chat completion request using the `tools` parameter in the `chat_completion` method:
139
+ You can control which tool functions are exposed to the AI per request using the `available_tools` parameter of the `chat_completion` method:
140
140
 
141
141
  ```ruby
142
142
  class WeatherAndTime
@@ -155,19 +155,19 @@ end
155
155
  weather = WeatherAndTime.new
156
156
 
157
157
  # Don't pass any tools to the LLM
158
- weather.chat_completion(tools: false)
158
+ weather.chat_completion(available_tools: false)
159
159
 
160
160
  # Only pass specific tools to the LLM
161
- weather.chat_completion(tools: [:check_weather])
161
+ weather.chat_completion(available_tools: [:check_weather])
162
162
 
163
163
  # Pass all declared tools (default behavior)
164
164
  weather.chat_completion
165
165
  ```
166
166
 
167
- The `tools` parameter accepts three types of values:
167
+ The `available_tools` parameter accepts three types of values:
168
+ - `nil`: All declared tool functions are passed (default behavior)
168
169
  - `false`: No tools are passed to the LLM
169
- - An array of symbols: Only the specified tools are passed (raises `Raix::UndeclaredToolError` if any tool is not declared)
170
- - Not provided: All declared tools are passed (default behavior)
170
+ - An array of symbols: Only the specified tools are passed (raises `Raix::UndeclaredToolError` if a specified tool function is not declared)
171
171
 
172
172
  #### Multiple Tool Calls
173
173
 
@@ -36,7 +36,7 @@ module Raix
36
36
 
37
37
  attr_accessor :cache_at, :frequency_penalty, :logit_bias, :logprobs, :loop, :min_p, :model, :presence_penalty,
38
38
  :prediction, :repetition_penalty, :response_format, :stream, :temperature, :max_completion_tokens,
39
- :max_tokens, :seed, :stop, :top_a, :top_k, :top_logprobs, :top_p, :tools, :tool_choice, :provider
39
+ :max_tokens, :seed, :stop, :top_a, :top_k, :top_logprobs, :top_p, :tools, :available_tools, :tool_choice, :provider
40
40
 
41
41
  # This method performs chat completion based on the provided transcript and parameters.
42
42
  #
@@ -46,9 +46,9 @@ module Raix
46
46
  # @option params [Boolean] :openai (false) Whether to use OpenAI's API instead of OpenRouter's.
47
47
  # @option params [Boolean] :raw (false) Whether to return the raw response or dig the text content.
48
48
  # @option params [Array] :messages (nil) An array of messages to use instead of the transcript.
49
- # @option tools [Array|false] :tools (nil) Tools to pass to the LLM. If false, no tools are passed. If an array, only declared tools in the array are passed.
49
+ # @option tools [Array|false] :available_tools (nil) Tools to pass to the LLM. Ignored if nil (default). If false, no tools are passed. If an array, only declared tools in the array are passed.
50
50
  # @return [String|Hash] The completed chat response.
51
- def chat_completion(params: {}, loop: false, json: false, raw: false, openai: false, save_response: true, messages: nil, tools: nil)
51
+ def chat_completion(params: {}, loop: false, json: false, raw: false, openai: false, save_response: true, messages: nil, available_tools: nil)
52
52
  # set params to default values if not provided
53
53
  params[:cache_at] ||= cache_at.presence
54
54
  params[:frequency_penalty] ||= frequency_penalty.presence
@@ -66,12 +66,12 @@ module Raix
66
66
  params[:stop] ||= stop.presence
67
67
  params[:temperature] ||= temperature.presence || Raix.configuration.temperature
68
68
  params[:tool_choice] ||= tool_choice.presence
69
- params[:tools] = if tools == false
69
+ params[:tools] = if available_tools == false
70
70
  nil
71
- elsif tools.is_a?(Array)
72
- filtered_tools(tools)
71
+ elsif available_tools.is_a?(Array)
72
+ filtered_tools(available_tools)
73
73
  else
74
- self.tools.presence
74
+ tools.presence
75
75
  end
76
76
  params[:top_a] ||= top_a.presence
77
77
  params[:top_k] ||= top_k.presence
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.4"
4
+ VERSION = "0.8.5"
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.4
4
+ version: 0.8.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Obie Fernandez
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-05-07 00:00:00.000000000 Z
10
+ date: 2025-05-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport