ox-ai-workers 0.7.9 → 0.8.0

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: 7158485603265249cd23284ad0bf2a34bade8f576809b871f87eb82004f14e03
4
- data.tar.gz: 808b5910cfcc23ace8d3445af45a63911da8092aedb12af4ac2ff4e1145976b6
3
+ metadata.gz: b177fcb5d7633d2cf26c608db3ec4ee0c69a301bf3913397be7cdd146de52cc5
4
+ data.tar.gz: 172312df86eba2fd578100467da9b7ac17ebfff577889f3df1b6888643c129e8
5
5
  SHA512:
6
- metadata.gz: 1a061cdf90b55bf7fab3af6819d6c1a4cab0454e23436186dcca88c5f4ebc85c0d8bcae59953572bb0ae680281d8583a8ae6ce907d782269040c3be528fbbac8
7
- data.tar.gz: 7af5980209650840f0e623a60225c00d4c06d0b761469d89606ffde2606406669b1d05204300bd0d48468cd30febfd3dc5ca348f10f661d05f61cd47054861ec
6
+ metadata.gz: 6d812c840212f8651ae58c09378c1eff43f4f8b69c0a6d50e17997863e3b1635d66470b9edec3eff270f8fe910dd309df994f07a4a18654799b82166fb52ee25
7
+ data.tar.gz: 24615b0e9a421c538d926fe97ad843f78d6795c54334d005fd03d0b6016dd4d24f694e267d0d18cb0ad653a25b8791893658557299fb6aa3558f17980fc2b696
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.8.0] - 2025-03-31
2
+
3
+ - Added `on_stream` for `Iterator`
4
+
5
+ ## [0.7.10] - 2025-03-31
6
+
7
+ - Added `tool_call_completed` for `Iterator`
8
+
1
9
  ## [0.7.9] - 2025-03-24
2
10
 
3
11
  - Added `uri_base` for configuration
@@ -20,8 +20,8 @@ module OxAiWorkers
20
20
  @iterator.execute
21
21
  end
22
22
 
23
- def init_worker(delayed: false, model: nil)
24
- worker = delayed ? DelayedRequest.new : Request.new
23
+ def init_worker(delayed: false, model: nil, on_stream: nil)
24
+ worker = delayed ? DelayedRequest.new : Request.new(on_stream:)
25
25
  worker.model = model || OxAiWorkers.configuration.model
26
26
  worker
27
27
  end
@@ -80,7 +80,7 @@ module OxAiWorkers
80
80
  # @return [nil] This method does not return a value.
81
81
  def inner_monologue(speach:)
82
82
  # @queue.pop
83
- @queue << { role: :assistant, content: speach.to_s }
83
+ # @queue << { role: :assistant, content: speach.to_s }
84
84
  @on_inner_monologue&.call(text: speach)
85
85
  nil
86
86
  end
@@ -229,10 +229,14 @@ module OxAiWorkers
229
229
  tool_name = t.respond_to?(:tool_name) ? t.tool_name : t.class.tool_name
230
230
  tool_name == external_call[:class] && t.respond_to?(external_call[:name])
231
231
  end.first
232
- unless tool.nil?
233
- out = tool.send(external_call[:name], **external_call[:args])
234
- @queue << { role: :system, content: out.to_s } if out.present?
235
- end
232
+ next if tool.nil?
233
+
234
+ out = tool.send(external_call[:name], **external_call[:args])
235
+ @queue << { role: :assistant,
236
+ content: "Call #{external_call[:name]} with args #{external_call[:args]}" }
237
+ @queue << { role: :system,
238
+ content: "Tool call #{external_call[:name]} complited" }
239
+ @queue << { role: :system, content: "Result: #{out}" } if out.present?
236
240
  end
237
241
  @worker.finish
238
242
  iterate! if can_iterate?
@@ -3,9 +3,9 @@
3
3
  module OxAiWorkers
4
4
  class ModuleRequest
5
5
  attr_accessor :result, :client, :messages, :model, :max_tokens, :custom_id, :temperature, :tools, :errors,
6
- :tool_calls_raw, :tool_calls, :is_truncated, :finish_reason, :uri_base
6
+ :tool_calls_raw, :tool_calls, :is_truncated, :finish_reason, :uri_base, :on_stream_proc
7
7
 
8
- def initialize_requests(model: nil, max_tokens: nil, temperature: nil, uri_base: nil)
8
+ def initialize_requests(model: nil, max_tokens: nil, temperature: nil, uri_base: nil, on_stream: nil)
9
9
  @max_tokens = max_tokens || OxAiWorkers.configuration.max_tokens
10
10
  @custom_id = SecureRandom.uuid
11
11
  @model = model || OxAiWorkers.configuration.model
@@ -14,6 +14,7 @@ module OxAiWorkers
14
14
  @client = nil
15
15
  @is_truncated = false
16
16
  @finish_reason = nil
17
+ @on_stream_proc = on_stream
17
18
 
18
19
  OxAiWorkers.configuration.access_token ||= ENV['OPENAI']
19
20
  if OxAiWorkers.configuration.access_token.nil?
@@ -40,7 +41,7 @@ module OxAiWorkers
40
41
  end
41
42
 
42
43
  def append(role: nil, content: nil, messages: nil)
43
- @messages << { role:, content: } if role.present? and content.present?
44
+ @messages << { role:, content: } if role.present? && content.present?
44
45
  @messages += messages if messages.present?
45
46
  end
46
47
 
@@ -55,6 +56,10 @@ module OxAiWorkers
55
56
  parameters[:tools] = @tools
56
57
  parameters[:tool_choice] = 'required'
57
58
  end
59
+ if @on_stream_proc.present?
60
+ parameters[:stream] = @on_stream_proc
61
+ parameters[:stream_options] = { include_usage: true }
62
+ end
58
63
  parameters
59
64
  end
60
65
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '0.7.9'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox-ai-workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-24 00:00:00.000000000 Z
10
+ date: 2025-03-31 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: colorize