omniai-tools 0.1.0 → 0.3.0
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/Gemfile +1 -0
- data/README.md +80 -0
- data/bin/setup +0 -2
- data/lib/omniai/tools/disk/base_tool.rb +0 -1
- data/lib/omniai/tools/disk/directory_create_tool.rb +2 -0
- data/lib/omniai/tools/disk/directory_delete_tool.rb +2 -0
- data/lib/omniai/tools/disk/file_create_tool.rb +2 -0
- data/lib/omniai/tools/disk/file_delete_tool.rb +4 -2
- data/lib/omniai/tools/disk/file_move_tool.rb +4 -2
- data/lib/omniai/tools/disk/file_read_tool.rb +3 -1
- data/lib/omniai/tools/disk/file_replace_tool.rb +3 -1
- data/lib/omniai/tools/disk/file_write_tool.rb +3 -1
- data/lib/omniai/tools/disk/summary_tool.rb +1 -1
- data/lib/omniai/tools/docker/compose_run_tool.rb +5 -5
- data/lib/omniai/tools/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbc1dae9ab7fe238fadd4c48d660f342e851b1803e3e33e22c487ceabd3bf32b
|
4
|
+
data.tar.gz: cf37310371a1711adaedea7609ce340552c7858faab4d9b60c6d26919864490a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 766b80d9ab2b3bf459eeee00473c69f352fd4e61b70a4be9531a76b164d1e1fbc7373fe634033f19c519dc56098b77e536431d53a46bd91bde017887ed91f61a
|
7
|
+
data.tar.gz: 1fc747fda798976e4c13e4c0fd208a83253b61d8f1b473029e085308f7603f7d20e616f32c9b0e564952e6f48cf4e1eb10cc5570d8d6525c6c4a9728449e5b08
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,3 +5,83 @@
|
|
5
5
|
[](https://github.com/ksylvest/omniai-tools)
|
6
6
|
[](https://omniai-tools.ksylvest.com)
|
7
7
|
[](https://circleci.com/gh/ksylvest/omniai-tools)
|
8
|
+
|
9
|
+
`OmniAI::Tools` is a library of pre-built tools to simplify integrating common tasks with [OmniAI](https://github.com/ksylvest/omniai).
|
10
|
+
|
11
|
+
## Disk
|
12
|
+
|
13
|
+
Disk tools are focused on creating, updating, and deleting files and directories within a "root":
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require "omniai/openai"
|
17
|
+
require "omniai/tools"
|
18
|
+
|
19
|
+
print "Root (e.g. /usr/src/project): "
|
20
|
+
root = gets.strip
|
21
|
+
|
22
|
+
client = OmniAI::OpenAI::Client.new
|
23
|
+
logger = Logger.new($stdout)
|
24
|
+
|
25
|
+
tools = [
|
26
|
+
OmniAI::Tools::Disk::DirectoryCreateTool,
|
27
|
+
OmniAI::Tools::Disk::DirectoryDeleteTool,
|
28
|
+
OmniAI::Tools::Disk::FileCreateTool,
|
29
|
+
OmniAI::Tools::Disk::FileDeleteTool,
|
30
|
+
OmniAI::Tools::Disk::FileMoveTool,
|
31
|
+
OmniAI::Tools::Disk::FileReplaceTool,
|
32
|
+
OmniAI::Tools::Disk::FileReadTool,
|
33
|
+
OmniAI::Tools::Disk::FileWriteTool,
|
34
|
+
OmniAI::Tools::Disk::SummaryTool,
|
35
|
+
].map { |klass| klass.new(root:, logger:) }
|
36
|
+
|
37
|
+
puts "Type 'exit' or 'quit' to leave."
|
38
|
+
|
39
|
+
prompt = OmniAI::Chat::Prompt.build do |builder|
|
40
|
+
builder.system "Use tools to manage files and directories as requested."
|
41
|
+
end
|
42
|
+
|
43
|
+
loop do
|
44
|
+
print "# "
|
45
|
+
text = gets.strip
|
46
|
+
break if %w[exit quit].include?(text)
|
47
|
+
|
48
|
+
prompt.user(text)
|
49
|
+
response = client.chat(prompt, stream: $stdout, tools:)
|
50
|
+
prompt.assistant(response.text)
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
## Docker
|
55
|
+
|
56
|
+
Docker tools are focused on running commands through Docker via Compose:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
require "omniai/openai"
|
60
|
+
require "omniai/tools"
|
61
|
+
|
62
|
+
print "Root (e.g. /usr/src/project): "
|
63
|
+
root = gets.strip
|
64
|
+
|
65
|
+
client = OmniAI::OpenAI::Client.new
|
66
|
+
logger = Logger.new($stdout)
|
67
|
+
|
68
|
+
tools = [
|
69
|
+
OmniAI::Tools::Docker::ComposeRunTool,
|
70
|
+
].map { |klass| klass.new(root:, logger:) }
|
71
|
+
|
72
|
+
puts "Type 'exit' or 'quit' to leave."
|
73
|
+
|
74
|
+
prompt = OmniAI::Chat::Prompt.build do |builder|
|
75
|
+
builder.system "Use tools to interact with Docker."
|
76
|
+
end
|
77
|
+
|
78
|
+
loop do
|
79
|
+
print "# "
|
80
|
+
text = gets.strip
|
81
|
+
break if %w[exit quit].include?(text)
|
82
|
+
|
83
|
+
prompt.user(text)
|
84
|
+
response = client.chat(prompt, stream: $stdout, tools:)
|
85
|
+
prompt.assistant(response.text)
|
86
|
+
end
|
87
|
+
```
|
data/bin/setup
CHANGED
@@ -7,9 +7,11 @@ module OmniAI
|
|
7
7
|
# tool = OmniAI::Tools::Disk::FileDeleteTool.new(root: "./project")
|
8
8
|
# tool.execute(path: "./README.md")
|
9
9
|
class FileDeleteTool < BaseTool
|
10
|
-
description "
|
10
|
+
description "Deletes a file."
|
11
11
|
|
12
|
-
parameter :path, :string, description: "a path to the
|
12
|
+
parameter :path, :string, description: "a path to the file (e.g. `./README.md`)"
|
13
|
+
|
14
|
+
required %i[path]
|
13
15
|
|
14
16
|
# @param path [String]
|
15
17
|
#
|
@@ -4,17 +4,19 @@ module OmniAI
|
|
4
4
|
module Tools
|
5
5
|
module Disk
|
6
6
|
# @example
|
7
|
-
# tool = OmniAI::Tools::Disk::
|
7
|
+
# tool = OmniAI::Tools::Disk::FileMoveTool.new(root: "./project")
|
8
8
|
# tool.execute(
|
9
9
|
# old_path: "./README.txt",
|
10
10
|
# new_path: "./README.md",
|
11
11
|
# )
|
12
12
|
class FileMoveTool < BaseTool
|
13
|
-
description "
|
13
|
+
description "Moves a file."
|
14
14
|
|
15
15
|
parameter :old_path, :string, description: "a path (e.g. `./old.rb`)"
|
16
16
|
parameter :new_path, :string, description: "a path (e.g. `./new.rb`)"
|
17
17
|
|
18
|
+
required %i[old_path new_path]
|
19
|
+
|
18
20
|
# @param old_path [String]
|
19
21
|
# @param new_path [String]
|
20
22
|
#
|
@@ -7,10 +7,12 @@ module OmniAI
|
|
7
7
|
# tool = OmniAI::Tools::Disk::FileReadTool.new(root: "./project")
|
8
8
|
# tool.execute(path: "./README.md") # => "..."
|
9
9
|
class FileReadTool < BaseTool
|
10
|
-
description "
|
10
|
+
description "Reads the contents of a file."
|
11
11
|
|
12
12
|
parameter :path, :string, description: "a path (e.g. `./main.rb`)"
|
13
13
|
|
14
|
+
required %i[path]
|
15
|
+
|
14
16
|
# @param path [String]
|
15
17
|
#
|
16
18
|
# @return [String]
|
@@ -11,12 +11,14 @@ module OmniAI
|
|
11
11
|
# path: "README.md"
|
12
12
|
# )
|
13
13
|
class FileReplaceTool < BaseTool
|
14
|
-
description "
|
14
|
+
description "Replaces a specific string in a file (old_text => new_text)."
|
15
15
|
|
16
16
|
parameter :old_text, :string, description: "the old text (e.g. `puts 'ABC'`)"
|
17
17
|
parameter :new_text, :string, description: "the new text (e.g. `puts 'DEF'`)"
|
18
18
|
parameter :path, :string, description: "a path (e.g. `./main.rb`)"
|
19
19
|
|
20
|
+
required %i[old_text new_text path]
|
21
|
+
|
20
22
|
# @param path [String]
|
21
23
|
# @param old_text [String]
|
22
24
|
# @param new_text [String]
|
@@ -7,11 +7,13 @@ module OmniAI
|
|
7
7
|
# tool = OmniAI::Tools::Disk::FileWriteTool.new(root: "./project")
|
8
8
|
# tool.execute(path: "./README.md", text: "Hello World")
|
9
9
|
class FileWriteTool < BaseTool
|
10
|
-
description "
|
10
|
+
description "Writes the contents of a file."
|
11
11
|
|
12
12
|
parameter :path, :string, description: "a path for the file (e.g. `./main.rb`)"
|
13
13
|
parameter :text, :string, description: "the text to write to the file (e.g. `puts 'Hello World'`)"
|
14
14
|
|
15
|
+
required %i[path text]
|
16
|
+
|
15
17
|
# @param path [String]
|
16
18
|
# @param text [String]
|
17
19
|
#
|
@@ -7,7 +7,7 @@ module OmniAI
|
|
7
7
|
# tool = OmniAI::Tools::Disk::SummaryTool.new(root: "./project")
|
8
8
|
# tool.execute
|
9
9
|
class SummaryTool < BaseTool
|
10
|
-
description "
|
10
|
+
description "Summarizes the contents (files and directories) of the project."
|
11
11
|
|
12
12
|
# @return [String]
|
13
13
|
def execute
|
@@ -9,12 +9,12 @@ module OmniAI
|
|
9
9
|
# tool = OmniAI::Tools::Docker::ComposeRunTool.new(root: "./project")
|
10
10
|
# tool.execute(service: "app", command: "rspec" args: ["spec/main_spec.rb"])
|
11
11
|
class ComposeRunTool < BaseTool
|
12
|
-
description "
|
12
|
+
description "Runs a command via Docker with arguments on the project (e.g. `rspec spec/main_spec.rb`)."
|
13
13
|
|
14
|
-
parameter :service, :string, description: "
|
15
|
-
parameter :command, :string, description: "
|
16
|
-
parameter :args, :array, description: "
|
17
|
-
items: OmniAI::Tool::Property.string(description: "
|
14
|
+
parameter :service, :string, description: "The service to run the command on (e.g. `app`)."
|
15
|
+
parameter :command, :string, description: "The command to run (e.g. `rspec`)."
|
16
|
+
parameter :args, :array, description: "The arguments for the command.",
|
17
|
+
items: OmniAI::Tool::Property.string(description: "An argument for the command (e.g. `spec/main_spec.rb`).")
|
18
18
|
|
19
19
|
# @param service [String]
|
20
20
|
# @param command [String]
|
data/lib/omniai/tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniai-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Sylvestre
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
10
|
+
date: 2025-04-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: omniai
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.6.
|
86
|
+
rubygems_version: 3.6.3
|
87
87
|
specification_version: 4
|
88
88
|
summary: A set of tools built for usage with OmniAI.
|
89
89
|
test_files: []
|