ox-ai-workers 0.4.0 → 0.4.2

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: fdbdf2dc16b6418e99209c8ff4710fedb25f01eec2b5980b8cc5562e3523d680
4
- data.tar.gz: 33f8d2543e2167be860002296cb45736c4be5fac651be37244be5a0b5ba47ab2
3
+ metadata.gz: 6c6a4642d2f20a5544eb56eb31b2ecb26a190565711f6257793fc5320f4c46ef
4
+ data.tar.gz: 480d67e601de4af89a947cb1951aa81ab04be079073cb6d50fc0b353e780300b
5
5
  SHA512:
6
- metadata.gz: 2f341be677a58fe8959bb86c8c6944769b77ae2d58a1cdae6800caf1ed5981d9c6532ad89549a6b5cb9189305049b123163754b5315a5e30369380a954c3c175
7
- data.tar.gz: 616972852f978d9b6c8c014dd0295d1f338cdda7737db09358a3a5ab11b1e8d120cdc54c91a88618c068b81ff5ec7e16ffc26db11a6ce1bbd176698986f4d1d5
6
+ metadata.gz: 6dfbee661da05077107165b65130ef4540aec31e9bfd7b94052f6ce0e068de593651bdcedaae6e3cdebec289d4d9011ddc0da3a8445b0ea0bce52d797e2a7041
7
+ data.tar.gz: e915d590643c6db03154384e66def40bc3e8b8dd91965dade1c6f3706fc3a874bd7d54301a3de4120b25da8f80f363204b08d8172676750fcb9c6cc965d39e49
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.2] - 2024-07-30
4
+
5
+ - Binary reading is suppressed
6
+ - Command output code is returned if the command output is empty
7
+
3
8
  ## [0.4.0] - 2024-07-30
4
9
 
5
10
  - Added tools: `file_system`, `database`
data/exe/oxaiworkers CHANGED
@@ -13,7 +13,6 @@ if ARGV.first == 'init'
13
13
  if Dir.exist? dir
14
14
  puts "Error: The #{dir} directory already exists."
15
15
  else
16
- FileUtils.mkdir_p "#{dir}/locales"
17
16
  if ARGV.last == 'full'
18
17
  FileUtils.copy_entry "#{source}/template", dest.to_s
19
18
  else
@@ -53,30 +53,30 @@ module OxAiWorkers
53
53
  end
54
54
 
55
55
  def innerMonologue(speach:)
56
- @queue.pop
57
- @queue << { role: :system, content: "#{__method__}: #{speach}" }
56
+ # @queue.pop
57
+ @queue << { role: :system, content: speach.to_s }
58
58
  @on_inner_monologue&.call(text: speach)
59
59
  nil
60
60
  end
61
61
 
62
62
  def outerVoice(text:)
63
- @queue.pop
64
- @queue << { role: :system, content: "#{__method__}: #{text}" }
63
+ # @queue.pop
64
+ @queue << { role: :system, content: text.to_s }
65
65
  @on_outer_voice&.call(text: text)
66
66
  nil
67
67
  end
68
68
 
69
69
  def actionRequest(action:)
70
70
  @result = action
71
- @queue.pop
72
- @messages << { role: :system, content: "#{__method__}: #{action}" }
71
+ # @queue.pop
72
+ @messages << { role: :system, content: action.to_s }
73
73
  complete! if can_complete?
74
74
  @on_action_request&.call(text: action)
75
75
  nil
76
76
  end
77
77
 
78
78
  def packHistory(text:)
79
- @milestones << "#{__method__}: #{text}"
79
+ @milestones << text.to_s
80
80
  @messages = []
81
81
  @worker.finish
82
82
  rebuildWorker
@@ -126,7 +126,7 @@ module OxAiWorkers
126
126
  puts "call: #{__method__} state: #{state_name}"
127
127
  @result = @worker.result || @worker.errors
128
128
  if @worker.tool_calls.present?
129
- @queue << { role: :system, content: @worker.tool_calls_raw.to_s }
129
+ @queue << { role: :assistant, content: @worker.tool_calls_raw.to_s }
130
130
  @worker.tool_calls.each do |external_call|
131
131
  tool = @tools.select do |t|
132
132
  t.class.tool_name == external_call[:class] && t.respond_to?(external_call[:name])
@@ -23,8 +23,10 @@ module OxAiWorkers
23
23
 
24
24
  def sh(input:)
25
25
  puts Rainbow("Executing sh: \"#{input}\"").red
26
- stdout_and_stderr_s, = Open3.capture2e(input)
27
- stdout_and_stderr_s
26
+ stdout_and_stderr_s, status = Open3.capture2e(input)
27
+ return stdout_and_stderr_s if stdout_and_stderr_s.present?
28
+
29
+ status.to_s
28
30
  end
29
31
  end
30
32
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'ptools'
4
+
3
5
  module OxAiWorkers
4
6
  module Tool
5
7
  #
@@ -10,6 +12,7 @@ module OxAiWorkers
10
12
  #
11
13
  class FileSystem
12
14
  extend OxAiWorkers::ToolDefinition
15
+ include OxAiWorkers::DependencyHelper
13
16
 
14
17
  define_function :list_directory,
15
18
  description: I18n.t('oxaiworkers.tool.file_system.list_directory.description') do
@@ -30,22 +33,30 @@ module OxAiWorkers
30
33
  required: true
31
34
  end
32
35
 
36
+ def initialize
37
+ depends_on 'ptools'
38
+ end
39
+
33
40
  def list_directory(directory_path:)
34
- puts "Listing directory: #{directory_path}"
41
+ puts Rainbow("Listing directory: #{directory_path}").magenta
35
42
  Dir.entries(directory_path)
36
43
  rescue Errno::ENOENT
37
44
  "No such directory: #{directory_path}"
38
45
  end
39
46
 
40
47
  def read_file(file_path:)
41
- puts "Reading file: #{file_path}"
42
- File.read(file_path).to_s
48
+ puts Rainbow("Reading file: #{file_path}").magenta
49
+ if File.binary?(file)
50
+ "File is binary: #{file_path}"
51
+ else
52
+ File.read(file_path).to_s
53
+ end
43
54
  rescue Errno::ENOENT
44
55
  "No such file: #{file_path}"
45
56
  end
46
57
 
47
58
  def write_to_file(file_path:, content:)
48
- puts "Writing to file: #{file_path}"
59
+ puts Rainbow("Writing to file: #{file_path}").magenta
49
60
  File.write(file_path, content)
50
61
  "Content was successfully written to the file: #{file_path}"
51
62
  rescue Errno::EACCES
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OxAiWorkers
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.2'
5
5
  end
data/locales/en.tool.yml CHANGED
@@ -13,7 +13,7 @@ en:
13
13
  description: 'File System Tool: Lists out the content of a specified directory'
14
14
  directory_path: 'Directory path to list'
15
15
  read_file:
16
- description: 'File System Tool: Reads the contents of a file'
16
+ description: 'File System Tool: Reads the contents of a text file'
17
17
  file_path: 'Path to the file to read from'
18
18
  write_to_file:
19
19
  description: 'File System Tool: Write content to a file'
data/locales/ru.tool.yml CHANGED
@@ -13,7 +13,7 @@ ru:
13
13
  description: 'Инструмент файловой системы: Выводит содержимое указанного каталога'
14
14
  directory_path: 'Путь к каталогу для вывода содержимого'
15
15
  read_file:
16
- description: 'Инструмент файловой системы: Считывает содержимое файла'
16
+ description: 'Инструмент файловой системы: Считывает содержимое текстового файла'
17
17
  file_path: 'Путь к файлу для считывания'
18
18
  write_to_file:
19
19
  description: 'Инструмент файловой системы: Записывает содержимое в файл'
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.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Smolev