ox-ai-workers 0.6.3 → 0.7.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: 82e40f2cc0ce3cadfe5d983d142222e2f79f403b0db8612aa46ac8063b74b79b
4
- data.tar.gz: 46b36ba0f6e7e752045ef17224fec3a3eb56386600efaba23f51220385bc9eba
3
+ metadata.gz: 1b048bed552be5256c39e0fecf347b159c260d61d34c10a5934150950eb3fed2
4
+ data.tar.gz: cfeae19629b927972efdc4aace51bc91cee71c3d67d31f9e6c86bf6b299250b9
5
5
  SHA512:
6
- metadata.gz: da2fe5d8378bae2210f3501a533a9542ce3f7d5f8d4a75872a26d4a93111ceac1d8633137a267ab3ecc4a953cc939d9c64d10c60759ee810eda64d8d550b0393
7
- data.tar.gz: 30e386279def1e4c96a93432e4c5d76a99806a62948d1b24bda53680e43c3990a3337d2928fe914ce1e5e19b9df50be7bfc1b60d2d877027f65949ba0690e54e
6
+ metadata.gz: 7cc8ce0a323462ebc2a65489746f642cc23770dc3e1b6dcdf0207fc5346823c9103058832920e44b8d274bd1b83690b5ccbd9b53480672751ff25c40d4f0a1f5
7
+ data.tar.gz: aafed04d15213bed593c0479ece8fbf038fe93461c68b7de8f7fa4e36239f158bf6b29a4464755e1ee7850fc71ff12f3738605a75182c2c2e89d1b62edbbd5f3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [0.7.1] - 2024-08-024
2
+
3
+ - Added retry for `Iterator`
4
+
5
+ ## [0.7.0] - 2024-08-024
6
+
7
+ - Added `finish` for `Iterator`
8
+ - Added `after_finish` for `Iterator`
9
+
1
10
  ## [0.6.3] - 2024-08-024
2
11
 
3
12
  - Added `add_raw_context` for `Iterator`
@@ -110,4 +119,4 @@
110
119
 
111
120
  ## [0.1.0] - 2024-07-29
112
121
 
113
- - Initial release
122
+ - Initial release
@@ -15,8 +15,9 @@ en:
15
15
  text: Enumeration of important facts and nuances
16
16
  result: Messages deleted
17
17
  monologue:
18
- - Step 1. Develop your own solution to the problem, taking initiative and making assumptions.
19
- - Step 2. Enclose all your developments from the previous step in the ox_ai_workers_iterator__inner_monologue function.
20
- - Step 3. Call the necessary functions one after another until the desired result is achieved.
21
- - Step 4. When all intermediate steps are completed and the exact content of previous messages is no longer relevant, use the ox_ai_workers_iterator__summarize function.
22
- - Step 5. When the solution is ready, notify about it and wait for the user's response.
18
+ - Step %d. Develop your own solution to the problem, taking initiative and making assumptions.
19
+ - Step %d. Enclose all your developments from the previous step in the ox_ai_workers_iterator__inner_monologue function.
20
+ - Step %d. Call the necessary functions one after another until the desired result is achieved.
21
+ - Step %d. When all intermediate steps are completed and the exact content of previous messages is no longer relevant, use the ox_ai_workers_iterator__summarize function.
22
+ - Step %d. When the solution is ready, notify about it and wait for the user's response.
23
+ - Step %d. In the end, call the ox_ai_workers_iterator__finish function.
@@ -14,9 +14,12 @@ ru:
14
14
  description: Функция сохраняет ключевые факты, нюансы и действия из предыдущих сообщений, включая предоставленный ответ. После вызова этой функции все предыдущие сообщения будут удалены. Используйте её только после завершения всех промежуточных шагов и когда точное содержание предыдущих сообщений больше не имеет значения.
15
15
  text: Перечисление важных фактов и нюансов
16
16
  result: Сообщения удалены
17
+ finish:
18
+ description: Функция для завершения шагов.
17
19
  monologue:
18
- - Шаг 1. Разработай собственное решение проблемы, проявляя инициативу и делая предположения.
19
- - Шаг 2. Заключи все свои наработки из предыдущего шага в функцию ox_ai_workers_iterator__inner_monologue.
20
- - Шаг 3. Вызывай необходимые функции друг за другом, пока желаемый результат не будет достигнут.
21
- - Шаг 4. Когда все промежуточные шаги завершены и точное содержание предыдущих сообщений больше не имеет значения, используй функцию ox_ai_workers_iterator__summarize.
22
- - Шаг 5. Когда решение готово, сообщи об этом и ожидай ответ пользователя.
20
+ - Шаг %d. Разработай собственное решение проблемы, проявляй инициативу и делай предположения.
21
+ - Шаг %d. Заключи все свои наработки из предыдущего шага в функцию ox_ai_workers_iterator__inner_monologue.
22
+ - Шаг %d. Вызывай необходимые функции друг за другом, пока желаемый результат не будет достигнут.
23
+ - Шаг %d. Когда все промежуточные шаги завершены и точное содержание предыдущих сообщений больше не имеет значения, используй функцию ox_ai_workers_iterator__summarize.
24
+ - Шаг %d. Когда решение готово, сообщи об этом с помощью функции ox_ai_workers_iterator__action_request и ожидай ответ пользователя.
25
+ - Шаг %d. В конце вызови функцию ox_ai_workers_iterator__finish.
@@ -11,7 +11,7 @@ module OxAiWorkers
11
11
  :on_inner_monologue, :on_outer_voice, :on_action_request, :on_summarize, :def_except, :def_only
12
12
 
13
13
  def initialize(worker:, role: nil, tools: [], on_inner_monologue: nil, on_outer_voice: nil, on_action_request: nil,
14
- on_summarize: nil, steps: nil, def_except: [], def_only: nil, locale: nil)
14
+ on_summarize: nil, after_finish: nil, steps: nil, def_except: [], def_only: nil, locale: nil)
15
15
 
16
16
  @locale = locale || I18n.locale
17
17
 
@@ -34,6 +34,8 @@ module OxAiWorkers
34
34
  property :text, type: 'string', description: I18n.t('oxaiworkers.iterator.summarize.text'), required: true
35
35
  end
36
36
 
37
+ define_function :finish, description: I18n.t('oxaiworkers.iterator.finish.description')
38
+
37
39
  @monologue = steps || I18n.t('oxaiworkers.iterator.monologue')
38
40
  end
39
41
 
@@ -48,6 +50,7 @@ module OxAiWorkers
48
50
  @on_outer_voice = on_outer_voice
49
51
  @on_action_request = on_action_request
50
52
  @on_summarize = on_summarize
53
+ @after_finish = after_finish
51
54
 
52
55
  cleanup
53
56
 
@@ -99,6 +102,12 @@ module OxAiWorkers
99
102
  nil
100
103
  end
101
104
 
105
+ def finish
106
+ complete! if can_complete?
107
+ @after_finish&.call
108
+ nil
109
+ end
110
+
102
111
  def summarize(text:)
103
112
  @milestones << text.to_s
104
113
  @messages = []
@@ -142,7 +151,8 @@ module OxAiWorkers
142
151
  end
143
152
 
144
153
  def valid_monologue
145
- @monologue.reject { |item| @def_except.any? { |fun| item.include?(full_function_name(fun)) } }
154
+ arr = @monologue.reject { |item| @def_except.any? { |fun| item.include?(full_function_name(fun)) } }
155
+ arr.each_with_index.map { |item, index| format(item, index + 1) }
146
156
  end
147
157
 
148
158
  def tool_name
@@ -169,7 +179,17 @@ module OxAiWorkers
169
179
  end
170
180
 
171
181
  def external_request
172
- @worker.request!
182
+ begin
183
+ @worker.request!
184
+ rescue Faraday::ServerError => e
185
+ logger.error "Iterator::ServerError #{e.message}"
186
+ sleep(10)
187
+ external_request
188
+ rescue Faraday::ForbiddenError => e
189
+ logger.error "Iterator::ForbiddenError #{e.message}"
190
+ rescue StandardError => e
191
+ logger.error "Iterator::StandardError #{e.message}"
192
+ end
173
193
  tick_or_wait
174
194
  end
175
195
 
@@ -228,7 +248,7 @@ module OxAiWorkers
228
248
  end
229
249
 
230
250
  def add_context(text, role: :system)
231
- add_raw_context({ role: role, content: text })
251
+ add_raw_context({ role:, content: text })
232
252
  end
233
253
 
234
254
  def add_raw_context(c)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '0.6.3'
4
+ VERSION = '0.7.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.6.3
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev