raix 0.4.8 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/raix/chat_completion.rb +5 -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: 7537dc5f13d858d6fdd7e5fcdeb60e1d5fd99e0f2aa84e618096f959f2c44ed1
|
4
|
+
data.tar.gz: 8af2e5eb06b2fdaf2c4da8e9b9df28750c6c449d63e5eec25478d61068de2742
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a76e3c1ac764735f05b603c83f6410c5d83274e0d8ef5b80e6a08dfb4ca2338ed324b14db3b4383399ebbd9a88d76615deed4ad8533592ac3dee2ccc84f1ab6d
|
7
|
+
data.tar.gz: c4c89a3d2feac21a80dd1be7f4c0626f48a09756af55b0f38dd0abc769ec4cdb989ae210baabcbbb896f869ec79dd1e26454cecd5df28ee3ff016661d612e7c3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -101,6 +101,8 @@ RSpec.describe WhatIsTheWeather do
|
|
101
101
|
end
|
102
102
|
```
|
103
103
|
|
104
|
+
Note that for security reasons, dispatching functions only works with functions implemented using `Raix::FunctionDispatch#function` or directly on the class.
|
105
|
+
|
104
106
|
#### Multiple Tool Calls
|
105
107
|
|
106
108
|
Some AI models (like GPT-4) can make multiple tool calls in a single response. When this happens, Raix will automatically handle all the function calls sequentially and return an array of their results. Here's an example:
|
data/lib/raix/chat_completion.rb
CHANGED
@@ -110,7 +110,10 @@ module Raix
|
|
110
110
|
return tool_calls.map do |tool_call|
|
111
111
|
# dispatch the called function
|
112
112
|
arguments = JSON.parse(tool_call["function"]["arguments"].presence || "{}")
|
113
|
-
|
113
|
+
function_name = tool_call["function"]["name"]
|
114
|
+
raise "Unauthorized function call: #{function_name}" unless self.class.functions.map { |f| f[:name].to_sym }.include?(function_name.to_sym)
|
115
|
+
|
116
|
+
send(function_name, arguments.with_indifferent_access)
|
114
117
|
end
|
115
118
|
end
|
116
119
|
|
@@ -174,7 +177,7 @@ module Raix
|
|
174
177
|
params[:stream] ||= stream.presence
|
175
178
|
params[:stream_options] = { include_usage: true } if params[:stream]
|
176
179
|
|
177
|
-
params.delete(:temperature) if model
|
180
|
+
params.delete(:temperature) if model.start_with?("o")
|
178
181
|
|
179
182
|
Raix.configuration.openai_client.chat(parameters: params.compact.merge(model:, messages:))
|
180
183
|
end
|
data/lib/raix/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Obie Fernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
rubygems_version: 3.
|
105
|
+
rubygems_version: 3.5.21
|
106
106
|
signing_key:
|
107
107
|
specification_version: 4
|
108
108
|
summary: Ruby AI eXtensions
|