ox-ai-workers 1.1.4.1 → 1.1.5

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: 56e2ee5c343058a40443b708c42546c7f76ce0c9915ab54b74a28215ce664a0a
4
- data.tar.gz: 3dd61c2eb153ea379b5e53871b1fae4805dca163526de51a4e40cf8407030cdd
3
+ metadata.gz: f5784dfd8d79874e6db22d56d3e311777e1bddc4b68686881b7d41d6a0b25fed
4
+ data.tar.gz: 6ef196f9d45a183fa3bec41d5782afbf0bb60158df14847a2e3682012143a3da
5
5
  SHA512:
6
- metadata.gz: 303e386cb438f35cde00787ea617a12215394e712932e15995bc9629f4d210cdccde0031262b80ea4221bc9441366f32a2c16702ecfc01917fbba4ddaebb42d6
7
- data.tar.gz: 1590ee68bdf1d6e4b5c31b02839ff5b28b4f298719f68c3ac0dac2ffc3938f7f7334f4c522ecbc2409fec3cb7135884d3bcbc5fcbfc9e0bc629ea09b820c9f3a
6
+ metadata.gz: 878ddf667e5e7198e0b007ad3cb7b41f268929f3ea678a6be0d20667ca7ecaa3fbad190c99a8e01bf9d4152bf7ca9af1f9de1d7d3d92cdf324d26974e1472d01
7
+ data.tar.gz: 2f23c2a05a207bc0a258e16c67724af7c9093aac3aba0bd8d72402a1d7d6887a383bee08965fac45ce1a8423810758a35a6063254b827e6a96530a00147e0589
@@ -76,7 +76,7 @@ module OxAiWorkers
76
76
  @tasks = []
77
77
  @messages = []
78
78
  @call_id = 0
79
- # Очищаем сообщения в worker, если он существует
79
+ # Clear messages in worker if it exists
80
80
  @worker.messages = [] if @worker&.respond_to?(:messages=)
81
81
  complete_iteration
82
82
  end
@@ -123,7 +123,7 @@ module OxAiWorkers
123
123
  # @worker.last_call = nil
124
124
  @worker.call_stack = @call_stack.dup
125
125
  @worker.stop_double_calls = @stop_double_calls
126
- # Не очищаем сообщения, а сохраняем их в переменной
126
+ # Don't clear messages, save them in a variable
127
127
  current_messages = @worker.messages || []
128
128
  @worker.messages = []
129
129
  @worker.append(role: :system, content: "<role>\n#{@role}\n</role>") if @role.present?
@@ -134,7 +134,7 @@ module OxAiWorkers
134
134
  @tools.each do |tool|
135
135
  @worker.append(role: :user, content: tool.context) if tool.respond_to?(:context) && tool.context.present?
136
136
  end
137
- # Добавляем сохраненные сообщения обратно, если они не пустые
137
+ # Add saved messages back if they are not empty
138
138
  @worker.append(messages: current_messages) if current_messages.present?
139
139
  @worker.append(messages: @messages)
140
140
  # @tasks.each { |task| @worker.append(role: :user, content: "<task>\n#{task}\n</task>") }
@@ -176,19 +176,19 @@ module OxAiWorkers
176
176
  end
177
177
 
178
178
  def next_iteration
179
- # Проверяем call_stack перед продолжением итерации
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
185
185
 
186
- # Сначала добавляем сообщения из очереди к worker
186
+ # First add messages from queue to worker
187
187
  @worker.append(messages: @queue)
188
- # Затем добавляем их к локальным сообщениям
188
+ # Then add them to local messages
189
189
  @messages += @queue
190
190
  OxAiWorkers.logger.warn "Iterator::Next iteration: #{@messages.count}/#{@queue.count}"
191
- # И только потом очищаем очередь
191
+ # And only then clear the queue
192
192
  @queue = []
193
193
  request!
194
194
  end
@@ -196,13 +196,11 @@ 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
-
202
- # Проверяем, пуста ли очередь вызовов или содержит только finish_it
203
- @worker.call_stack.empty? ||
204
- (@worker.call_stack.size == 1 && @worker.call_stack.first == finish_it_function) ||
205
- @worker.call_stack.all? { |call| call == finish_it_function }
201
+
202
+ # Check if the call queue is empty or contains only finish_it
203
+ @worker.call_stack.empty? || @worker.call_stack.all? { |call| call == finish_it_function }
206
204
  end
207
205
 
208
206
  def external_request
@@ -282,7 +280,7 @@ module OxAiWorkers
282
280
 
283
281
  def complete_iteration
284
282
  @queue = []
285
- # Используем finish_without_cleanup вместо finish
283
+ # Use finish_without_cleanup instead of finish
286
284
  @worker.finish_without_cleanup if @worker.respond_to?(:finish_without_cleanup)
287
285
  end
288
286
 
@@ -55,11 +55,7 @@ module OxAiWorkers
55
55
  filtered_functions = []
56
56
  filtered_functions << @last_call if @stop_double_calls.include?(@last_call)
57
57
 
58
- tool_choice = if @call_stack&.any?
59
- func1 = @call_stack.first
60
- @call_stack = @call_stack.drop(1)
61
- func1
62
- end
58
+ tool_choice = (@call_stack.first if @call_stack&.any?)
63
59
 
64
60
  @model.build_parameters(
65
61
  messages: @messages,
@@ -87,6 +83,11 @@ module OxAiWorkers
87
83
  @tool_calls += tool_calls
88
84
  end
89
85
  @last_call = @tool_calls.last[:name] if @tool_calls.any?
86
+
87
+ # Remove the first element from call_stack only after successful tool call
88
+ if @tool_calls.any? && @call_stack&.any?
89
+ @call_stack = @call_stack.drop(1)
90
+ end
90
91
  end
91
92
  end
92
93
  end
@@ -9,10 +9,10 @@ module OxAiWorkers
9
9
  cleanup
10
10
  end
11
11
 
12
- # Метод для завершения без очистки сообщений
12
+ # Method to finish without clearing messages
13
13
  def finish_without_cleanup
14
14
  @custom_id = SecureRandom.uuid
15
- # Очищаем только результат и ошибки, но не сообщения
15
+ # Clear only result and errors, but not messages
16
16
  @result = nil
17
17
  @errors = nil
18
18
  @tool_calls = nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '1.1.4.1'
4
+ VERSION = '1.1.5'
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.1
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev