ox-ai-workers 1.1.4.2 → 1.1.6

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: 1d0694e0a6bed4958f629d8faa968fa8246f8ed3be490af1471b135d07e362c1
4
- data.tar.gz: b0e2648f476ca674bb53c7fa5f37c0c8200fb482b7a43f558601faa6abc7523a
3
+ metadata.gz: 2973c35e35aa9849e733816b594cfbb85e6a80175104deae2b893a21baa0eba3
4
+ data.tar.gz: a378871902aff431c32839deeb5e510992fcc5d6a46bdfbf2c20b519df56a42e
5
5
  SHA512:
6
- metadata.gz: c637d9bab58ff1384a1e658423e5abdd631c21a5b15f57523415e98adaf196870a8285b1fed173a8f7248349b33d471f0941c9ab5d877d3a8ce6c9d72c17bd0a
7
- data.tar.gz: d1f3279c0dcc2db5a6b696d17777d248b934663d8776a87eeab93ac7bbe4d8890a174f876dae443bfd9f047b7a01f7e50d694ef0cbc2b110aa08dbe1d703c7a9
6
+ metadata.gz: 98df04485d061d7a8ae5f8fe603650f6c5f0abe3ec2b24e492d22bc77430696a4fd2463a1f51181ee88f62eb2e8107f6e14e8567c597880eeea89d9704aa207c
7
+ data.tar.gz: 0daff534025e9c507b8ad7df5d57f3da17c6f7030d218776ca15d4a8d428584752c7e262d57953bb2697f1540d6b352d889d68cfa4959f30602b17d66a9a2557
@@ -178,7 +178,7 @@ module OxAiWorkers
178
178
  def next_iteration
179
179
  # Check call_stack before continuing iteration
180
180
  if should_finish_iteration?
181
- OxAiWorkers.logger.info "Iterator::Call stack is empty or contains only finish_it. Finishing iteration."
181
+ OxAiWorkers.logger.info 'Iterator::Call stack is empty or contains only finish_it. Finishing iteration.'
182
182
  finish_it
183
183
  return
184
184
  end
@@ -196,9 +196,9 @@ module OxAiWorkers
196
196
  def should_finish_iteration?
197
197
  return false if @worker.call_stack.nil?
198
198
  return false unless @worker.respond_to?(:call_stack) && @worker.call_stack.present?
199
-
199
+
200
200
  finish_it_function = OxAiWorkers::Iterator.full_function_name(:finish_it)
201
-
201
+
202
202
  # Check if the call queue is empty or contains only finish_it
203
203
  @worker.call_stack.empty? || @worker.call_stack.all? { |call| call == finish_it_function }
204
204
  end
@@ -41,10 +41,13 @@ module OxAiWorkers
41
41
  @messages.each do |message|
42
42
  content = message[:content]
43
43
  if content.is_a?(String)
44
- OxAiWorkers.logger.warn "Request (String)[#{message[:role]}]: #{content.truncate(500)}"
44
+ truncated = content.length > 500 ? "#{content[0...500]}..." : content
45
+ OxAiWorkers.logger.warn "Request (String)[#{message[:role]}]: #{truncated}"
45
46
  elsif content.is_a?(Array)
46
47
  types = content.map do |item|
47
- "#{item[:type]}: #{item[:content]&.truncate(500)}"
48
+ text = item[:content]
49
+ truncated = text && text.length > 500 ? "#{text[0...500]}..." : text
50
+ "#{item[:type]}: #{truncated}"
48
51
  end.compact.join(', ')
49
52
  OxAiWorkers.logger.warn "Request (Array): [#{types}]"
50
53
  else
@@ -55,11 +58,7 @@ module OxAiWorkers
55
58
  filtered_functions = []
56
59
  filtered_functions << @last_call if @stop_double_calls.include?(@last_call)
57
60
 
58
- tool_choice = if @call_stack&.any?
59
- func1 = @call_stack.first
60
- @call_stack = @call_stack.drop(1)
61
- func1
62
- end
61
+ tool_choice = (@call_stack.first if @call_stack&.any?)
63
62
 
64
63
  @model.build_parameters(
65
64
  messages: @messages,
@@ -87,6 +86,11 @@ module OxAiWorkers
87
86
  @tool_calls += tool_calls
88
87
  end
89
88
  @last_call = @tool_calls.last[:name] if @tool_calls.any?
89
+
90
+ # Remove the first element from call_stack only after successful tool call
91
+ if @tool_calls.any? && @call_stack&.any?
92
+ @call_stack = @call_stack.drop(1)
93
+ end
90
94
  end
91
95
  end
92
96
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '1.1.4.2'
4
+ VERSION = '1.1.6'
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: 1.1.4.2
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  - !ruby/object:Gem::Version
210
210
  version: '0'
211
211
  requirements: []
212
- rubygems_version: 3.6.9
212
+ rubygems_version: 3.7.2
213
213
  specification_version: 4
214
214
  summary: A powerful state machine with OpenAI generative intelligence integration
215
215
  test_files: []