ox-ai-workers 0.7.10 → 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: d656a51afd4404891dc9f4bd3cfc2d802a3ea169ea5d8371f69e15f6b1465acf
4
- data.tar.gz: 9a8e9ff98302ee0613fe3293a8877eeb0f08adcb6a83ebb34ca45a94268aa4f0
3
+ metadata.gz: b177fcb5d7633d2cf26c608db3ec4ee0c69a301bf3913397be7cdd146de52cc5
4
+ data.tar.gz: 172312df86eba2fd578100467da9b7ac17ebfff577889f3df1b6888643c129e8
5
5
  SHA512:
6
- metadata.gz: 8921ec6600bf79f0c9c31b15cb31d67507998bf2079f09204e04ac9476abb396b4080322ece14889e9a45669d682fb3c6ff40b124ff22c2c895e5c05e5a7c1fa
7
- data.tar.gz: 5a9183f5510029e6e133cc14d3b97a3fb433469dfbe66cb391c1f19aac3470dd7b3287c89f98ae1210ba8fe25e91cec6ca4adcb48d718185f7097b4638111501
6
+ metadata.gz: 6d812c840212f8651ae58c09378c1eff43f4f8b69c0a6d50e17997863e3b1635d66470b9edec3eff270f8fe910dd309df994f07a4a18654799b82166fb52ee25
7
+ data.tar.gz: 24615b0e9a421c538d926fe97ad843f78d6795c54334d005fd03d0b6016dd4d24f694e267d0d18cb0ad653a25b8791893658557299fb6aa3558f17980fc2b696
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.8.0] - 2025-03-31
2
+
3
+ - Added `on_stream` for `Iterator`
4
+
1
5
  ## [0.7.10] - 2025-03-31
2
6
 
3
7
  - Added `tool_call_completed` for `Iterator`
@@ -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
@@ -233,8 +233,10 @@ module OxAiWorkers
233
233
 
234
234
  out = tool.send(external_call[:name], **external_call[:args])
235
235
  @queue << { role: :assistant,
236
- content: "Tool call #{external_call[:name]} completed. Args: #{external_call[:args]}" }
237
- @queue << { role: :system, content: out.to_s } if out.present?
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?
238
240
  end
239
241
  @worker.finish
240
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.10'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox-ai-workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev