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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +96 -12
- data/exe/oxaiworkers +9 -0
- data/lib/oxaiworkers/assistant/coder.rb +6 -0
- data/lib/oxaiworkers/tool/eval.rb +1 -1
- data/lib/oxaiworkers/version.rb +1 -1
- data/template/start +4 -0
- 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: 6f6d50356df9fac9b6a2497737e46f2b478051fa9e1c524bde5047c06c38b07b
|
4
|
+
data.tar.gz: 7577169961cd5b1720b697c7751d9560a73415e52bfdba4f889dca695b7c9db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35702e04879dcffc1f87f0224df17c251983ddae5c8915264d5ae5df0a2c254b8e9949bc7333b80125f05791e1ac21c5f5ce3106337db3da18646565d4b0243e
|
7
|
+
data.tar.gz: cbf4c76a447d52484c63afc4546589b4cf4098ad9b441cbb9e7eb7bf8297de011bb1eff5410fdfad57c3010619cb818fb53b8e67bf32f318fc86e995649ca948
|
data/CHANGELOG.md
CHANGED
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
|
data/lib/oxaiworkers/version.rb
CHANGED
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__)
|