ox-ai-workers 0.5.5 → 0.5.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: ca54c1ff9c1f4360ddfe986c4b5bc6fb6b7c0cde0484d1b2f88bfe4d8c5707b7
4
- data.tar.gz: 2c54e55fedd99af36f7a510ab923c54581faecfc8b36caa4d228f14349e293a8
3
+ metadata.gz: 6f6d50356df9fac9b6a2497737e46f2b478051fa9e1c524bde5047c06c38b07b
4
+ data.tar.gz: 7577169961cd5b1720b697c7751d9560a73415e52bfdba4f889dca695b7c9db7
5
5
  SHA512:
6
- metadata.gz: b8915a64826c118706328c89a87c01fdf49f13b63408c64d5af1ea53a2f92dbb326b9e537f36aa755297a5c919239d426da1f38a83b3cd5fdfbc5a9ebc4146f7
7
- data.tar.gz: 8614ed16d7771b594bda52de36f87bbd211adfc8c579fff752634fc4ce44a7d554cd25cf7b32bfaa80954830f835a7b3c1f61d0e237c930bc043f433e98534c1
6
+ metadata.gz: 35702e04879dcffc1f87f0224df17c251983ddae5c8915264d5ae5df0a2c254b8e9949bc7333b80125f05791e1ac21c5f5ce3106337db3da18646565d4b0243e
7
+ data.tar.gz: cbf4c76a447d52484c63afc4546589b4cf4098ad9b441cbb9e7eb7bf8297de011bb1eff5410fdfad57c3010619cb818fb53b8e67bf32f318fc86e995649ca948
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.6] - 2024-08-02
4
+
5
+ - Added `oxaiworkers run` command
6
+
3
7
  ## [0.5.5] - 2024-08-02
4
8
 
5
9
  - Added `only` for Tools
data/README.md CHANGED
@@ -97,9 +97,11 @@ Then you can create an assistant like this:
97
97
  ```ruby
98
98
  assistant = OxAiWorkers::Assistant::Sysop.new()
99
99
  assistant.task = "Remove all cron jobs."
100
+ # assistant.execute # if auto_execute is false
100
101
 
101
102
  # Provide a response to the assistant's question
102
103
  assistant.add_response("blah-blah-blah")
104
+ # assistant.execute # if auto_execute is false
103
105
  ```
104
106
 
105
107
  Besides, you can create assistants with different locales
@@ -132,6 +134,12 @@ iterator.add_task("Show files in current directory.")
132
134
  iterator.add_task("linux")
133
135
  ```
134
136
 
137
+ If `auto_execute` is set to false in the configuration, don't forget to manually execute the iterator or assistant.
138
+
139
+ ```ruby
140
+ iterator.execute # if auto_execute is false
141
+ ```
142
+
135
143
  This way, you have the flexibility to choose between a higher-level assistant for simplicity or a lower-level iterator for finer control over the tasks and tools used.
136
144
 
137
145
  ### Advanced instructions for your Assistant
@@ -176,25 +184,25 @@ As a worker, you can use different classes depending on your needs:
176
184
 
177
185
  2. Initialize with the command:
178
186
 
179
- ```sh
180
- oxaiworkers init
181
- ```
187
+ ```sh
188
+ oxaiworkers init
189
+ ```
182
190
 
183
- This will create a `.oxaiworkers-local` directory with the necessary initial source code.
191
+ This will create a `.oxaiworkers-local` directory with the necessary initial source code.
184
192
 
185
- Additionally, you can initialize a more comprehensive example using the command:
193
+ Additionally, you can initialize a more comprehensive example using the command:
186
194
 
187
- ```sh
188
- oxaiworkers init full
189
- ```
195
+ ```sh
196
+ oxaiworkers init full
197
+ ```
190
198
 
191
- After this, in the `my_assistant.rb` file, you can find an example of an assistant that uses a tool from the `tools/my_tool.rb` file. In the `start` file, you will find the algorithm for applying this assistant.
199
+ After this, in the `my_assistant.rb` file, you can find an example of an assistant that uses a tool from the `tools/my_tool.rb` file. In the `start` file, you will find the algorithm for applying this assistant.
192
200
 
193
201
  3. Modify the code as needed and run:
194
202
 
195
- ```sh
196
- .oxaiworkers-local/start
197
- ```
203
+ ```sh
204
+ .oxaiworkers-local/start
205
+ ```
198
206
 
199
207
  ## Logging
200
208
 
@@ -205,6 +213,82 @@ To show all log messages:
205
213
  OxAiWorkers.logger.level = :debug
206
214
  ```
207
215
 
216
+ ## Real World Examples
217
+
218
+ ### Project: Python Snake Game
219
+
220
+ 1. Create the project folder:
221
+
222
+ ```sh
223
+ mkdir snake
224
+ cd snake
225
+ ```
226
+
227
+ 2. Initialize OxAiWorkers:
228
+
229
+ ```sh
230
+ oxaiworkers init
231
+ ```
232
+
233
+ 3. Modify the file `.oxaiworkers-local/start`:
234
+
235
+ ```ruby
236
+ # Replace
237
+ @assistant = OxAiWorkers::Assistant::Sysop.new
238
+
239
+ # With
240
+ @assistant = OxAiWorkers::Assistant::Coder.new(language: 'python')
241
+ ```
242
+
243
+ 4. Run the project:
244
+
245
+ ```sh
246
+ .oxaiworkers-local/start
247
+ ```
248
+
249
+ 5. In the command prompt, type:
250
+
251
+ ```sh
252
+ @assistant.task = "Write a snake game"
253
+ ```
254
+
255
+ ### Running System Operator in Any Directory
256
+
257
+ To run OxAiWorkers in any directory, execute the following command:
258
+
259
+ ```sh
260
+ oxaiworkers run sysop
261
+ ```
262
+
263
+ Alternatively, you can use IRB (Interactive Ruby):
264
+
265
+ 1. Start IRB:
266
+
267
+ ```sh
268
+ irb
269
+ ```
270
+
271
+ 2. In the console, enter the following commands:
272
+
273
+ ```ruby
274
+ require 'ox-ai-workers'
275
+ @sysop = OxAiWorkers::Assistant::Sysop.new
276
+ ```
277
+
278
+ Then set a task:
279
+
280
+ ```ruby
281
+ @sysop.task = "Show all cron jobs."
282
+ ```
283
+
284
+ After these steps you can interact with it using the following method:
285
+
286
+ ```ruby
287
+ @sysop.add_response("Yes, I want it.")
288
+ ```
289
+
290
+ or set a new task.
291
+
208
292
  ## Features
209
293
 
210
294
  - **Generative Intelligence**: Leverages OpenAI's capabilities to enhance task execution.
data/exe/oxaiworkers CHANGED
@@ -21,4 +21,13 @@ if ARGV.first == 'init'
21
21
  puts "A #{dir} directory was created with the necessary initial settings."
22
22
  puts "Modify the settings as needed and run: #{dir}/start"
23
23
  end
24
+ elsif ARGV.first == 'run'
25
+ require 'irb'
26
+ require 'ox-ai-workers'
27
+ puts "#{ARGV.last.capitalize}: #{OxAiWorkers::VERSION}"
28
+ instance_variable_set("@#{ARGV.last}", Object.const_get("OxAiWorkers::Assistant::#{ARGV.last.capitalize}").new)
29
+ ARGV.clear
30
+ IRB.start
31
+ else
32
+ puts "Error: Unknown command: #{ARGV.first}"
24
33
  end
@@ -18,6 +18,12 @@ module OxAiWorkers
18
18
  on_summarize: ->(text:) { puts "summary: #{text}".colorize(:blue) }
19
19
  )
20
20
  end
21
+
22
+ def language=(language)
23
+ with_locale do
24
+ @iterator.role = format(I18n.t('oxaiworkers.assistant.coder.role'), language)
25
+ end
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -24,7 +24,7 @@ module OxAiWorkers
24
24
  end
25
25
 
26
26
  def ruby(input:)
27
- puts "Executing ruby: \"#{input}\"".colorize(:red)
27
+ OxAiWorkers.logger.info("Executing ruby: \"#{input}\"", for: self.class)
28
28
  eval(input)
29
29
  end
30
30
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '0.5.5'
4
+ VERSION = '0.5.6'
5
5
  end
data/template/start CHANGED
@@ -20,6 +20,7 @@ puts "OxAiWorkers #{OxAiWorkers::VERSION}"
20
20
  OxAiWorkers.configure do |config|
21
21
  config.access_token = ENV.fetch('OPENAI')
22
22
  config.model = 'gpt-4o-mini'
23
+ # config.auto_execute = false
23
24
  end
24
25
 
25
26
  # OxAiWorkers.logger.level = :debug
@@ -28,4 +29,7 @@ end
28
29
  @assistant = MyAssistant.new
29
30
  @assistant.task = '2 + 2 is ?'
30
31
 
32
+ # Uncomment this if auto_execute is false
33
+ # @assistant.execute
34
+
31
35
  IRB.start(__FILE__)
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.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev