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 +4 -4
- data/CHANGELOG.md +5 -0
- data/exe/oxaiworkers +0 -1
- data/lib/oxaiworkers/iterator.rb +8 -8
- data/lib/oxaiworkers/tool/eval.rb +4 -2
- data/lib/oxaiworkers/tool/file_system.rb +15 -4
- data/lib/oxaiworkers/version.rb +1 -1
- data/locales/en.tool.yml +1 -1
- data/locales/ru.tool.yml +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: 6c6a4642d2f20a5544eb56eb31b2ecb26a190565711f6257793fc5320f4c46ef
|
4
|
+
data.tar.gz: 480d67e601de4af89a947cb1951aa81ab04be079073cb6d50fc0b353e780300b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dfbee661da05077107165b65130ef4540aec31e9bfd7b94052f6ce0e068de593651bdcedaae6e3cdebec289d4d9011ddc0da3a8445b0ea0bce52d797e2a7041
|
7
|
+
data.tar.gz: e915d590643c6db03154384e66def40bc3e8b8dd91965dade1c6f3706fc3a874bd7d54301a3de4120b25da8f80f363204b08d8172676750fcb9c6cc965d39e49
|
data/CHANGELOG.md
CHANGED
data/exe/oxaiworkers
CHANGED
data/lib/oxaiworkers/iterator.rb
CHANGED
@@ -53,30 +53,30 @@ module OxAiWorkers
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def innerMonologue(speach:)
|
56
|
-
@queue.pop
|
57
|
-
@queue << { role: :system, content:
|
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:
|
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:
|
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 <<
|
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: :
|
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.
|
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
|
data/lib/oxaiworkers/version.rb
CHANGED
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: 'Инструмент файловой системы: Записывает содержимое в файл'
|