omniai 3.1.2 → 3.2.1

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: d4564620d223dc2b398e45479742eb8e2ab9873716a946af44a069b1df84ec96
4
- data.tar.gz: d03aae31d15a19f1f14b0bf9643f79e85ac9f31aa4d8c0fa5b0d2ad0b959e982
3
+ metadata.gz: 329e024c0319179ac8ff6757755d8c3d4275f68a759ec864200b88d1930e8e52
4
+ data.tar.gz: beac9879c26d58b6ff6cc5dd71e32cd29a2e32f511971d8982e78c9ece33d654
5
5
  SHA512:
6
- metadata.gz: e09fcf9083efd4b6de9bd6e8658f04f4b6a6a92f27a935d30e345fed635609d0dd1b21bb0c32e78c25f3fd2e9b7a8f6728b367db6190fa4f69bf7dc47a717f42
7
- data.tar.gz: 026e7f2fbddab552fc2635cd11856d652e06f2a3a3a9e30990612da223fe979aee105495be6d39a163dc8040c7bca927e16a6cddec63efe761570ab7eabc30ab
6
+ metadata.gz: f57c9c5daa85d4cb77c8569abc79cb01203c531fbe9e0849a38884229c45b555df3c286cf7646c071ec000356ff748f7b53a0c0a0c26da5feba402fdf4a0cfe0
7
+ data.tar.gz: c9abb1aa60e64e663428f42c66bbc78b639dbbaabdfb0510f3ced5ba25ecddbe9497a3d0389a632816748c54b209142c1d4ccc15271a0f313fb32e7a3d8c87b3
@@ -165,6 +165,11 @@ module OmniAI
165
165
  else "input"
166
166
  end
167
167
  end
168
+
169
+ # @return [Boolean]
170
+ def tool_call_list?
171
+ @tool_call_list&.any?
172
+ end
168
173
  end
169
174
  end
170
175
  end
@@ -81,7 +81,7 @@ module OmniAI
81
81
 
82
82
  # @return [ToolCallList, nil]
83
83
  def tool_call_list
84
- tool_call_lists = messages.map(&:tool_call_list).compact
84
+ tool_call_lists = messages.filter(&:tool_call_list?).map(&:tool_call_list)
85
85
  return if tool_call_lists.empty?
86
86
 
87
87
  tool_call_lists.reduce(&:+)
@@ -12,11 +12,17 @@ module OmniAI
12
12
  # @return [Function]
13
13
  attr_accessor :function
14
14
 
15
+ # @!attribute [r] options
16
+ # @return [Hash] provider-specific options
17
+ attr_reader :options
18
+
15
19
  # @param id [String]
16
20
  # @param function [Function]
17
- def initialize(id:, function:)
21
+ # @param options [Hash] optional - used for provider-specific options
22
+ def initialize(id:, function:, **options)
18
23
  @id = id
19
24
  @function = function
25
+ @options = options
20
26
  end
21
27
 
22
28
  # @return [String]
@@ -42,6 +42,11 @@ module OmniAI
42
42
  "#<#{self.class.name} entries=#{@entries.inspect}>"
43
43
  end
44
44
 
45
+ # @return [Boolean]
46
+ def any?
47
+ @entries.any?
48
+ end
49
+
45
50
  # @yield toolcall
46
51
  # @yieldparam toolcall [ToolCall]
47
52
  def each(&)
@@ -12,11 +12,17 @@ module OmniAI
12
12
  # @return [ToolCall]
13
13
  attr_accessor :tool_call_id
14
14
 
15
+ # @!attribute [r] options
16
+ # @return [Hash] provider-specific options
17
+ attr_reader :options
18
+
15
19
  # @param content [Object] e.g. a string, hash, array, boolean, numeric, etc.
16
20
  # @param tool_call_id [String]
17
- def initialize(content:, tool_call_id:)
21
+ # @param options [Hash] optional - used for provider-specific options
22
+ def initialize(content:, tool_call_id:, **options)
18
23
  @content = content
19
24
  @tool_call_id = tool_call_id
25
+ @options = options
20
26
  end
21
27
 
22
28
  # @return [String]
data/lib/omniai/chat.rb CHANGED
@@ -112,7 +112,7 @@ module OmniAI
112
112
  raise SSLError, e.message, cause: e
113
113
  end
114
114
 
115
- if @tools && completion.tool_call_list?
115
+ if tools? && completion.tool_call_list?
116
116
  spawn!(
117
117
  @prompt.dup.tap do |prompt|
118
118
  prompt.messages += completion.messages
@@ -126,6 +126,11 @@ module OmniAI
126
126
 
127
127
  protected
128
128
 
129
+ # @return [Boolean]
130
+ def tools?
131
+ @tools&.any?
132
+ end
133
+
129
134
  # @return [Boolean]
130
135
  def stream?
131
136
  !@stream.nil?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniAI
4
- VERSION = "3.1.2"
4
+ VERSION = "3.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre