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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e742b4a56d2c4f860ef050e318ec3347d4498740a04331dbd7d9c44d261ea3bb
4
- data.tar.gz: 044723cd3ecfecdde286d02dd0af3de1137488b8d2ee8a2d98000dc33a4eaaf0
3
+ metadata.gz: 344c37f9e68f279cdbc7e84247ba973c57e7d3c635de4178c1c6ae48c503cf10
4
+ data.tar.gz: a1bd748d4d078c9f911549f9a0d02be9dd3ce2c02cdaac13b10eb048fe23881f
5
5
  SHA512:
6
- metadata.gz: 8b78ca31b18d8447217a12882d9073dc96f77a6f24687332a160bf06c4ad46a05d59ccc0d621f244573074ca26bb726c29e9196c9a84474a4decc64c78ea974c
7
- data.tar.gz: a0e7df6d557677f68e30f4c76ba005b86da6224501d130ea5cabef7683b86d3b4bb186b6eeb5819283412ceecdf969c40c3a29bb6a30345245d8b74a6d47ae39
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
- - start script with configure section
13
+
14
+ - Added start script with configuration section
5
15
 
6
16
  ## [0.2.2] - 2024-07-30
7
- - fix cli
8
- - better start script (cli: .oxaiworkers-local/start)
9
- - better init script
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
- - fix missing require 'open3'
13
- - fix Steps
14
- - cli: oxaiworkers init
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
- - Fix Delayed Requests
19
- - Configurable model, max_tokens, temperature
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 settings as needed and run:
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
- if ARGV.first == "init"
6
- dir = '.oxaiworkers-local'
7
- dest = "#{Dir.pwd}/#{dir}"
8
- source = File.expand_path('../../', __FILE__)
6
+ puts 'Welcome to OxAiWorkers!'
9
7
 
10
- unless Dir.exist? dir
11
- FileUtils.mkdir_p dir + "/locales"
12
- FileUtils.copy_entry source + "/locales", dest + "/locales"
13
- FileUtils.cp(source+"/exe/start", dest)
14
- puts "A #{dir} directory was created with the necessary initial settings."
15
- puts "Modify the settings as needed and run:"
16
- puts "#{dir}/start"
17
- else
18
- puts "Error: The #{dir} directory already exists."
19
- end
20
- end
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
- require "i18n"
4
- I18n.load_path += Dir[File.expand_path(".oxaiworkers-local/locales") + "/*.yml"]
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 "ox-ai-workers"
9
- require "irb"
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
- config.access_token = ENV.fetch("OPENAI")
15
- config.model = "gpt-4o-mini"
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 delayed: false, model: nil
8
+ def initialize(delayed: false, model: nil)
7
9
  @iterator = OxAiWorkers::Iterator.new(
8
- worker: initWorker(delayed: delayed, model: model),
9
- role: I18n.t("oxaiworkers.assistant.sysop.role"),
10
- tools: [OxAiWorkers::Tool::Eval.new]
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("oxaiworkers.tool.eval.ruby.description") do
10
- property :input, type: "string", description: I18n.t("oxaiworkers.tool.eval.ruby.input"), required: true
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("oxaiworkers.tool.eval.sh.description") do
14
- property :input, type: "string", description: I18n.t("oxaiworkers.tool.eval.sh.input"), required: true
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, _ = Open3.capture2e(input)
25
- return stdout_and_stderr_s
25
+ stdout_and_stderr_s, = Open3.capture2e(input)
26
+ stdout_and_stderr_s
26
27
  end
27
28
  end
28
- end
29
+ end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = "0.2.3"
4
+ VERSION = '0.2.5'
5
5
  end
6
-
@@ -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.3
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-29 00:00:00.000000000 Z
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: state_machine
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: ruby-openai
56
+ name: rainbow
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '7'
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: '7'
68
+ version: '3'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rainbow
70
+ name: ruby-openai
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '3'
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: '3'
82
+ version: '7'
83
83
  - !ruby/object:Gem::Dependency
84
- name: i18n
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.6.0
159
+ version: 2.7.0
157
160
  required_rubygems_version: !ruby/object:Gem::Requirement
158
161
  requirements:
159
162
  - - ">="