nano-bots 3.1.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/Gemfile.lock +26 -35
- data/README.md +21 -21
- data/components/providers/google.rb +17 -9
- data/components/storage.rb +2 -12
- data/controllers/session.rb +12 -2
- data/docker-compose.example.yml +2 -2
- data/logic/cartridge/parser.rb +1 -1
- data/nano-bots.gemspec +4 -4
- data/static/fennel/fennel.lua +863 -807
- data/static/gem.rb +1 -1
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaec6b825711abf0cc489a12d158c8558c51f886772bde35ba606baa23c32a0b
|
4
|
+
data.tar.gz: fe8fbb0a863c0f5a4bbe72a83daaa4b6fea807b3816fbaf3daffbb7fbc902a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13fe49fd1bbab45f622a7b77d05de9308aa1ac90d7bf1ba9dce03280ef6bd995624106616706a68defb8580c7f8de9d2a79e140f8974b0c3f493d0c6042e420f
|
7
|
+
data.tar.gz: 673e795b635e5ec5a3b48dffee25ebdbf509bacd55de906aa180fc65f9342ab7820168c375257bc4351f23ec8989463e5c70de96ba20f4f6962aef439e6a142b
|
data/Gemfile
CHANGED
@@ -7,6 +7,6 @@ gemspec
|
|
7
7
|
group :test, :development do
|
8
8
|
gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
|
9
9
|
gem 'rspec', '~> 3.13'
|
10
|
-
gem 'rubocop', '~> 1.
|
11
|
-
gem 'rubocop-rspec', '~>
|
10
|
+
gem 'rubocop', '~> 1.64', '>= 1.64.1'
|
11
|
+
gem 'rubocop-rspec', '~> 3.0', '>= 3.0.1'
|
12
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nano-bots (3.
|
4
|
+
nano-bots (3.3.0)
|
5
5
|
babosa (~> 2.0)
|
6
6
|
cohere-ai (~> 1.1)
|
7
|
-
concurrent-ruby (~> 1.
|
7
|
+
concurrent-ruby (~> 1.3, >= 1.3.3)
|
8
8
|
dotenv (~> 3.1, >= 3.1.2)
|
9
|
-
faraday (~> 2.9)
|
9
|
+
faraday (~> 2.9, >= 2.9.2)
|
10
10
|
faraday-typhoeus (~> 1.1)
|
11
11
|
gemini-ai (~> 4.0)
|
12
12
|
maritaca-ai (~> 1.2)
|
@@ -16,15 +16,15 @@ PATH
|
|
16
16
|
rainbow (~> 3.1, >= 3.1.1)
|
17
17
|
rbnacl (~> 7.1, >= 7.1.1)
|
18
18
|
redcarpet (~> 3.6)
|
19
|
-
ruby-openai (~> 7.
|
20
|
-
sweet-moon (~>
|
19
|
+
ruby-openai (~> 7.1)
|
20
|
+
sweet-moon (~> 1.0)
|
21
21
|
typhoeus (~> 1.4, >= 1.4.1)
|
22
22
|
|
23
23
|
GEM
|
24
24
|
remote: https://rubygems.org/
|
25
25
|
specs:
|
26
|
-
addressable (2.8.
|
27
|
-
public_suffix (>= 2.0.2, <
|
26
|
+
addressable (2.8.7)
|
27
|
+
public_suffix (>= 2.0.2, < 7.0)
|
28
28
|
ast (2.4.2)
|
29
29
|
babosa (2.0.0)
|
30
30
|
base64 (0.2.0)
|
@@ -33,13 +33,13 @@ GEM
|
|
33
33
|
cohere-ai (1.1.0)
|
34
34
|
faraday (~> 2.9)
|
35
35
|
faraday-typhoeus (~> 1.1)
|
36
|
-
concurrent-ruby (1.
|
36
|
+
concurrent-ruby (1.3.3)
|
37
37
|
diff-lcs (1.5.1)
|
38
38
|
dotenv (3.1.2)
|
39
39
|
ethon (0.16.0)
|
40
40
|
ffi (>= 1.15.0)
|
41
41
|
event_stream_parser (1.0.0)
|
42
|
-
faraday (2.9.
|
42
|
+
faraday (2.9.2)
|
43
43
|
faraday-net_http (>= 2.0, < 3.2)
|
44
44
|
faraday-multipart (1.0.4)
|
45
45
|
multipart-post (~> 2)
|
@@ -48,7 +48,7 @@ GEM
|
|
48
48
|
faraday-typhoeus (1.1.0)
|
49
49
|
faraday (~> 2.0)
|
50
50
|
typhoeus (~> 1.4)
|
51
|
-
ffi (1.
|
51
|
+
ffi (1.17.0)
|
52
52
|
gemini-ai (4.0.0)
|
53
53
|
event_stream_parser (~> 1.0)
|
54
54
|
faraday (~> 2.9)
|
@@ -65,7 +65,7 @@ GEM
|
|
65
65
|
os (>= 0.9, < 2.0)
|
66
66
|
signet (>= 0.16, < 2.a)
|
67
67
|
json (2.7.2)
|
68
|
-
jwt (2.8.
|
68
|
+
jwt (2.8.2)
|
69
69
|
base64
|
70
70
|
language_server-protocol (3.17.0.3)
|
71
71
|
maritaca-ai (1.2.0)
|
@@ -85,8 +85,8 @@ GEM
|
|
85
85
|
faraday (~> 2.9)
|
86
86
|
faraday-typhoeus (~> 1.1)
|
87
87
|
os (1.1.4)
|
88
|
-
parallel (1.
|
89
|
-
parser (3.3.
|
88
|
+
parallel (1.25.1)
|
89
|
+
parser (3.3.3.0)
|
90
90
|
ast (~> 2.4.1)
|
91
91
|
racc
|
92
92
|
pry (0.14.2)
|
@@ -95,29 +95,29 @@ GEM
|
|
95
95
|
pry-byebug (3.10.1)
|
96
96
|
byebug (~> 11.0)
|
97
97
|
pry (>= 0.13, < 0.15)
|
98
|
-
public_suffix (
|
99
|
-
racc (1.
|
98
|
+
public_suffix (6.0.0)
|
99
|
+
racc (1.8.0)
|
100
100
|
rainbow (3.1.1)
|
101
101
|
rbnacl (7.1.1)
|
102
102
|
ffi
|
103
103
|
redcarpet (3.6.0)
|
104
104
|
regexp_parser (2.9.2)
|
105
|
-
rexml (3.
|
106
|
-
strscan
|
105
|
+
rexml (3.3.0)
|
106
|
+
strscan
|
107
107
|
rspec (3.13.0)
|
108
108
|
rspec-core (~> 3.13.0)
|
109
109
|
rspec-expectations (~> 3.13.0)
|
110
110
|
rspec-mocks (~> 3.13.0)
|
111
111
|
rspec-core (3.13.0)
|
112
112
|
rspec-support (~> 3.13.0)
|
113
|
-
rspec-expectations (3.13.
|
113
|
+
rspec-expectations (3.13.1)
|
114
114
|
diff-lcs (>= 1.2.0, < 2.0)
|
115
115
|
rspec-support (~> 3.13.0)
|
116
116
|
rspec-mocks (3.13.1)
|
117
117
|
diff-lcs (>= 1.2.0, < 2.0)
|
118
118
|
rspec-support (~> 3.13.0)
|
119
119
|
rspec-support (3.13.1)
|
120
|
-
rubocop (1.
|
120
|
+
rubocop (1.64.1)
|
121
121
|
json (~> 2.3)
|
122
122
|
language_server-protocol (>= 3.17.0)
|
123
123
|
parallel (~> 1.10)
|
@@ -130,18 +130,9 @@ GEM
|
|
130
130
|
unicode-display_width (>= 2.4.0, < 3.0)
|
131
131
|
rubocop-ast (1.31.3)
|
132
132
|
parser (>= 3.3.1.0)
|
133
|
-
rubocop-
|
134
|
-
rubocop (~> 1.
|
135
|
-
|
136
|
-
rubocop (~> 1.41)
|
137
|
-
rubocop-rspec (2.29.2)
|
138
|
-
rubocop (~> 1.40)
|
139
|
-
rubocop-capybara (~> 2.17)
|
140
|
-
rubocop-factory_bot (~> 2.22)
|
141
|
-
rubocop-rspec_rails (~> 2.28)
|
142
|
-
rubocop-rspec_rails (2.28.3)
|
143
|
-
rubocop (~> 1.40)
|
144
|
-
ruby-openai (7.0.1)
|
133
|
+
rubocop-rspec (3.0.1)
|
134
|
+
rubocop (~> 1.61)
|
135
|
+
ruby-openai (7.1.0)
|
145
136
|
event_stream_parser (>= 0.3.0, < 2.0.0)
|
146
137
|
faraday (>= 1)
|
147
138
|
faraday-multipart (>= 1)
|
@@ -152,8 +143,8 @@ GEM
|
|
152
143
|
jwt (>= 1.5, < 3.0)
|
153
144
|
multi_json (~> 1.10)
|
154
145
|
strscan (3.1.0)
|
155
|
-
sweet-moon (0.0
|
156
|
-
ffi (~> 1.
|
146
|
+
sweet-moon (1.0.0)
|
147
|
+
ffi (~> 1.17)
|
157
148
|
typhoeus (1.4.1)
|
158
149
|
ethon (>= 0.9.0)
|
159
150
|
unicode-display_width (2.5.0)
|
@@ -166,8 +157,8 @@ DEPENDENCIES
|
|
166
157
|
nano-bots!
|
167
158
|
pry-byebug (~> 3.10, >= 3.10.1)
|
168
159
|
rspec (~> 3.13)
|
169
|
-
rubocop (~> 1.
|
170
|
-
rubocop-rspec (~>
|
160
|
+
rubocop (~> 1.64, >= 1.64.1)
|
161
|
+
rubocop-rspec (~> 3.0, >= 3.0.1)
|
171
162
|
|
172
163
|
BUNDLED WITH
|
173
164
|
2.4.22
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ https://user-images.githubusercontent.com/113217272/238141567-c58a240c-7b67-4b3b
|
|
9
9
|
## TL;DR and Quick Start
|
10
10
|
|
11
11
|
```sh
|
12
|
-
gem install nano-bots -v 3.
|
12
|
+
gem install nano-bots -v 3.3.0
|
13
13
|
```
|
14
14
|
|
15
15
|
```bash
|
@@ -59,7 +59,7 @@ nb gpt.yml - eval "hi"
|
|
59
59
|
```
|
60
60
|
|
61
61
|
```ruby
|
62
|
-
gem 'nano-bots', '~> 3.
|
62
|
+
gem 'nano-bots', '~> 3.3.0'
|
63
63
|
```
|
64
64
|
|
65
65
|
```ruby
|
@@ -250,13 +250,13 @@ end
|
|
250
250
|
To install the CLI on your system:
|
251
251
|
|
252
252
|
```sh
|
253
|
-
gem install nano-bots -v 3.
|
253
|
+
gem install nano-bots -v 3.3.0
|
254
254
|
```
|
255
255
|
|
256
256
|
To use it in a Ruby project as a library, add to your `Gemfile`:
|
257
257
|
|
258
258
|
```ruby
|
259
|
-
gem 'nano-bots', '~> 3.
|
259
|
+
gem 'nano-bots', '~> 3.3.0'
|
260
260
|
```
|
261
261
|
|
262
262
|
```sh
|
@@ -971,8 +971,8 @@ Set your provider credentials and choose your desired path for the cartridges fi
|
|
971
971
|
---
|
972
972
|
services:
|
973
973
|
nano-bots:
|
974
|
-
image: ruby:3.
|
975
|
-
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 3.
|
974
|
+
image: ruby:3.3.3-slim-bookworm
|
975
|
+
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 3.3.0 && bash"
|
976
976
|
environment:
|
977
977
|
COHERE_API_KEY: your-api-key
|
978
978
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -988,8 +988,8 @@ services:
|
|
988
988
|
---
|
989
989
|
services:
|
990
990
|
nano-bots:
|
991
|
-
image: ruby:3.
|
992
|
-
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 3.
|
991
|
+
image: ruby:3.3.3-slim-bookworm
|
992
|
+
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 3.3.0 && bash"
|
993
993
|
environment:
|
994
994
|
MARITACA_API_KEY: your-api-key
|
995
995
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -1005,8 +1005,8 @@ services:
|
|
1005
1005
|
---
|
1006
1006
|
services:
|
1007
1007
|
nano-bots:
|
1008
|
-
image: ruby:3.
|
1009
|
-
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 3.
|
1008
|
+
image: ruby:3.3.3-slim-bookworm
|
1009
|
+
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 3.3.0 && bash"
|
1010
1010
|
environment:
|
1011
1011
|
MISTRAL_API_KEY: your-api-key
|
1012
1012
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -1024,8 +1024,8 @@ Remember that your `localhost` is by default inaccessible from inside Docker. Yo
|
|
1024
1024
|
---
|
1025
1025
|
services:
|
1026
1026
|
nano-bots:
|
1027
|
-
image: ruby:3.
|
1028
|
-
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 3.
|
1027
|
+
image: ruby:3.3.3-slim-bookworm
|
1028
|
+
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 3.3.0 && bash"
|
1029
1029
|
environment:
|
1030
1030
|
OLLAMA_API_ADDRESS: http://localhost:11434
|
1031
1031
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -1043,8 +1043,8 @@ services:
|
|
1043
1043
|
---
|
1044
1044
|
services:
|
1045
1045
|
nano-bots:
|
1046
|
-
image: ruby:3.
|
1047
|
-
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 3.
|
1046
|
+
image: ruby:3.3.3-slim-bookworm
|
1047
|
+
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 3.3.0 && bash"
|
1048
1048
|
environment:
|
1049
1049
|
OPENAI_API_KEY: your-access-token
|
1050
1050
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -1062,8 +1062,8 @@ services:
|
|
1062
1062
|
---
|
1063
1063
|
services:
|
1064
1064
|
nano-bots:
|
1065
|
-
image: ruby:3.
|
1066
|
-
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 3.
|
1065
|
+
image: ruby:3.3.3-slim-bookworm
|
1066
|
+
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 3.3.0 && bash"
|
1067
1067
|
environment:
|
1068
1068
|
GOOGLE_API_KEY: your-api-key
|
1069
1069
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -1079,8 +1079,8 @@ services:
|
|
1079
1079
|
---
|
1080
1080
|
services:
|
1081
1081
|
nano-bots:
|
1082
|
-
image: ruby:3.
|
1083
|
-
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 3.
|
1082
|
+
image: ruby:3.3.3-slim-bookworm
|
1083
|
+
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 3.3.0 && bash"
|
1084
1084
|
environment:
|
1085
1085
|
GOOGLE_CREDENTIALS_FILE_PATH: /root/.config/google-credentials.json
|
1086
1086
|
GOOGLE_REGION: us-east4
|
@@ -1098,8 +1098,8 @@ services:
|
|
1098
1098
|
---
|
1099
1099
|
services:
|
1100
1100
|
nano-bots:
|
1101
|
-
image: ruby:3.
|
1102
|
-
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 3.
|
1101
|
+
image: ruby:3.3.3-slim-bookworm
|
1102
|
+
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 3.3.0 && bash"
|
1103
1103
|
environment:
|
1104
1104
|
GOOGLE_REGION: us-east4
|
1105
1105
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -1161,5 +1161,5 @@ gem build nano-bots.gemspec
|
|
1161
1161
|
|
1162
1162
|
gem signin
|
1163
1163
|
|
1164
|
-
gem push nano-bots-3.
|
1164
|
+
gem push nano-bots-3.3.0.gem
|
1165
1165
|
```
|
@@ -28,6 +28,8 @@ module NanoBot
|
|
28
28
|
def initialize(options, settings, credentials, _environment)
|
29
29
|
@settings = settings
|
30
30
|
|
31
|
+
@service = credentials[:service]
|
32
|
+
|
31
33
|
gemini_options = options.transform_keys { |key| key.to_s.gsub('-', '_').to_sym }
|
32
34
|
|
33
35
|
unless gemini_options.key?(:stream)
|
@@ -82,11 +84,18 @@ module NanoBot
|
|
82
84
|
|
83
85
|
payload = { contents: messages, generationConfig: { candidateCount: 1 } }
|
84
86
|
|
85
|
-
if input[:behavior][:directive]
|
87
|
+
if input[:behavior][:directive] && @service == 'vertex-ai-api'
|
86
88
|
payload[:system_instruction] = {
|
87
89
|
role: 'user',
|
88
90
|
parts: { text: input[:behavior][:directive] }
|
89
91
|
}
|
92
|
+
elsif input[:behavior][:directive]
|
93
|
+
# TODO: Will generative-language-api support system instructions?
|
94
|
+
messages.prepend(
|
95
|
+
{ role: 'user',
|
96
|
+
parts: { text: input[:behavior][:directive] },
|
97
|
+
_meta: { at: Time.now } }
|
98
|
+
)
|
90
99
|
end
|
91
100
|
|
92
101
|
if @settings
|
@@ -124,13 +133,13 @@ module NanoBot
|
|
124
133
|
# TODO: How to better handle finishReason == 'OTHER'?
|
125
134
|
return if event.dig('candidates', 0, 'finishReason') == 'OTHER'
|
126
135
|
|
127
|
-
partial_content = event.dig('candidates', 0, 'content', 'parts')
|
136
|
+
partial_content = event.dig('candidates', 0, 'content', 'parts')&.filter do |part|
|
128
137
|
part.key?('text')
|
129
|
-
end
|
138
|
+
end&.map { |part| part['text'] }&.join || ''
|
130
139
|
|
131
|
-
partial_tools = event.dig('candidates', 0, 'content', 'parts')
|
140
|
+
partial_tools = event.dig('candidates', 0, 'content', 'parts')&.filter do |part|
|
132
141
|
part.key?('functionCall')
|
133
|
-
end
|
142
|
+
end || []
|
134
143
|
|
135
144
|
tools.concat(partial_tools) if partial_tools.size.positive?
|
136
145
|
|
@@ -142,10 +151,9 @@ module NanoBot
|
|
142
151
|
)
|
143
152
|
end
|
144
153
|
|
145
|
-
if event.dig('candidates', 0, 'finishReason')
|
146
|
-
|
147
|
-
|
148
|
-
# Is this a bug from the Google Gemini REST API or expected behavior?
|
154
|
+
if event.dig('candidates', 0, 'finishReason') == 'SAFETY'
|
155
|
+
reasons = event.dig('candidates', 0, 'safetyRatings')
|
156
|
+
raise StandardError, "Generation stopped for safety reasons: #{reasons}"
|
149
157
|
end
|
150
158
|
end
|
151
159
|
|
data/components/storage.rb
CHANGED
@@ -35,7 +35,7 @@ module NanoBot
|
|
35
35
|
Crypto.encrypt(user, soft: true)
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.
|
38
|
+
def self.build_path_for_state_file(key, cartridge, environment: {})
|
39
39
|
path = [
|
40
40
|
Logic::Helpers::Hash.fetch(cartridge, %i[state path]),
|
41
41
|
Logic::Helpers::Hash.fetch(cartridge, %i[state directory]),
|
@@ -54,18 +54,8 @@ module NanoBot
|
|
54
54
|
path = "#{path}/#{cartridge[:meta][:version].to_s.gsub('.', '-').to_slug.normalize}"
|
55
55
|
path = "#{path}/#{end_user(cartridge, environment)}"
|
56
56
|
path = "#{path}/#{Crypto.encrypt(key, soft: true)}"
|
57
|
-
path = "#{path}/state.json"
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
unless File.exist?(path)
|
62
|
-
File.write(
|
63
|
-
path,
|
64
|
-
Crypto.encrypt(JSON.generate({ key:, history: [] }))
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
path
|
58
|
+
"#{path}/state.json"
|
69
59
|
end
|
70
60
|
|
71
61
|
def self.cartridges_path(components: {})
|
data/controllers/session.rb
CHANGED
@@ -34,7 +34,9 @@ module NanoBot
|
|
34
34
|
if @stateless
|
35
35
|
@state = { history: [] }
|
36
36
|
else
|
37
|
-
@
|
37
|
+
@state_key = state.strip
|
38
|
+
|
39
|
+
@state_path = Components::Storage.build_path_for_state_file(
|
38
40
|
state.strip, @cartridge, environment:
|
39
41
|
)
|
40
42
|
|
@@ -43,16 +45,24 @@ module NanoBot
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def state
|
46
|
-
|
48
|
+
if @state[:history].empty?
|
49
|
+
nil
|
50
|
+
else
|
51
|
+
{ state: { path: @state_path, content: @state } }
|
52
|
+
end
|
47
53
|
end
|
48
54
|
|
49
55
|
def load_state
|
56
|
+
return { key: @state_key, history: [] } unless File.exist?(@state_path)
|
57
|
+
|
50
58
|
@state = Logic::Helpers::Hash.symbolize_keys(
|
51
59
|
JSON.parse(Components::Crypto.decrypt(File.read(@state_path)))
|
52
60
|
)
|
53
61
|
end
|
54
62
|
|
55
63
|
def store_state!
|
64
|
+
FileUtils.mkdir_p(File.dirname(@state_path)) unless File.exist?(@state_path)
|
65
|
+
|
56
66
|
File.write(@state_path, Components::Crypto.encrypt(JSON.generate(@state)))
|
57
67
|
end
|
58
68
|
|
data/docker-compose.example.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
---
|
2
2
|
services:
|
3
3
|
nano-bots:
|
4
|
-
image: ruby:3.
|
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 3.
|
4
|
+
image: ruby:3.3.3-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 3.3.0 && bash"
|
6
6
|
environment:
|
7
7
|
COHERE_API_KEY: your-api-key
|
8
8
|
|
data/logic/cartridge/parser.rb
CHANGED
data/nano-bots.gemspec
CHANGED
@@ -32,22 +32,22 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = ['nb']
|
33
33
|
|
34
34
|
spec.add_dependency 'babosa', '~> 2.0'
|
35
|
-
spec.add_dependency 'concurrent-ruby', '~> 1.
|
35
|
+
spec.add_dependency 'concurrent-ruby', '~> 1.3', '>= 1.3.3'
|
36
36
|
spec.add_dependency 'dotenv', '~> 3.1', '>= 3.1.2'
|
37
37
|
spec.add_dependency 'pry', '~> 0.14.2'
|
38
38
|
spec.add_dependency 'rainbow', '~> 3.1', '>= 3.1.1'
|
39
39
|
spec.add_dependency 'rbnacl', '~> 7.1', '>= 7.1.1'
|
40
40
|
spec.add_dependency 'redcarpet', '~> 3.6'
|
41
|
-
spec.add_dependency 'sweet-moon', '~>
|
41
|
+
spec.add_dependency 'sweet-moon', '~> 1.0'
|
42
42
|
|
43
43
|
spec.add_dependency 'cohere-ai', '~> 1.1'
|
44
44
|
spec.add_dependency 'gemini-ai', '~> 4.0'
|
45
45
|
spec.add_dependency 'maritaca-ai', '~> 1.2'
|
46
46
|
spec.add_dependency 'mistral-ai', '~> 1.2'
|
47
47
|
spec.add_dependency 'ollama-ai', '~> 1.2', '>= 1.2.1'
|
48
|
-
spec.add_dependency 'ruby-openai', '~> 7.
|
48
|
+
spec.add_dependency 'ruby-openai', '~> 7.1'
|
49
49
|
|
50
|
-
spec.add_dependency 'faraday', '~> 2.9'
|
50
|
+
spec.add_dependency 'faraday', '~> 2.9', '>= 2.9.2'
|
51
51
|
spec.add_dependency 'faraday-typhoeus', '~> 1.1'
|
52
52
|
spec.add_dependency 'typhoeus', '~> 1.4', '>= 1.4.1'
|
53
53
|
|