ox-ai-workers 0.6.2.3 → 0.7.0

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: bf126a4c839758576c8dd28e924f2e4473d0be2e6bcbf462016c8271bfe63e74
4
- data.tar.gz: e0ecded110176e8feaeb9929361f379be265f49f4e9cb429cd34d9543aed434f
3
+ metadata.gz: ced51dc28f65c75dd2331716a9843ea3301a1979b9de929c7cecad1ec7cf1c8f
4
+ data.tar.gz: 18dfa8828baf811c7a599e215fbe33700e5d2c21a52d8e597c63d9cf4187013d
5
5
  SHA512:
6
- metadata.gz: 48982ba7196ed961dc8647a73eb5648f25270b8e020abe6cb6aecee0c6af34a3d48923112be30571ae3caabe2401320fb248cefaa04ee4672ad26936065d8226
7
- data.tar.gz: e34ac5dd7cf5530f4609c0d13924c2bef1bbb203f9ddd8971b9e535b48f7e71ecb1cc155764a62b3ae0fd1e6bf727866486582ffc80e16d576796bea66352794
6
+ metadata.gz: 8e3b484f0cf492f32e4382cce682a66d50cef8e8111b6628069fd8c4b6dcd9f9a657007999c8eb966ad723285ebd1fec3176fa05e115b9c85f3db6f68f8af60c
7
+ data.tar.gz: ebf148e9ee57de6f5c6c8fdda086e60dad821b88620d841d7ed66c21f18200f482eab4df97133ee1fe77cb8f0ec2cc7f433e228f43a20f31b438a4fc2f660d95
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
+ ## [0.7.0] - 2024-08-024
2
+
3
+ - Added `finish` for `Iterator`
4
+ - Added `after_finish` for `Iterator`
5
+
1
6
  ## [0.6.3] - 2024-08-024
2
7
 
3
8
  - Added `add_raw_context` for `Iterator`
9
+ - Fixed `requested?`
4
10
 
5
11
  ## [0.6.2] - 2024-08-024
6
12
 
@@ -109,4 +115,4 @@
109
115
 
110
116
  ## [0.1.0] - 2024-07-29
111
117
 
112
- - Initial release
118
+ - 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
@@ -228,7 +238,7 @@ module OxAiWorkers
228
238
  end
229
239
 
230
240
  def add_context(text, role: :system)
231
- add_raw_context { role:, content: text }
241
+ add_raw_context({ role:, content: text })
232
242
  end
233
243
 
234
244
  def add_raw_context(c)
@@ -16,6 +16,10 @@ module OxAiWorkers
16
16
  OxAiWorkers.logger.debug(e.inspect, for: self.class)
17
17
  end
18
18
 
19
+ def requested?
20
+ false
21
+ end
22
+
19
23
  def completed?
20
24
  @result.present? or @errors.present? or @tool_calls.present?
21
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '0.6.2.3'
4
+ VERSION = '0.7.0'
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.2.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev