omniai-tools 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 404c95beb54e2092a9a694887ba55a2e8ac8ec736bed56b755cfe34d0906cf9e
4
- data.tar.gz: f07bf709204ea5a472733695e45870bbbf51b5f89a7d817d290e9e926cf4a57d
3
+ metadata.gz: 04d1c28a8b8a92c2cc6c0ada9976d58ee2aed291fe25368356ce9a055b14cc7e
4
+ data.tar.gz: 5afcc660cd72ef9ed7cea14fb6478a3239af14d8e519e3ba2bb89c32ccfaeb97
5
5
  SHA512:
6
- metadata.gz: 206fda9b71017456d3d4f6d2c590849b93bf302c298916fe64fdd9552429357b35c86a01fde359f0ff7e63fc6202429e9bf16e4c4563a61b7ddc065a77c404e8
7
- data.tar.gz: c7a122e9c86e418825285c4503236eb921570980eba9c8586c509243d2bb9ee7d3bb2d0da2187f331c8c53647153c2109b258d44ed52f12b1929e8cf08d8d93e
6
+ metadata.gz: f1331d0fc5ed4b89072e8d793620b7531d240556bca49be4a6a9b16e3368a96df3d8ca7a45c4e50198d97850b50ee13319875d4a8152ea8e7c93676d3eb81653
7
+ data.tar.gz: 39ac4a40cbcafe9876e51c9a7a5f8b63c3d51c9bfc7f63afe6a47e209ed0ee6acbdb8d7c5845e3f9b7fab3ed6dac8eb946eda1a69d900f8a3d897cee67bb3b52
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ gemspec
7
7
  gem "factory_bot"
8
8
  gem "irb"
9
9
  gem "rake"
10
+ gem "redcarpet"
10
11
  gem "rspec"
11
12
  gem "rspec_junit_formatter"
12
13
  gem "rubocop"
data/README.md CHANGED
@@ -5,3 +5,83 @@
5
5
  [![GitHub](https://img.shields.io/badge/github-repo-blue.svg)](https://github.com/ksylvest/omniai-tools)
6
6
  [![Yard](https://img.shields.io/badge/docs-site-blue.svg)](https://omniai-tools.ksylvest.com)
7
7
  [![CircleCI](https://img.shields.io/circleci/build/github/ksylvest/omniai-tools)](https://circleci.com/gh/ksylvest/omniai-tools)
8
+
9
+ `OmniAI::Tools` is a library of pre-built tools to simplify integrating common tasks w/ [OmniAI](https://github.com/ksylvest/omniai).
10
+
11
+ ## Disk
12
+
13
+ Disk tools are focused on creating / updating / 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
+ Disk 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
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -18,7 +18,6 @@ module OmniAI
18
18
 
19
19
  protected
20
20
 
21
- # @param directory [Pathname]
22
21
  # @param path [String]
23
22
  #
24
23
  # @raise [SecurityError]
@@ -11,6 +11,8 @@ module OmniAI
11
11
 
12
12
  parameter :path, :string, description: "a path to the directory (e.g. `./foo/bar`)"
13
13
 
14
+ required %i[path]
15
+
14
16
  # @param path [String]
15
17
  #
16
18
  # @return [String]
@@ -11,6 +11,8 @@ module OmniAI
11
11
 
12
12
  parameter :path, :string, description: "a path to the directory (e.g. `./foo/bar`)"
13
13
 
14
+ required %i[path]
15
+
14
16
  # @param path [String]
15
17
  #
16
18
  # @return [String]
@@ -11,6 +11,8 @@ module OmniAI
11
11
 
12
12
  parameter :path, :string, description: "a path to the file (e.g. `./README.md`)"
13
13
 
14
+ required %i[path]
15
+
14
16
  # @param path [String]
15
17
  #
16
18
  # @return [String]
@@ -11,6 +11,8 @@ module OmniAI
11
11
 
12
12
  parameter :path, :string, description: "a path to the directory (e.g. `./foo/bar`)"
13
13
 
14
+ required %i[path]
15
+
14
16
  # @param path [String]
15
17
  #
16
18
  # @raise [SecurityError]
@@ -15,6 +15,8 @@ module OmniAI
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
  #
@@ -11,6 +11,8 @@ module OmniAI
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]
@@ -17,6 +17,8 @@ module OmniAI
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]
@@ -12,6 +12,8 @@ module OmniAI
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
  #
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Tools
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-22 00:00:00.000000000 Z
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.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: []