ox-ai-workers 0.7.10 → 0.8.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: d656a51afd4404891dc9f4bd3cfc2d802a3ea169ea5d8371f69e15f6b1465acf
4
- data.tar.gz: 9a8e9ff98302ee0613fe3293a8877eeb0f08adcb6a83ebb34ca45a94268aa4f0
3
+ metadata.gz: f78fe8562d281490ff77a739af65aac6c23961e19bed5b2d14cf7598711affc6
4
+ data.tar.gz: 8f3fea145d2c7d9ae60fd6b79705cc03b4dfa88e81c1954051015e0ae5542dc9
5
5
  SHA512:
6
- metadata.gz: 8921ec6600bf79f0c9c31b15cb31d67507998bf2079f09204e04ac9476abb396b4080322ece14889e9a45669d682fb3c6ff40b124ff22c2c895e5c05e5a7c1fa
7
- data.tar.gz: 5a9183f5510029e6e133cc14d3b97a3fb433469dfbe66cb391c1f19aac3470dd7b3287c89f98ae1210ba8fe25e91cec6ca4adcb48d718185f7097b4638111501
6
+ metadata.gz: 96beaf2ea54324504aef5267915672987ff70b2fb9ce862306515759a0a90dc0ea18b8c8889694fb5ee6739cd1223a880da86468b1eeca597a9e003c387c9723
7
+ data.tar.gz: 93d1baa2365ee956027a882662aa549afd7bd8cd2e34f3573fb3f412f1c694840243aa7a396422ac1806767aa48ca63963707bf7e33296c5e212b5aae924f568
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
@@ -232,9 +232,9 @@ module OxAiWorkers
232
232
  next if tool.nil?
233
233
 
234
234
  out = tool.send(external_call[:name], **external_call[:args])
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?
235
+ @queue << { role: :system,
236
+ content: "Tool called #{external_call[:name]} completed. Args: #{external_call[:args]}" }
237
+ @queue << { role: :system, content: "Result: #{out}" } if out.present?
238
238
  end
239
239
  @worker.finish
240
240
  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.1'
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev