ox-ai-workers 0.2.3 → 0.2.5
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 +22 -11
- data/README.md +18 -2
- data/exe/oxaiworkers +21 -15
- data/exe/start +8 -7
- data/lib/oxaiworkers/assistant/sysop.rb +8 -6
- data/lib/oxaiworkers/tool/eval.rb +8 -7
- data/lib/oxaiworkers/version.rb +1 -2
- data/template/my_assistant.rb +15 -0
- data/template/start +22 -0
- data/template/tools/my_tool.rb +16 -0
- metadata +14 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344c37f9e68f279cdbc7e84247ba973c57e7d3c635de4178c1c6ae48c503cf10
|
4
|
+
data.tar.gz: a1bd748d4d078c9f911549f9a0d02be9dd3ce2c02cdaac13b10eb048fe23881f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78703cebb3370c3ca967346e77f5816720a824ebefb9170d304add87aa7e4cbb1f54f7f2904bbf11e8bed5030730f24e6f9b40ea7ff59126968c70d43960ffd1
|
7
|
+
data.tar.gz: 7331e973af417507cc7c2232080b104a4d0e173eb7c1117513089374b648a3f759b31b8cffa2c1f0bb551178f63f169e7a81c2e4134381f50df5c3a95998bd3c
|
data/CHANGELOG.md
CHANGED
@@ -1,24 +1,35 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.5] - 2024-07-30
|
4
|
+
|
5
|
+
- Improved start template
|
6
|
+
|
7
|
+
## [0.2.4] - 2024-07-30
|
8
|
+
|
9
|
+
- Complete template for initialization: `oxaiworkers init full`
|
10
|
+
- Fix missing require_relative
|
11
|
+
|
3
12
|
## [0.2.3] - 2024-07-30
|
4
|
-
|
13
|
+
|
14
|
+
- Added start script with configuration section
|
5
15
|
|
6
16
|
## [0.2.2] - 2024-07-30
|
7
|
-
|
8
|
-
-
|
9
|
-
-
|
17
|
+
|
18
|
+
- Fixed CLI issues
|
19
|
+
- Improved start script (CLI: .oxaiworkers-local/start)
|
20
|
+
- Enhanced initialization script
|
10
21
|
|
11
22
|
## [0.2.0] - 2024-07-30
|
12
|
-
|
13
|
-
-
|
14
|
-
-
|
23
|
+
|
24
|
+
- Fixed missing require 'open3'
|
25
|
+
- Corrected execution steps
|
26
|
+
- CLI: added command `oxaiworkers init`
|
15
27
|
|
16
28
|
## [0.1.1] - 2024-07-29
|
17
29
|
|
18
|
-
-
|
19
|
-
-
|
30
|
+
- Fixed delayed requests
|
31
|
+
- Added configurable parameters for model, max_tokens, temperature
|
20
32
|
|
21
33
|
## [0.1.0] - 2024-07-29
|
22
34
|
|
23
|
-
- Initial release
|
24
|
-
|
35
|
+
- Initial release
|
data/README.md
CHANGED
@@ -70,6 +70,9 @@ iterator.role = "You are a software agent inside my computer"
|
|
70
70
|
|
71
71
|
# Add a task to the iterator
|
72
72
|
iterator.addTask("Show files in current dir")
|
73
|
+
|
74
|
+
# Provide a response to the gpt's question
|
75
|
+
iterator.addTask("linux")
|
73
76
|
```
|
74
77
|
|
75
78
|
### With Config
|
@@ -90,6 +93,9 @@ Then you can create an assistant like this:
|
|
90
93
|
```ruby
|
91
94
|
assistant = OxAiWorkers::Assistant::Sysop.new()
|
92
95
|
assistant.setTask("your task")
|
96
|
+
|
97
|
+
# Provide a response to the assistant's question
|
98
|
+
assistant.addResponse("blah-blah-blah")
|
93
99
|
```
|
94
100
|
|
95
101
|
Or you can create a lower-level iterator for more control:
|
@@ -101,6 +107,8 @@ iterator = OxAiWorkers::Iterator.new(
|
|
101
107
|
role: "You are a software agent inside my computer" )
|
102
108
|
|
103
109
|
iterator.addTask("Show files in current directory.")
|
110
|
+
# ...
|
111
|
+
iterator.addTask("linux")
|
104
112
|
```
|
105
113
|
|
106
114
|
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.
|
@@ -123,9 +131,17 @@ As a worker, you can use different classes depending on your needs:
|
|
123
131
|
oxaiworkers init
|
124
132
|
```
|
125
133
|
|
126
|
-
This will create a `.oxaiworkers-local` directory with the necessary initial settings.
|
134
|
+
This will create a `.oxaiworkers-local` directory with the necessary initial settings.
|
135
|
+
|
136
|
+
Additionally, you can initialize a more comprehensive example using the command:
|
137
|
+
|
138
|
+
```sh
|
139
|
+
oxaiworkers init full
|
140
|
+
```
|
141
|
+
|
142
|
+
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.
|
127
143
|
|
128
|
-
3. Modify the
|
144
|
+
3. Modify the code as needed and run:
|
129
145
|
|
130
146
|
```sh
|
131
147
|
.oxaiworkers-local/start
|
data/exe/oxaiworkers
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'fileutils'
|
4
5
|
|
5
|
-
|
6
|
-
dir = '.oxaiworkers-local'
|
7
|
-
dest = "#{Dir.pwd}/#{dir}"
|
8
|
-
source = File.expand_path('../../', __FILE__)
|
6
|
+
puts 'Welcome to OxAiWorkers!'
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
if ARGV.first == 'init'
|
9
|
+
dir = '.oxaiworkers-local'
|
10
|
+
dest = "#{Dir.pwd}/#{dir}"
|
11
|
+
source = File.expand_path('..', __dir__)
|
12
|
+
|
13
|
+
if Dir.exist? dir
|
14
|
+
puts "Error: The #{dir} directory already exists."
|
15
|
+
else
|
16
|
+
FileUtils.mkdir_p "#{dir}/locales"
|
17
|
+
FileUtils.copy_entry "#{source}/locales", "#{dest}/locales"
|
18
|
+
if ARGV.last == 'full'
|
19
|
+
FileUtils.copy_entry "#{source}/template", dest.to_s
|
20
|
+
else
|
21
|
+
FileUtils.cp("#{source}/exe/start", dest)
|
22
|
+
end
|
23
|
+
puts "A #{dir} directory was created with the necessary initial settings."
|
24
|
+
puts "Modify the settings as needed and run: #{dir}/start"
|
25
|
+
end
|
26
|
+
end
|
data/exe/start
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
require 'i18n'
|
5
|
+
I18n.load_path += Dir["#{File.expand_path('.oxaiworkers-local/locales')}/*.yml"]
|
5
6
|
I18n.default_locale = :en
|
6
7
|
|
7
8
|
# Start your code here
|
8
|
-
require
|
9
|
-
require
|
9
|
+
require 'ox-ai-workers'
|
10
|
+
require 'irb'
|
10
11
|
|
11
12
|
puts "OxAiWorkers #{OxAiWorkers::VERSION}"
|
12
13
|
|
13
14
|
OxAiWorkers.configure do |config|
|
14
|
-
|
15
|
-
|
15
|
+
config.access_token = ENV.fetch('OPENAI')
|
16
|
+
config.model = 'gpt-4o-mini'
|
16
17
|
end
|
17
18
|
|
18
|
-
@assistant = OxAiWorkers::Assistant::Sysop.new
|
19
|
+
@assistant = OxAiWorkers::Assistant::Sysop.new
|
19
20
|
|
20
21
|
IRB.start(__FILE__)
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module OxAiWorkers
|
2
4
|
module Assistant
|
3
5
|
class Sysop
|
4
6
|
include OxAiWorkers::Assistant::ModuleBase
|
5
7
|
|
6
|
-
def initialize
|
8
|
+
def initialize(delayed: false, model: nil)
|
7
9
|
@iterator = OxAiWorkers::Iterator.new(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
worker: initWorker(delayed: delayed, model: model),
|
11
|
+
role: I18n.t('oxaiworkers.assistant.sysop.role'),
|
12
|
+
tools: [OxAiWorkers::Tool::Eval.new]
|
13
|
+
)
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'open3'
|
3
4
|
|
4
5
|
module OxAiWorkers::Tool
|
@@ -6,12 +7,12 @@ module OxAiWorkers::Tool
|
|
6
7
|
extend OxAiWorkers::ToolDefinition
|
7
8
|
include OxAiWorkers::DependencyHelper
|
8
9
|
|
9
|
-
define_function :ruby, description: I18n.t(
|
10
|
-
property :input, type:
|
10
|
+
define_function :ruby, description: I18n.t('oxaiworkers.tool.eval.ruby.description') do
|
11
|
+
property :input, type: 'string', description: I18n.t('oxaiworkers.tool.eval.ruby.input'), required: true
|
11
12
|
end
|
12
13
|
|
13
|
-
define_function :sh, description: I18n.t(
|
14
|
-
property :input, type:
|
14
|
+
define_function :sh, description: I18n.t('oxaiworkers.tool.eval.sh.description') do
|
15
|
+
property :input, type: 'string', description: I18n.t('oxaiworkers.tool.eval.sh.input'), required: true
|
15
16
|
end
|
16
17
|
|
17
18
|
def ruby(input:)
|
@@ -21,8 +22,8 @@ module OxAiWorkers::Tool
|
|
21
22
|
|
22
23
|
def sh(input:)
|
23
24
|
puts Rainbow("Executing sh: \"#{input}\"").red
|
24
|
-
stdout_and_stderr_s,
|
25
|
-
|
25
|
+
stdout_and_stderr_s, = Open3.capture2e(input)
|
26
|
+
stdout_and_stderr_s
|
26
27
|
end
|
27
28
|
end
|
28
|
-
end
|
29
|
+
end
|
data/lib/oxaiworkers/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'tools/my_tool'
|
4
|
+
|
5
|
+
class MyAssistant
|
6
|
+
include OxAiWorkers::Assistant::ModuleBase
|
7
|
+
|
8
|
+
def initialize(delayed: false, model: nil)
|
9
|
+
@iterator = OxAiWorkers::Iterator.new(
|
10
|
+
worker: initWorker(delayed: delayed, model: model),
|
11
|
+
role: 'You are a software agent inside my computer',
|
12
|
+
tools: [MyTool.new]
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
data/template/start
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'i18n'
|
5
|
+
I18n.load_path += Dir["#{File.expand_path('.oxaiworkers-local/locales')}/*.yml"]
|
6
|
+
I18n.default_locale = :en
|
7
|
+
|
8
|
+
# Start your code here
|
9
|
+
require 'ox-ai-workers'
|
10
|
+
require 'irb'
|
11
|
+
require_relative 'my_assistant'
|
12
|
+
|
13
|
+
puts "OxAiWorkers #{OxAiWorkers::VERSION}"
|
14
|
+
|
15
|
+
OxAiWorkers.configure do |config|
|
16
|
+
config.access_token = ENV.fetch('OPENAI')
|
17
|
+
config.model = 'gpt-4o-mini'
|
18
|
+
end
|
19
|
+
|
20
|
+
@assistant = MyAssistant.new
|
21
|
+
|
22
|
+
IRB.start(__FILE__)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MyTool
|
4
|
+
extend OxAiWorkers::ToolDefinition
|
5
|
+
include OxAiWorkers::DependencyHelper
|
6
|
+
|
7
|
+
define_function :sh, description: 'Execute a sh command and get the result (stdout + stderr)' do
|
8
|
+
property :input, type: 'string', description: 'Source command', required: true
|
9
|
+
end
|
10
|
+
|
11
|
+
def sh(input:)
|
12
|
+
puts "Executing sh: \"#{input}\""
|
13
|
+
stdout_and_stderr_s, = Open3.capture2e(input)
|
14
|
+
stdout_and_stderr_s
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ox-ai-workers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Smolev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: i18n
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,35 +53,35 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rainbow
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: ruby-openai
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '7'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: state_machine
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -138,6 +138,9 @@ files:
|
|
138
138
|
- lib/ruby/ox-ai-workers.rb
|
139
139
|
- locales/en.system.yml
|
140
140
|
- locales/ru.system.yml
|
141
|
+
- template/my_assistant.rb
|
142
|
+
- template/start
|
143
|
+
- template/tools/my_tool.rb
|
141
144
|
homepage: https://ai.oxteam.me
|
142
145
|
licenses:
|
143
146
|
- MIT
|
@@ -153,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
156
|
requirements:
|
154
157
|
- - ">="
|
155
158
|
- !ruby/object:Gem::Version
|
156
|
-
version: 2.
|
159
|
+
version: 2.7.0
|
157
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
161
|
requirements:
|
159
162
|
- - ">="
|