nano-bots 1.0.1 → 1.1.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 +7 -7
- data/components/providers/openai.rb +1 -1
- data/components/stream.rb +2 -2
- data/controllers/interfaces/tools.rb +4 -1
- data/controllers/session.rb +17 -4
- data/docker-compose.example.yml +1 -1
- data/nano-bots.gemspec +1 -1
- data/static/cartridges/default.yml +1 -1
- data/static/gem.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b15d457541548f43fcc6d1c7cf7724c2e22a6505c0ca82e95681617e70259bd
|
4
|
+
data.tar.gz: c5b20938128e993273a0759e6c0e5571a90f67fe59d7b43a36967254dab3bf40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2915fddd84a82616a2457bb6ef6d2acb6c7e3ad83beb9fb162033326047b123d43ec3c80764e27b6dbf5b0827a5dc2e3ed9781de3d44d787a188e1724043ab4e
|
7
|
+
data.tar.gz: b9413865e968eddf7f38e506c7ed96760c2734dea25ddcacac504e58a8ed45f0573d8b1a42285fddd5ddacfe0acbf710d9e804af827338bb58e0e1cbc5163bc8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nano-bots (1.0
|
4
|
+
nano-bots (1.1.0)
|
5
5
|
babosa (~> 2.0)
|
6
6
|
concurrent-ruby (~> 1.2, >= 1.2.2)
|
7
7
|
dotenv (~> 2.8, >= 2.8.1)
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
pry (~> 0.14.2)
|
10
10
|
rainbow (~> 3.1, >= 3.1.1)
|
11
11
|
rbnacl (~> 7.1, >= 7.1.1)
|
12
|
-
ruby-openai (~> 6.3)
|
12
|
+
ruby-openai (~> 6.3, >= 6.3.1)
|
13
13
|
sweet-moon (~> 0.0.7)
|
14
14
|
|
15
15
|
GEM
|
@@ -32,7 +32,7 @@ GEM
|
|
32
32
|
multipart-post (~> 2)
|
33
33
|
faraday-net_http (3.0.2)
|
34
34
|
ffi (1.16.3)
|
35
|
-
json (2.7.
|
35
|
+
json (2.7.1)
|
36
36
|
language_server-protocol (3.17.0.3)
|
37
37
|
method_source (1.0.0)
|
38
38
|
multipart-post (2.3.0)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
rainbow (3.1.1)
|
51
51
|
rbnacl (7.1.1)
|
52
52
|
ffi
|
53
|
-
regexp_parser (2.8.
|
53
|
+
regexp_parser (2.8.3)
|
54
54
|
rexml (3.2.6)
|
55
55
|
rspec (3.12.0)
|
56
56
|
rspec-core (~> 3.12.0)
|
@@ -86,7 +86,7 @@ GEM
|
|
86
86
|
rubocop (~> 1.40)
|
87
87
|
rubocop-capybara (~> 2.17)
|
88
88
|
rubocop-factory_bot (~> 2.22)
|
89
|
-
ruby-openai (6.3.
|
89
|
+
ruby-openai (6.3.1)
|
90
90
|
event_stream_parser (>= 0.3.0, < 2.0.0)
|
91
91
|
faraday (>= 1)
|
92
92
|
faraday-multipart (>= 1)
|
data/README.md
CHANGED
@@ -30,13 +30,13 @@ https://user-images.githubusercontent.com/113217272/238141567-c58a240c-7b67-4b3b
|
|
30
30
|
For a system usage:
|
31
31
|
|
32
32
|
```sh
|
33
|
-
gem install nano-bots -v 1.0
|
33
|
+
gem install nano-bots -v 1.1.0
|
34
34
|
```
|
35
35
|
|
36
36
|
To use it in a project, add it to your `Gemfile`:
|
37
37
|
|
38
38
|
```ruby
|
39
|
-
gem 'nano-bots', '~> 1.0
|
39
|
+
gem 'nano-bots', '~> 1.1.0'
|
40
40
|
```
|
41
41
|
|
42
42
|
```sh
|
@@ -86,7 +86,7 @@ Set your provider credentials and choose your desired directory for the cartridg
|
|
86
86
|
services:
|
87
87
|
nano-bots:
|
88
88
|
image: ruby:3.2.2-slim-bookworm
|
89
|
-
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 1.0
|
89
|
+
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 1.1.0 && bash"
|
90
90
|
environment:
|
91
91
|
OPENAI_API_ADDRESS: https://api.openai.com
|
92
92
|
OPENAI_API_KEY: your-access-token
|
@@ -218,7 +218,7 @@ bot.eval('Hello', as: 'eval')
|
|
218
218
|
bot.eval('Hello', as: 'repl')
|
219
219
|
|
220
220
|
# When stream is enabled and available:
|
221
|
-
bot.eval('Hi!') do |content, fragment, finished|
|
221
|
+
bot.eval('Hi!') do |content, fragment, finished, meta|
|
222
222
|
print fragment unless fragment.nil?
|
223
223
|
end
|
224
224
|
|
@@ -235,7 +235,7 @@ bot.boot
|
|
235
235
|
bot.boot(as: 'eval')
|
236
236
|
bot.boot(as: 'repl')
|
237
237
|
|
238
|
-
bot.boot do |content, fragment, finished|
|
238
|
+
bot.boot do |content, fragment, finished, meta|
|
239
239
|
print fragment unless fragment.nil?
|
240
240
|
end
|
241
241
|
```
|
@@ -250,7 +250,7 @@ meta:
|
|
250
250
|
symbol: 🤖
|
251
251
|
name: Nano Bot Name
|
252
252
|
author: Your Name
|
253
|
-
version: 1.0.
|
253
|
+
version: 1.0.0
|
254
254
|
license: CC0-1.0
|
255
255
|
description: A helpful assistant.
|
256
256
|
|
@@ -488,5 +488,5 @@ gem build nano-bots.gemspec
|
|
488
488
|
|
489
489
|
gem signin
|
490
490
|
|
491
|
-
gem push nano-bots-1.0.
|
491
|
+
gem push nano-bots-1.1.0.gem
|
492
492
|
```
|
data/components/stream.rb
CHANGED
@@ -13,9 +13,9 @@ module NanoBot
|
|
13
13
|
@accumulated = "#{@accumulated.force_encoding('UTF-8')}#{args.first.force_encoding('UTF-8')}"
|
14
14
|
end
|
15
15
|
|
16
|
-
@callback.call(@accumulated, args.first, false)
|
16
|
+
@callback.call(@accumulated, args.first, false, args[1])
|
17
17
|
end
|
18
|
-
super
|
18
|
+
super(args.first)
|
19
19
|
end
|
20
20
|
|
21
21
|
def callback=(block)
|
@@ -72,7 +72,10 @@ module NanoBot
|
|
72
72
|
|
73
73
|
message = "#{adapter[:prefix]}#{message}#{adapter[:suffix]}"
|
74
74
|
|
75
|
-
session.print(
|
75
|
+
session.print(
|
76
|
+
color.nil? ? message : Rainbow(message).send(color),
|
77
|
+
{ tool: { action: feedback[:action].to_s } }
|
78
|
+
)
|
76
79
|
end
|
77
80
|
|
78
81
|
def self.adapter(cartridge, mode, feedback)
|
data/controllers/session.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative '../logic/cartridge/streaming'
|
|
11
11
|
require_relative '../logic/cartridge/interaction'
|
12
12
|
require_relative '../logic/cartridge/fetch'
|
13
13
|
require_relative 'interfaces/tools'
|
14
|
+
require_relative '../components/stream'
|
14
15
|
require_relative '../components/storage'
|
15
16
|
require_relative '../components/adapter'
|
16
17
|
require_relative '../components/crypto'
|
@@ -56,11 +57,19 @@ module NanoBot
|
|
56
57
|
end
|
57
58
|
|
58
59
|
def boot(mode:)
|
59
|
-
|
60
|
+
instruction = Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot instruction])
|
61
|
+
return unless instruction
|
60
62
|
|
61
63
|
behavior = Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot]) || {}
|
62
64
|
|
63
|
-
|
65
|
+
@state[:history] << {
|
66
|
+
who: 'user',
|
67
|
+
mode: mode.to_s,
|
68
|
+
input: instruction,
|
69
|
+
message: instruction
|
70
|
+
}
|
71
|
+
|
72
|
+
input = { behavior:, history: @state[:history] }
|
64
73
|
|
65
74
|
process(input, mode:)
|
66
75
|
end
|
@@ -182,8 +191,12 @@ module NanoBot
|
|
182
191
|
@stream.flush
|
183
192
|
end
|
184
193
|
|
185
|
-
def print(content)
|
186
|
-
@stream.
|
194
|
+
def print(content, meta = nil)
|
195
|
+
if @stream.is_a?(NanoBot::Components::Stream)
|
196
|
+
@stream.write(content, meta)
|
197
|
+
else
|
198
|
+
@stream.write(content)
|
199
|
+
end
|
187
200
|
end
|
188
201
|
end
|
189
202
|
end
|
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 1.0
|
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 1.1.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
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
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'
|
41
|
-
spec.add_dependency 'ruby-openai', '~> 6.3'
|
41
|
+
spec.add_dependency 'ruby-openai', '~> 6.3', '>= 6.3.1'
|
42
42
|
spec.add_dependency 'sweet-moon', '~> 0.0.7'
|
43
43
|
|
44
44
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
data/static/gem.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module NanoBot
|
4
4
|
GEM = {
|
5
5
|
name: 'nano-bots',
|
6
|
-
version: '1.0
|
6
|
+
version: '1.1.0',
|
7
7
|
author: 'icebaker',
|
8
8
|
summary: 'Ruby Implementation of Nano Bots: small, AI-powered bots',
|
9
9
|
description: 'Ruby Implementation of Nano Bots: small, AI-powered bots easily shared as a single file, designed to support multiple providers such as Vicuna, OpenAI ChatGPT, Google PaLM, Alpaca, and LLaMA.',
|
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: 1.0
|
4
|
+
version: 1.1.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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: babosa
|
@@ -145,6 +145,9 @@ dependencies:
|
|
145
145
|
- - "~>"
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '6.3'
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 6.3.1
|
148
151
|
type: :runtime
|
149
152
|
prerelease: false
|
150
153
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -152,6 +155,9 @@ dependencies:
|
|
152
155
|
- - "~>"
|
153
156
|
- !ruby/object:Gem::Version
|
154
157
|
version: '6.3'
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 6.3.1
|
155
161
|
- !ruby/object:Gem::Dependency
|
156
162
|
name: sweet-moon
|
157
163
|
requirement: !ruby/object:Gem::Requirement
|