nano-bots 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +110 -14
- data/components/providers/google.rb +31 -55
- data/controllers/interfaces/cli.rb +4 -0
- data/controllers/interfaces/repl.rb +53 -8
- data/docker-compose.example.yml +1 -1
- data/nano-bots.gemspec +1 -1
- data/ports/dsl/nano-bots.rb +4 -0
- data/static/gem.rb +2 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d87686427ed075d44e4c4b21e41de70047adf4ce56eb73c50f77fb695e63a562
|
4
|
+
data.tar.gz: 8bc004c9dfe2a004fa8e6f7bbcc946e461c54daf7b9b58b7e416c9f3c8ebe734
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ce8acc93fbd5eedaaaae2dc271ab64998fad38e3e2f5f40e9a0a51e4cbed01e25787ff77ebf02663e88786c01ede5a70127052aeb2fcf6dfcb58c22bb004620
|
7
|
+
data.tar.gz: c46e9cfcbbb2d871191153c48760cd4625216b6dbbff598c2921635df7af02fdca8923b806fc9fdbe35ee86ab6c6217a63b287b3bf65c42d5281aff9c91e8878
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nano-bots (2.
|
4
|
+
nano-bots (2.2.0)
|
5
5
|
babosa (~> 2.0)
|
6
6
|
concurrent-ruby (~> 1.2, >= 1.2.2)
|
7
7
|
dotenv (~> 2.8, >= 2.8.1)
|
8
|
-
gemini-ai (~> 2.
|
8
|
+
gemini-ai (~> 2.2)
|
9
9
|
pry (~> 0.14.2)
|
10
10
|
rainbow (~> 3.1, >= 3.1.1)
|
11
11
|
rbnacl (~> 7.1, >= 7.1.1)
|
@@ -34,7 +34,7 @@ GEM
|
|
34
34
|
multipart-post (~> 2)
|
35
35
|
faraday-net_http (3.0.2)
|
36
36
|
ffi (1.16.3)
|
37
|
-
gemini-ai (2.
|
37
|
+
gemini-ai (2.2.0)
|
38
38
|
event_stream_parser (~> 1.0)
|
39
39
|
faraday (~> 2.7, >= 2.7.12)
|
40
40
|
googleauth (~> 1.9, >= 1.9.1)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
multi_json (1.15.0)
|
55
55
|
multipart-post (2.3.0)
|
56
56
|
os (1.1.4)
|
57
|
-
parallel (1.
|
57
|
+
parallel (1.24.0)
|
58
58
|
parser (3.2.2.4)
|
59
59
|
ast (~> 2.4.1)
|
60
60
|
racc
|
@@ -131,4 +131,4 @@ DEPENDENCIES
|
|
131
131
|
rubocop-rspec (~> 2.25)
|
132
132
|
|
133
133
|
BUNDLED WITH
|
134
|
-
2.4.
|
134
|
+
2.4.22
|
data/README.md
CHANGED
@@ -36,13 +36,13 @@ https://user-images.githubusercontent.com/113217272/238141567-c58a240c-7b67-4b3b
|
|
36
36
|
For a system usage:
|
37
37
|
|
38
38
|
```sh
|
39
|
-
gem install nano-bots -v 2.
|
39
|
+
gem install nano-bots -v 2.2.0
|
40
40
|
```
|
41
41
|
|
42
42
|
To use it in a project, add it to your `Gemfile`:
|
43
43
|
|
44
44
|
```ruby
|
45
|
-
gem 'nano-bots', '~> 2.
|
45
|
+
gem 'nano-bots', '~> 2.2.0'
|
46
46
|
```
|
47
47
|
|
48
48
|
```sh
|
@@ -105,11 +105,10 @@ NANO_BOTS_END_USER=your-user
|
|
105
105
|
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
106
106
|
```
|
107
107
|
|
108
|
-
#### Option 2: Service Account (Vertex AI API)
|
108
|
+
#### Option 2: Service Account Credentials File (Vertex AI API)
|
109
109
|
|
110
110
|
```sh
|
111
111
|
export GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
|
112
|
-
export GOOGLE_PROJECT_ID=your-project-id
|
113
112
|
export GOOGLE_REGION=us-east4
|
114
113
|
|
115
114
|
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
@@ -123,7 +122,6 @@ Alternatively, if your current directory has a `.env` file with the environment
|
|
123
122
|
|
124
123
|
```sh
|
125
124
|
GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
|
126
|
-
GOOGLE_PROJECT_ID=your-project-id
|
127
125
|
GOOGLE_REGION=us-east4
|
128
126
|
|
129
127
|
NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
@@ -133,12 +131,50 @@ NANO_BOTS_END_USER=your-user
|
|
133
131
|
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
134
132
|
```
|
135
133
|
|
134
|
+
#### Option 3: Application Default Credentials (Vertex AI API)
|
135
|
+
|
136
|
+
```sh
|
137
|
+
export GOOGLE_REGION=us-east4
|
138
|
+
|
139
|
+
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
140
|
+
export NANO_BOTS_END_USER=your-user
|
141
|
+
|
142
|
+
# export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
143
|
+
# export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
144
|
+
```
|
145
|
+
|
146
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
147
|
+
|
148
|
+
```sh
|
149
|
+
GOOGLE_REGION=us-east4
|
150
|
+
|
151
|
+
NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
152
|
+
NANO_BOTS_END_USER=your-user
|
153
|
+
|
154
|
+
# NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
155
|
+
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
156
|
+
```
|
157
|
+
|
158
|
+
#### Custom Project ID
|
159
|
+
|
160
|
+
If you need to manually set a Google Project ID:
|
161
|
+
|
162
|
+
```sh
|
163
|
+
export GOOGLE_PROJECT_ID=your-project-id
|
164
|
+
```
|
165
|
+
|
166
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
167
|
+
|
168
|
+
```sh
|
169
|
+
GOOGLE_PROJECT_ID=your-project-id
|
170
|
+
```
|
171
|
+
|
136
172
|
## Docker
|
137
173
|
|
138
174
|
Clone the repository and copy the Docker Compose template:
|
139
175
|
|
140
176
|
```
|
141
|
-
git clone
|
177
|
+
git clone https://github.com/icebaker/ruby-nano-bots.git
|
142
178
|
cd ruby-nano-bots
|
143
179
|
cp docker-compose.example.yml docker-compose.yml
|
144
180
|
```
|
@@ -152,7 +188,7 @@ Set your provider credentials and choose your desired directory for the cartridg
|
|
152
188
|
services:
|
153
189
|
nano-bots:
|
154
190
|
image: ruby:3.2.2-slim-bookworm
|
155
|
-
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.
|
191
|
+
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.2.0 && bash"
|
156
192
|
environment:
|
157
193
|
OPENAI_API_ADDRESS: https://api.openai.com
|
158
194
|
OPENAI_API_KEY: your-access-token
|
@@ -172,7 +208,7 @@ services:
|
|
172
208
|
services:
|
173
209
|
nano-bots:
|
174
210
|
image: ruby:3.2.2-slim-bookworm
|
175
|
-
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.
|
211
|
+
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.2.0 && bash"
|
176
212
|
environment:
|
177
213
|
GOOGLE_API_KEY: your-api-key
|
178
214
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -182,17 +218,16 @@ services:
|
|
182
218
|
- ./your-state-path:/root/.local/state/nano-bots
|
183
219
|
```
|
184
220
|
|
185
|
-
#### Option 2: Service Account (Vertex AI API)
|
221
|
+
#### Option 2: Service Account Credentials File (Vertex AI API)
|
186
222
|
|
187
223
|
```yaml
|
188
224
|
---
|
189
225
|
services:
|
190
226
|
nano-bots:
|
191
227
|
image: ruby:3.2.2-slim-bookworm
|
192
|
-
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.
|
228
|
+
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.2.0 && bash"
|
193
229
|
environment:
|
194
230
|
GOOGLE_CREDENTIALS_FILE_PATH: /root/.config/google-credentials.json
|
195
|
-
GOOGLE_PROJECT_ID: your-project-id
|
196
231
|
GOOGLE_REGION: us-east4
|
197
232
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
198
233
|
NANO_BOTS_END_USER: your-user
|
@@ -202,6 +237,31 @@ services:
|
|
202
237
|
- ./your-state-path:/root/.local/state/nano-bots
|
203
238
|
```
|
204
239
|
|
240
|
+
#### Option 3: Application Default Credentials (Vertex AI API)
|
241
|
+
|
242
|
+
```yaml
|
243
|
+
---
|
244
|
+
services:
|
245
|
+
nano-bots:
|
246
|
+
image: ruby:3.2.2-slim-bookworm
|
247
|
+
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.2.0 && bash"
|
248
|
+
environment:
|
249
|
+
GOOGLE_REGION: us-east4
|
250
|
+
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
251
|
+
NANO_BOTS_END_USER: your-user
|
252
|
+
volumes:
|
253
|
+
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
|
254
|
+
- ./your-state-path:/root/.local/state/nano-bots
|
255
|
+
```
|
256
|
+
|
257
|
+
#### Custom Project ID
|
258
|
+
If you need to manually set a Google Project ID:
|
259
|
+
|
260
|
+
```yaml
|
261
|
+
environment:
|
262
|
+
GOOGLE_PROJECT_ID=your-project-id
|
263
|
+
```
|
264
|
+
|
205
265
|
### Container
|
206
266
|
|
207
267
|
Enter the container:
|
@@ -416,7 +476,7 @@ provider:
|
|
416
476
|
model: gemini-pro
|
417
477
|
```
|
418
478
|
|
419
|
-
#### Option 2: Service Account (Vertex AI API)
|
479
|
+
#### Option 2: Service Account Credentials File (Vertex AI API)
|
420
480
|
|
421
481
|
```yaml
|
422
482
|
---
|
@@ -437,12 +497,48 @@ provider:
|
|
437
497
|
credentials:
|
438
498
|
service: vertex-ai-api
|
439
499
|
file-path: ENV/GOOGLE_CREDENTIALS_FILE_PATH
|
440
|
-
project-id: ENV/GOOGLE_PROJECT_ID
|
441
500
|
region: ENV/GOOGLE_REGION
|
442
501
|
options:
|
443
502
|
model: gemini-pro
|
444
503
|
```
|
445
504
|
|
505
|
+
#### Option 3: Application Default Credentials (Vertex AI API)
|
506
|
+
|
507
|
+
```yaml
|
508
|
+
---
|
509
|
+
meta:
|
510
|
+
symbol: 🤖
|
511
|
+
name: Nano Bot Name
|
512
|
+
author: Your Name
|
513
|
+
version: 1.0.0
|
514
|
+
license: CC0-1.0
|
515
|
+
description: A helpful assistant.
|
516
|
+
|
517
|
+
behaviors:
|
518
|
+
interaction:
|
519
|
+
directive: You are a helpful assistant.
|
520
|
+
|
521
|
+
provider:
|
522
|
+
id: google
|
523
|
+
credentials:
|
524
|
+
service: vertex-ai-api
|
525
|
+
region: ENV/GOOGLE_REGION
|
526
|
+
options:
|
527
|
+
model: gemini-pro
|
528
|
+
```
|
529
|
+
|
530
|
+
#### Custom Project ID
|
531
|
+
|
532
|
+
If you need to manually set a Google Project ID:
|
533
|
+
|
534
|
+
```yaml
|
535
|
+
---
|
536
|
+
provider:
|
537
|
+
id: google
|
538
|
+
credentials:
|
539
|
+
project-id: ENV/GOOGLE_PROJECT_ID
|
540
|
+
```
|
541
|
+
|
446
542
|
### Tools (Functions)
|
447
543
|
|
448
544
|
Nano Bots can also be powered by _Tools_ (Functions):
|
@@ -649,5 +745,5 @@ gem build nano-bots.gemspec
|
|
649
745
|
|
650
746
|
gem signin
|
651
747
|
|
652
|
-
gem push nano-bots-2.
|
748
|
+
gem push nano-bots-2.2.0.gem
|
653
749
|
```
|
@@ -26,25 +26,9 @@ module NanoBot
|
|
26
26
|
def initialize(options, settings, credentials, _environment)
|
27
27
|
@settings = settings
|
28
28
|
|
29
|
-
gemini_credentials = if credentials[:'api-key']
|
30
|
-
{
|
31
|
-
service: credentials[:service],
|
32
|
-
api_key: credentials[:'api-key'],
|
33
|
-
project_id: credentials[:'project-id'],
|
34
|
-
region: credentials[:region]
|
35
|
-
}
|
36
|
-
else
|
37
|
-
{
|
38
|
-
service: credentials[:service],
|
39
|
-
file_path: credentials[:'file-path'],
|
40
|
-
project_id: credentials[:'project-id'],
|
41
|
-
region: credentials[:region]
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
29
|
@client = Gemini.new(
|
46
|
-
credentials:
|
47
|
-
options: {
|
30
|
+
credentials: credentials.transform_keys { |key| key.to_s.gsub('-', '_').to_sym },
|
31
|
+
options: options.transform_keys { |key| key.to_s.gsub('-', '_').to_sym }
|
48
32
|
)
|
49
33
|
end
|
50
34
|
|
@@ -70,6 +54,7 @@ module NanoBot
|
|
70
54
|
end
|
71
55
|
end
|
72
56
|
|
57
|
+
# TODO: Does Gemini have system messages?
|
73
58
|
%i[backdrop directive].each do |key|
|
74
59
|
next unless input[:behavior][key]
|
75
60
|
|
@@ -79,7 +64,6 @@ module NanoBot
|
|
79
64
|
_meta: { at: Time.now } }
|
80
65
|
)
|
81
66
|
|
82
|
-
# TODO: Does Gemini have system messages?
|
83
67
|
messages.prepend(
|
84
68
|
{ role: 'user',
|
85
69
|
parts: { text: input[:behavior][key] },
|
@@ -140,49 +124,41 @@ module NanoBot
|
|
140
124
|
end
|
141
125
|
|
142
126
|
if event.dig('candidates', 0, 'finishReason')
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
needs_another_round: true,
|
147
|
-
interaction: { who: 'AI', message: nil, meta: { tool_calls: tools } } }
|
148
|
-
)
|
149
|
-
Tools.apply(
|
150
|
-
cartridge, input[:tools], tools, feedback, Logic::Google::Tools
|
151
|
-
).each do |interaction|
|
152
|
-
feedback.call({ should_be_stored: true, needs_another_round: true, interaction: })
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
feedback.call(
|
157
|
-
{ should_be_stored: !(content.nil? || content == ''),
|
158
|
-
interaction: content.nil? || content == '' ? nil : { who: 'AI', message: content },
|
159
|
-
finished: true }
|
160
|
-
)
|
127
|
+
# TODO: This does not have the same behavior as OpenAI, so you should
|
128
|
+
# not use it as a reference for the end of the streaming.
|
129
|
+
# Is this a bug from the Google Gemini REST API or expected behavior?
|
161
130
|
end
|
162
131
|
end
|
163
132
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
)
|
169
|
-
rescue StandardError => e
|
170
|
-
raise e.class, e.response[:body] if e.response && e.response[:body]
|
133
|
+
@client.stream_generate_content(
|
134
|
+
Logic::Google::Tokens.apply_policies!(cartridge, payload),
|
135
|
+
stream: true, &stream_call_back
|
136
|
+
)
|
171
137
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
Logic::Google::Tokens.apply_policies!(cartridge, payload),
|
178
|
-
stream: false
|
138
|
+
if tools&.size&.positive?
|
139
|
+
feedback.call(
|
140
|
+
{ should_be_stored: true,
|
141
|
+
needs_another_round: true,
|
142
|
+
interaction: { who: 'AI', message: nil, meta: { tool_calls: tools } } }
|
179
143
|
)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
144
|
+
Tools.apply(
|
145
|
+
cartridge, input[:tools], tools, feedback, Logic::Google::Tools
|
146
|
+
).each do |interaction|
|
147
|
+
feedback.call({ should_be_stored: true, needs_another_round: true, interaction: })
|
148
|
+
end
|
184
149
|
end
|
185
150
|
|
151
|
+
feedback.call(
|
152
|
+
{ should_be_stored: !(content.nil? || content == ''),
|
153
|
+
interaction: content.nil? || content == '' ? nil : { who: 'AI', message: content },
|
154
|
+
finished: true }
|
155
|
+
)
|
156
|
+
else
|
157
|
+
result = @client.stream_generate_content(
|
158
|
+
Logic::Google::Tokens.apply_policies!(cartridge, payload),
|
159
|
+
stream: false
|
160
|
+
)
|
161
|
+
|
186
162
|
tools = result.dig(0, 'candidates', 0, 'content', 'parts').filter do |part|
|
187
163
|
part.key?('functionCall')
|
188
164
|
end
|
@@ -12,6 +12,9 @@ module NanoBot
|
|
12
12
|
when 'version'
|
13
13
|
puts NanoBot::GEM[:version]
|
14
14
|
exit
|
15
|
+
when 'specification'
|
16
|
+
puts NanoBot::GEM[:specification]
|
17
|
+
exit
|
15
18
|
when 'security'
|
16
19
|
result = NanoBot.security.check
|
17
20
|
|
@@ -57,6 +60,7 @@ module NanoBot
|
|
57
60
|
puts ' nb cartridge.yml STATE-KEY state'
|
58
61
|
puts ''
|
59
62
|
puts ' nb security'
|
63
|
+
puts ' nb specification'
|
60
64
|
puts ' nb version'
|
61
65
|
puts ' nb help'
|
62
66
|
puts ''
|
@@ -10,6 +10,21 @@ module NanoBot
|
|
10
10
|
module Controllers
|
11
11
|
module Interfaces
|
12
12
|
module REPL
|
13
|
+
COMMANDS_TO_BE_REMOVED = [
|
14
|
+
'help', 'cd', 'find-method', 'ls', 'pry-backtrace', 'raise-up', 'reset', 'watch',
|
15
|
+
'whereami', 'wtf?', '!', 'amend-line', 'edit', 'hist', 'show-input', 'ri', 'show-doc',
|
16
|
+
'show-source', 'stat', 'import-set', 'play', '!!!', '!!@', '$', '?', '@', 'file-mode',
|
17
|
+
'history', 'quit', 'quit-program', 'reload-method', 'show-method', 'cat',
|
18
|
+
'change-inspector', 'change-prompt', 'clear-screen', 'fix-indent', 'list-inspectors',
|
19
|
+
'save-file', 'shell-mode', 'pry-version', 'reload-code', 'toggle-color', '!pry',
|
20
|
+
'disable-pry', 'jump-to', 'nesting', 'switch-to',
|
21
|
+
'pry-theme'
|
22
|
+
].freeze
|
23
|
+
|
24
|
+
COMMANDS_TO_KEEP = [
|
25
|
+
'/whereami[!?]+/', '.<shell command>', 'exit', 'exit-all', 'exit-program'
|
26
|
+
].freeze
|
27
|
+
|
13
28
|
def self.boot(cartridge, session, prefix = nil, suffix = nil, as: 'repl')
|
14
29
|
return unless Logic::Helpers::Hash.fetch(cartridge, %i[behaviors boot instruction])
|
15
30
|
|
@@ -31,13 +46,7 @@ module NanoBot
|
|
31
46
|
|
32
47
|
prompt = self.prompt(cartridge)
|
33
48
|
|
34
|
-
|
35
|
-
'REPL',
|
36
|
-
'REPL Prompt',
|
37
|
-
[proc { prompt }, proc { 'MISSING INPUT' }]
|
38
|
-
)
|
39
|
-
|
40
|
-
Pry.commands.block_command(/(.*)/, 'handler') do |line|
|
49
|
+
handler = proc do |line|
|
41
50
|
session.print(prefix) unless prefix.nil?
|
42
51
|
session.evaluate_and_print(line, mode: 'repl')
|
43
52
|
session.print(suffix) unless suffix.nil?
|
@@ -45,7 +54,43 @@ module NanoBot
|
|
45
54
|
session.flush
|
46
55
|
end
|
47
56
|
|
48
|
-
Pry.
|
57
|
+
pry_prompt = Pry::Prompt.new(
|
58
|
+
'REPL',
|
59
|
+
'REPL Prompt',
|
60
|
+
[proc { prompt }, proc { 'MISSING INPUT' }]
|
61
|
+
)
|
62
|
+
|
63
|
+
pry_instance = Pry.new({ prompt: pry_prompt })
|
64
|
+
|
65
|
+
pry_instance.config.correct_indent = false
|
66
|
+
|
67
|
+
pry_instance.config.completer = Struct.new(:initialize, :call) do
|
68
|
+
def initialize(...); end
|
69
|
+
def call(...); end
|
70
|
+
end
|
71
|
+
|
72
|
+
first_whereami = true
|
73
|
+
|
74
|
+
pry_instance.config.commands.block_command(/whereami --quiet(.*)/, '/whereami[!?]+/') do |line|
|
75
|
+
unless first_whereami
|
76
|
+
handler.call(line.nil? ? 'whereami --quiet' : "whereami --quiet#{line}")
|
77
|
+
end
|
78
|
+
first_whereami = false
|
79
|
+
end
|
80
|
+
|
81
|
+
pry_instance.config.commands.block_command(/\.(.*)/, '.<shell command>') do |line|
|
82
|
+
handler.call(line.nil? ? '.' : ".#{line}")
|
83
|
+
end
|
84
|
+
|
85
|
+
COMMANDS_TO_BE_REMOVED.each do |command|
|
86
|
+
pry_instance.config.commands.block_command(command, 'handler') do |line|
|
87
|
+
handler.call(line.nil? ? command : "#{command} #{line}")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
pry_instance.commands.block_command(/(.*)/, 'handler', &handler)
|
92
|
+
|
93
|
+
Pry::REPL.new(pry_instance).start
|
49
94
|
end
|
50
95
|
|
51
96
|
def self.prompt(cartridge)
|
data/docker-compose.example.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
services:
|
3
3
|
nano-bots:
|
4
4
|
image: ruby:3.2.2-slim-bookworm
|
5
|
-
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.
|
5
|
+
command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 2.2.0 && bash"
|
6
6
|
environment:
|
7
7
|
OPENAI_API_ADDRESS: https://api.openai.com
|
8
8
|
OPENAI_API_KEY: your-access-token
|
data/nano-bots.gemspec
CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency 'babosa', '~> 2.0'
|
35
35
|
spec.add_dependency 'concurrent-ruby', '~> 1.2', '>= 1.2.2'
|
36
36
|
spec.add_dependency 'dotenv', '~> 2.8', '>= 2.8.1'
|
37
|
-
spec.add_dependency 'gemini-ai', '~> 2.
|
37
|
+
spec.add_dependency 'gemini-ai', '~> 2.2'
|
38
38
|
spec.add_dependency 'pry', '~> 0.14.2'
|
39
39
|
spec.add_dependency 'rainbow', '~> 3.1', '>= 3.1.1'
|
40
40
|
spec.add_dependency 'rbnacl', '~> 7.1', '>= 7.1.1'
|
data/ports/dsl/nano-bots.rb
CHANGED
data/static/gem.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
module NanoBot
|
4
4
|
GEM = {
|
5
5
|
name: 'nano-bots',
|
6
|
-
version: '2.
|
6
|
+
version: '2.2.0',
|
7
|
+
specification: '2.0.1',
|
7
8
|
author: 'icebaker',
|
8
9
|
summary: 'Ruby Implementation of Nano Bots: small, AI-powered bots for OpenAI ChatGPT and Google Gemini.',
|
9
10
|
description: 'Ruby Implementation of Nano Bots: small, AI-powered bots that can be easily shared as a single file, designed to support multiple providers such as OpenAI ChatGPT and Google Gemini, with support for calling Tools (Functions).',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nano-bots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icebaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: babosa
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '2.
|
73
|
+
version: '2.2'
|
74
74
|
type: :runtime
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '2.
|
80
|
+
version: '2.2'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: pry
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|