ox-ai-workers 0.2.2 → 0.2.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/CHANGELOG.md +4 -0
- data/README.md +43 -10
- data/exe/start +5 -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: e742b4a56d2c4f860ef050e318ec3347d4498740a04331dbd7d9c44d261ea3bb
|
4
|
+
data.tar.gz: 044723cd3ecfecdde286d02dd0af3de1137488b8d2ee8a2d98000dc33a4eaaf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b78ca31b18d8447217a12882d9073dc96f77a6f24687332a160bf06c4ad46a05d59ccc0d621f244573074ca26bb726c29e9196c9a84474a4decc64c78ea974c
|
7
|
+
data.tar.gz: a0e7df6d557677f68e30f4c76ba005b86da6224501d130ea5cabef7683b86d3b4bb186b6eeb5819283412ceecdf969c40c3a29bb6a30345245d8b74a6d47ae39
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.3] - 2024-07-30
|
4
|
+
- start script with configure section
|
5
|
+
|
3
6
|
## [0.2.2] - 2024-07-30
|
4
7
|
- fix cli
|
5
8
|
- better start script (cli: .oxaiworkers-local/start)
|
9
|
+
- better init script
|
6
10
|
|
7
11
|
## [0.2.0] - 2024-07-30
|
8
12
|
- fix missing require 'open3'
|
data/README.md
CHANGED
@@ -27,27 +27,48 @@ gem install ox-ai-workers
|
|
27
27
|
Here's a basic example of how to use OxAiWorkers:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
|
31
|
-
I18n.
|
30
|
+
# Load localization files and set default locale
|
31
|
+
I18n.load_path += Dir[File.expand_path("locales") + "/*.yml"] # only for pure Ruby
|
32
|
+
I18n.default_locale = :en # only for pure Ruby
|
33
|
+
|
34
|
+
# Require the main gem
|
32
35
|
require 'ox-ai-workers'
|
33
36
|
|
34
37
|
# Initialize the assistant
|
35
38
|
sysop = OxAiWorkers::Assistant::Sysop.new(delayed: false, model: "gpt-4o")
|
36
39
|
|
37
|
-
# Add a task
|
40
|
+
# Add a task to the assistant
|
38
41
|
sysop.setTask("Add a cron job to synchronize files daily.")
|
39
42
|
|
40
|
-
#
|
43
|
+
# Provide a response to the assistant's question
|
41
44
|
sysop.addResponse("blah-blah-blah")
|
42
45
|
```
|
43
46
|
|
47
|
+
Alternatively, you can use a lower-level approach for more control:
|
48
|
+
|
44
49
|
```ruby
|
45
|
-
|
46
|
-
|
47
|
-
|
50
|
+
# Initialize a worker for delayed requests
|
51
|
+
worker = OxAiWorkers::DelayedRequest.new(
|
52
|
+
model: "gpt-4o-mini",
|
53
|
+
max_tokens: 4096,
|
54
|
+
temperature: 0.7 )
|
55
|
+
|
56
|
+
# Alternatively, initialize a worker for immediate requests
|
57
|
+
worker = OxAiWorkers::Request.new(
|
58
|
+
model: "gpt-4o-mini",
|
59
|
+
max_tokens: 4096,
|
60
|
+
temperature: 0.7 )
|
61
|
+
|
62
|
+
# Initialize a tool
|
48
63
|
my_tool = OxAiWorkers::Tool::Eval.new()
|
49
|
-
|
64
|
+
|
65
|
+
# Create an iterator with the worker and tool
|
66
|
+
iterator = OxAiWorkers::Iterator.new(
|
67
|
+
worker: worker,
|
68
|
+
tools: [my_tool] )
|
50
69
|
iterator.role = "You are a software agent inside my computer"
|
70
|
+
|
71
|
+
# Add a task to the iterator
|
51
72
|
iterator.addTask("Show files in current dir")
|
52
73
|
```
|
53
74
|
|
@@ -68,18 +89,30 @@ Then you can create an assistant like this:
|
|
68
89
|
|
69
90
|
```ruby
|
70
91
|
assistant = OxAiWorkers::Assistant::Sysop.new()
|
92
|
+
assistant.setTask("your task")
|
71
93
|
```
|
72
94
|
|
95
|
+
Or you can create a lower-level iterator for more control:
|
96
|
+
|
73
97
|
```ruby
|
74
98
|
iterator = OxAiWorkers::Iterator.new(
|
75
99
|
worker: OxAiWorkers::Request.new,
|
76
100
|
tools: [OxAiWorkers::Tool::Eval.new],
|
77
|
-
role: "You are a software agent inside my computer"
|
78
|
-
)
|
101
|
+
role: "You are a software agent inside my computer" )
|
79
102
|
|
80
103
|
iterator.addTask("Show files in current directory.")
|
81
104
|
```
|
82
105
|
|
106
|
+
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.
|
107
|
+
|
108
|
+
### Worker Options
|
109
|
+
|
110
|
+
As a worker, you can use different classes depending on your needs:
|
111
|
+
|
112
|
+
- `OxAiWorkers::Request`: This class is used for immediate request execution. It is suitable for operations that require instant responses.
|
113
|
+
|
114
|
+
- `OxAiWorkers::DelayedRequest`: This class is used for batch API requests, ideal for operations that do not require immediate execution. Using `DelayedRequest` can save up to 50% on costs as requests are executed when the remote server is less busy, but no later than within 24 hours.
|
115
|
+
|
83
116
|
## Command Line Interface (CLI)
|
84
117
|
|
85
118
|
1. Navigate to the required directory.
|
data/exe/start
CHANGED
@@ -10,6 +10,11 @@ require "irb"
|
|
10
10
|
|
11
11
|
puts "OxAiWorkers #{OxAiWorkers::VERSION}"
|
12
12
|
|
13
|
+
OxAiWorkers.configure do |config|
|
14
|
+
config.access_token = ENV.fetch("OPENAI")
|
15
|
+
config.model = "gpt-4o-mini"
|
16
|
+
end
|
17
|
+
|
13
18
|
@assistant = OxAiWorkers::Assistant::Sysop.new()
|
14
19
|
|
15
20
|
IRB.start(__FILE__)
|
data/lib/oxaiworkers/version.rb
CHANGED