ox-ai-workers 1.1.2.12 → 1.1.3
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 +4 -4
- data/lib/oxaiworkers/iterator.rb +13 -3
- data/lib/oxaiworkers/module_request.rb +1 -1
- data/lib/oxaiworkers/request.rb +10 -0
- data/lib/oxaiworkers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff50d91eb53d6cad821557f5c103128f4881a9281de7518b094b0792b4cbda46
|
4
|
+
data.tar.gz: 3ef9261b02ecbb2bc7dc90f703174f6c0dfc406856b20061eaee208cdca47778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e2ef85d37cfcb2821705df4dc5ed621f2db7dba1543e95ca82111dfcc145f9594094861c50bb68df285f1641073c1931358fff36e09cda34ee1a07ab0b0f4e5
|
7
|
+
data.tar.gz: 4e463f6ef03c29a001cbe6c783829c39369b2f4d8acc95cad8eeeb2791495b52d8418325cb1d21de434a40ae912324d0f0f1528fdc12b48f9400122ef8eeeff9
|
data/lib/oxaiworkers/iterator.rb
CHANGED
@@ -76,6 +76,8 @@ module OxAiWorkers
|
|
76
76
|
@tasks = []
|
77
77
|
@messages = []
|
78
78
|
@call_id = 0
|
79
|
+
# Очищаем сообщения в worker, если он существует
|
80
|
+
@worker.messages = [] if @worker&.respond_to?(:messages=)
|
79
81
|
complete_iteration
|
80
82
|
end
|
81
83
|
|
@@ -121,6 +123,8 @@ module OxAiWorkers
|
|
121
123
|
# @worker.last_call = nil
|
122
124
|
@worker.call_stack = @call_stack.dup
|
123
125
|
@worker.stop_double_calls = @stop_double_calls
|
126
|
+
# Не очищаем сообщения, а сохраняем их в переменной
|
127
|
+
current_messages = @worker.messages || []
|
124
128
|
@worker.messages = []
|
125
129
|
@worker.append(role: :system, content: "<role>\n#{@role}\n</role>") if @role.present?
|
126
130
|
|
@@ -130,6 +134,8 @@ module OxAiWorkers
|
|
130
134
|
@tools.each do |tool|
|
131
135
|
@worker.append(role: :user, content: tool.context) if tool.respond_to?(:context) && tool.context.present?
|
132
136
|
end
|
137
|
+
# Добавляем сохраненные сообщения обратно, если они не пустые
|
138
|
+
@worker.append(messages: current_messages) if current_messages.present?
|
133
139
|
@worker.append(messages: @messages)
|
134
140
|
# @tasks.each { |task| @worker.append(role: :user, content: "<task>\n#{task}\n</task>") }
|
135
141
|
@worker.tools = [function_schemas]
|
@@ -170,10 +176,13 @@ module OxAiWorkers
|
|
170
176
|
end
|
171
177
|
|
172
178
|
def next_iteration
|
179
|
+
# Сначала добавляем сообщения из очереди к worker
|
180
|
+
@worker.append(messages: @queue)
|
181
|
+
# Затем добавляем их к локальным сообщениям
|
173
182
|
@messages += @queue
|
174
183
|
OxAiWorkers.logger.warn "Iterator::Next iteration: #{@messages.count}/#{@queue.count}"
|
184
|
+
# И только потом очищаем очередь
|
175
185
|
@queue = []
|
176
|
-
@worker.append(messages: @messages)
|
177
186
|
request!
|
178
187
|
end
|
179
188
|
|
@@ -242,7 +251,7 @@ module OxAiWorkers
|
|
242
251
|
out:
|
243
252
|
)
|
244
253
|
end
|
245
|
-
@worker.
|
254
|
+
@worker.finish_without_cleanup if @worker.respond_to?(:finish_without_cleanup)
|
246
255
|
iterate! if can_iterate?
|
247
256
|
end
|
248
257
|
result = @worker.result || @worker.errors
|
@@ -254,7 +263,8 @@ module OxAiWorkers
|
|
254
263
|
|
255
264
|
def complete_iteration
|
256
265
|
@queue = []
|
257
|
-
|
266
|
+
# Используем finish_without_cleanup вместо finish
|
267
|
+
@worker.finish_without_cleanup if @worker.respond_to?(:finish_without_cleanup)
|
258
268
|
end
|
259
269
|
|
260
270
|
def add_task(task)
|
@@ -44,7 +44,7 @@ module OxAiWorkers
|
|
44
44
|
OxAiWorkers.logger.warn "Request (String)[#{message[:role]}]: #{content.truncate(500)}"
|
45
45
|
elsif content.is_a?(Array)
|
46
46
|
types = content.map do |item|
|
47
|
-
"#{item[:type]}: #{item[:content]&.truncate(500)}
|
47
|
+
"#{item[:type]}: #{item[:content]&.truncate(500)}"
|
48
48
|
end.compact.join(', ')
|
49
49
|
OxAiWorkers.logger.warn "Request (Array): [#{types}]"
|
50
50
|
else
|
data/lib/oxaiworkers/request.rb
CHANGED
@@ -9,6 +9,16 @@ module OxAiWorkers
|
|
9
9
|
cleanup
|
10
10
|
end
|
11
11
|
|
12
|
+
# Метод для завершения без очистки сообщений
|
13
|
+
def finish_without_cleanup
|
14
|
+
@custom_id = SecureRandom.uuid
|
15
|
+
# Очищаем только результат и ошибки, но не сообщения
|
16
|
+
@result = nil
|
17
|
+
@errors = nil
|
18
|
+
@tool_calls = nil
|
19
|
+
@is_truncated = false
|
20
|
+
end
|
21
|
+
|
12
22
|
def request!
|
13
23
|
response = @model.request(params)
|
14
24
|
parse_choices(response)
|
data/lib/oxaiworkers/version.rb
CHANGED