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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c992bede26be258d71c430d42cde2bf369f0ca90b3b835998829008612c7e1aa
4
- data.tar.gz: 122564e6d76bab01b3f18e825c75209ca4a6c531957a5f7ed94e8921e40a3d3a
3
+ metadata.gz: 8b15d457541548f43fcc6d1c7cf7724c2e22a6505c0ca82e95681617e70259bd
4
+ data.tar.gz: c5b20938128e993273a0759e6c0e5571a90f67fe59d7b43a36967254dab3bf40
5
5
  SHA512:
6
- metadata.gz: 55e3ee927659469db0c0533c55241e752ebee17869fe290f9f242de28e3503f74ba7e5c69530d886ce8614b7c68e079c1bf912264c717cb61061e3bfc445e63e
7
- data.tar.gz: 8e990faf709f6c720f9ba8f9aab59196e729416f762968f6a02badfe7879b9f24de5ff833b102e99d6aed53a694710f6712b1995e336403c40203dbbff621e1b
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.1)
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.0)
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.2)
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.0)
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.1
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.1'
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.1 && bash"
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.1
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.1.gem
491
+ gem push nano-bots-1.1.0.gem
492
492
  ```
@@ -49,7 +49,7 @@ module NanoBot
49
49
  end
50
50
  end
51
51
 
52
- %i[instruction backdrop directive].each do |key|
52
+ %i[backdrop directive].each do |key|
53
53
  next unless input[:behavior][key]
54
54
 
55
55
  messages.prepend(
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(color.nil? ? message : Rainbow(message).send(color))
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)
@@ -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
- return unless Logic::Helpers::Hash.fetch(@cartridge, %i[behaviors boot instruction])
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
- input = { behavior:, history: [] }
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.write(content)
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
@@ -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.1 && bash"
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'
@@ -9,8 +9,8 @@ interfaces:
9
9
  repl:
10
10
  output:
11
11
  stream: true
12
- suffix: "\n"
13
12
  prefix: "\n"
13
+ suffix: "\n"
14
14
  prompt:
15
15
  - text: '🤖'
16
16
  - text: '> '
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.1',
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.1
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-02 00:00:00.000000000 Z
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