nano-bots 2.4.0 → 2.5.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 +14 -8
- data/README.md +598 -335
- data/components/provider.rb +10 -4
- data/components/providers/cohere.rb +1 -1
- data/components/providers/maritaca.rb +113 -0
- data/components/providers/ollama.rb +132 -0
- data/docker-compose.example.yml +10 -4
- data/logic/cartridge/streaming.rb +2 -2
- data/logic/providers/maritaca/tokens.rb +14 -0
- data/logic/providers/ollama/tokens.rb +14 -0
- data/nano-bots.gemspec +7 -4
- data/static/gem.rb +4 -4
- metadata +90 -51
data/README.md
CHANGED
@@ -1,218 +1,109 @@
|
|
1
1
|
# Nano Bots 💎 🤖
|
2
2
|
|
3
|
-
|
3
|
+
An implementation of the [Nano Bots](https://spec.nbots.io) specification with support for [Cohere Command](https://cohere.com), [Google Gemini](https://deepmind.google/technologies/gemini), [Maritaca AI MariTalk](https://www.maritaca.ai), [Mistral AI](https://mistral.ai), [Ollama](https://ollama.ai), [OpenAI ChatGPT](https://openai.com/chatgpt), and others.
|
4
4
|
|
5
5
|
![Ruby Nano Bots](https://raw.githubusercontent.com/icebaker/assets/main/nano-bots/ruby-nano-bots-canvas.png)
|
6
6
|
|
7
7
|
https://user-images.githubusercontent.com/113217272/238141567-c58a240c-7b67-4b3b-864a-0f49bbf6e22f.mp4
|
8
8
|
|
9
|
-
|
10
|
-
- [Cohere Command](#cohere-command)
|
11
|
-
- [Google Gemini](#google-gemini)
|
12
|
-
- [Mistral AI](#mistral-ai)
|
13
|
-
- [OpenAI ChatGPT](#openai-chatgpt)
|
14
|
-
- [Usage](#usage)
|
15
|
-
- [Command Line](#command-line)
|
16
|
-
- [Library](#library)
|
17
|
-
- [Cartridges](#cartridges)
|
18
|
-
- [Cohere Command](#cohere-command-1)
|
19
|
-
- [Google Gemini](#google-gemini-1)
|
20
|
-
- [Mistral AI](#mistral-ai-1)
|
21
|
-
- [OpenAI ChatGPT](#openai-chatgpt-1)
|
22
|
-
- [Tools (Functions)](#tools-functions)
|
23
|
-
- [Experimental Clojure Support](#experimental-clojure-support)
|
24
|
-
- [Marketplace](#marketplace)
|
25
|
-
- [Docker](#docker)
|
26
|
-
- [Cohere Command](#cohere-command-2)
|
27
|
-
- [Google Gemini](#google-gemini-2)
|
28
|
-
- [Mistral AI](#mistral-ai-2)
|
29
|
-
- [OpenAI ChatGPT](#openai-chatgpt-2)
|
30
|
-
- [Security and Privacy](#security-and-privacy)
|
31
|
-
- [Cryptography](#cryptography)
|
32
|
-
- [End-user IDs](#end-user-ids)
|
33
|
-
- [Decrypting](#decrypting)
|
34
|
-
- [Providers](#providers)
|
35
|
-
- [Debugging](#debugging)
|
36
|
-
- [Development](#development)
|
37
|
-
- [Publish to RubyGems](#publish-to-rubygems)
|
38
|
-
|
39
|
-
## Setup
|
40
|
-
|
41
|
-
For a system usage:
|
42
|
-
|
43
|
-
```sh
|
44
|
-
gem install nano-bots -v 2.4.0
|
45
|
-
```
|
46
|
-
|
47
|
-
To use it in a project, add it to your `Gemfile`:
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
gem 'nano-bots', '~> 2.4.0'
|
51
|
-
```
|
52
|
-
|
53
|
-
```sh
|
54
|
-
bundle install
|
55
|
-
```
|
56
|
-
|
57
|
-
For credentials and configurations, relevant environment variables can be set in your `.bashrc`, `.zshrc`, or equivalent files, as well as in your Docker Container or System Environment. Example:
|
58
|
-
|
59
|
-
```sh
|
60
|
-
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
61
|
-
export NANO_BOTS_END_USER=your-user
|
62
|
-
|
63
|
-
# export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
64
|
-
# export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
65
|
-
```
|
66
|
-
|
67
|
-
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
68
|
-
|
69
|
-
```sh
|
70
|
-
NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
71
|
-
NANO_BOTS_END_USER=your-user
|
72
|
-
|
73
|
-
# NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
74
|
-
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
75
|
-
```
|
76
|
-
|
77
|
-
### Cohere Command
|
78
|
-
|
79
|
-
You can obtain your credentials on the [Cohere Platform](https://dashboard.cohere.com).
|
80
|
-
|
81
|
-
```sh
|
82
|
-
export COHERE_API_ADDRESS=https://api.cohere.ai
|
83
|
-
export COHERE_API_KEY=your-api-key
|
84
|
-
```
|
85
|
-
|
86
|
-
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
87
|
-
|
88
|
-
```sh
|
89
|
-
COHERE_API_ADDRESS=https://api.cohere.ai
|
90
|
-
COHERE_API_KEY=your-api-key
|
91
|
-
```
|
92
|
-
|
93
|
-
### Mistral AI
|
94
|
-
|
95
|
-
You can obtain your credentials on the [Mistral Platform](https://console.mistral.ai).
|
96
|
-
|
97
|
-
```sh
|
98
|
-
export MISTRAL_API_ADDRESS=https://api.mistral.ai
|
99
|
-
export MISTRAL_API_KEY=your-api-key
|
100
|
-
```
|
101
|
-
|
102
|
-
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
103
|
-
|
104
|
-
```sh
|
105
|
-
MISTRAL_API_ADDRESS=https://api.mistral.ai
|
106
|
-
MISTRAL_API_KEY=your-api-key
|
107
|
-
```
|
108
|
-
|
109
|
-
### OpenAI ChatGPT
|
110
|
-
|
111
|
-
You can obtain your credentials on the [OpenAI Platform](https://platform.openai.com).
|
9
|
+
## TL;DR and Quick Start
|
112
10
|
|
113
11
|
```sh
|
114
|
-
|
115
|
-
export OPENAI_API_KEY=your-access-token
|
12
|
+
gem install nano-bots -v 2.5.0
|
116
13
|
```
|
117
14
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
OPENAI_API_ADDRESS=https://api.openai.com
|
122
|
-
OPENAI_API_KEY=your-access-token
|
15
|
+
```bash
|
16
|
+
nb - - eval "hello"
|
17
|
+
# => Hello! How may I assist you today?
|
123
18
|
```
|
124
19
|
|
125
|
-
|
126
|
-
|
127
|
-
Click [here](https://github.com/gbaptista/gemini-ai#credentials) to learn how to obtain your credentials.
|
128
|
-
|
129
|
-
#### Option 1: API Key (Generative Language API)
|
130
|
-
|
131
|
-
```sh
|
132
|
-
export GOOGLE_API_KEY=your-api-key
|
133
|
-
|
134
|
-
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
135
|
-
export NANO_BOTS_END_USER=your-user
|
136
|
-
|
137
|
-
# export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
138
|
-
# export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
20
|
+
```bash
|
21
|
+
nb - - repl
|
139
22
|
```
|
140
23
|
|
141
|
-
|
142
|
-
|
143
|
-
```sh
|
144
|
-
GOOGLE_API_KEY=your-api-key
|
24
|
+
```text
|
25
|
+
🤖> Hi, how are you doing?
|
145
26
|
|
146
|
-
|
147
|
-
|
27
|
+
As an AI language model, I do not experience emotions but I am functioning
|
28
|
+
well. How can I assist you?
|
148
29
|
|
149
|
-
|
150
|
-
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
30
|
+
🤖> |
|
151
31
|
```
|
152
32
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
160
|
-
export NANO_BOTS_END_USER=your-user
|
33
|
+
```yaml
|
34
|
+
---
|
35
|
+
meta:
|
36
|
+
symbol: 🤖
|
37
|
+
name: ChatGPT
|
161
38
|
|
162
|
-
|
163
|
-
|
39
|
+
provider:
|
40
|
+
id: openai
|
41
|
+
credentials:
|
42
|
+
access-token: ENV/OPENAI_API_KEY
|
43
|
+
settings:
|
44
|
+
model: gpt-4-1106-preview
|
164
45
|
```
|
165
46
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
|
170
|
-
GOOGLE_REGION=us-east4
|
171
|
-
|
172
|
-
NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
173
|
-
NANO_BOTS_END_USER=your-user
|
174
|
-
|
175
|
-
# NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
176
|
-
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
47
|
+
```bash
|
48
|
+
nb gpt.yml - eval "hi"
|
49
|
+
# => Hello! How can I assist you today?
|
177
50
|
```
|
178
51
|
|
179
|
-
|
180
|
-
|
181
|
-
```sh
|
182
|
-
export GOOGLE_REGION=us-east4
|
183
|
-
|
184
|
-
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
185
|
-
export NANO_BOTS_END_USER=your-user
|
186
|
-
|
187
|
-
# export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
188
|
-
# export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
52
|
+
```ruby
|
53
|
+
gem 'nano-bots', '~> 2.5.0'
|
189
54
|
```
|
190
55
|
|
191
|
-
|
192
|
-
|
193
|
-
```sh
|
194
|
-
GOOGLE_REGION=us-east4
|
195
|
-
|
196
|
-
NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
197
|
-
NANO_BOTS_END_USER=your-user
|
198
|
-
|
199
|
-
# NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
200
|
-
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
201
|
-
```
|
56
|
+
```ruby
|
57
|
+
require 'nano-bots'
|
202
58
|
|
203
|
-
|
59
|
+
bot = NanoBot.new(cartridge: 'gpt.yml')
|
204
60
|
|
205
|
-
|
61
|
+
bot.eval('Hi!') do |content, fragment, finished, meta|
|
62
|
+
print fragment unless fragment.nil?
|
63
|
+
end
|
206
64
|
|
207
|
-
|
208
|
-
export GOOGLE_PROJECT_ID=your-project-id
|
65
|
+
# => Hello! How can I assist you today?
|
209
66
|
```
|
210
67
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
68
|
+
- [TL;DR and Quick Start](#tldr-and-quick-start)
|
69
|
+
- [Usage](#usage)
|
70
|
+
- [Command Line](#command-line)
|
71
|
+
- [Debugging](#debugging)
|
72
|
+
- [Library](#library)
|
73
|
+
- [Setup](#setup)
|
74
|
+
- [Cohere Command](#cohere-command)
|
75
|
+
- [Maritaca AI MariTalk](#maritaca-ai-maritalk)
|
76
|
+
- [Mistral AI](#mistral-ai)
|
77
|
+
- [Ollama](#ollama)
|
78
|
+
- [OpenAI ChatGPT](#openai-chatgpt)
|
79
|
+
- [Google Gemini](#google-gemini)
|
80
|
+
- [Option 1: API Key (Generative Language API)](#option-1-api-key-generative-language-api)
|
81
|
+
- [Option 2: Service Account Credentials File (Vertex AI API)](#option-2-service-account-credentials-file-vertex-ai-api)
|
82
|
+
- [Option 3: Application Default Credentials (Vertex AI API)](#option-3-application-default-credentials-vertex-ai-api)
|
83
|
+
- [Custom Project ID](#custom-project-id)
|
84
|
+
- [Cartridges](#cartridges)
|
85
|
+
- [Tools (Functions)](#tools-functions)
|
86
|
+
- [Experimental Clojure Support](#experimental-clojure-support)
|
87
|
+
- [Marketplace](#marketplace)
|
88
|
+
- [Security and Privacy](#security-and-privacy)
|
89
|
+
- [Cryptography](#cryptography)
|
90
|
+
- [End-user IDs](#end-user-ids)
|
91
|
+
- [Decrypting](#decrypting)
|
92
|
+
- [Supported Providers](#supported-providers)
|
93
|
+
- [Docker](#docker)
|
94
|
+
- [Cohere Command Container](#cohere-command-container)
|
95
|
+
- [Maritaca AI MariTalk Container](#maritaca-ai-maritalk-container)
|
96
|
+
- [Mistral AI Container](#mistral-ai-container)
|
97
|
+
- [Ollama Container](#ollama-container)
|
98
|
+
- [OpenAI ChatGPT Container](#openai-chatgpt-container)
|
99
|
+
- [Google Gemini Container](#google-gemini-container)
|
100
|
+
- [Option 1: API Key (Generative Language API) Config](#option-1-api-key-generative-language-api-config)
|
101
|
+
- [Option 2: Service Account Credentials File (Vertex AI API) Config](#option-2-service-account-credentials-file-vertex-ai-api-config)
|
102
|
+
- [Option 3: Application Default Credentials (Vertex AI API) Config](#option-3-application-default-credentials-vertex-ai-api-config)
|
103
|
+
- [Custom Project ID Config](#custom-project-id-config)
|
104
|
+
- [Running the Container](#running-the-container)
|
105
|
+
- [Development](#development)
|
106
|
+
- [Publish to RubyGems](#publish-to-rubygems)
|
216
107
|
|
217
108
|
## Usage
|
218
109
|
|
@@ -345,17 +236,59 @@ bot.boot do |content, fragment, finished, meta|
|
|
345
236
|
end
|
346
237
|
```
|
347
238
|
|
348
|
-
##
|
239
|
+
## Setup
|
349
240
|
|
350
|
-
|
241
|
+
To install the CLI on your system:
|
351
242
|
|
352
|
-
|
243
|
+
```sh
|
244
|
+
gem install nano-bots -v 2.5.0
|
245
|
+
```
|
353
246
|
|
354
|
-
|
247
|
+
To use it in a Ruby project as a library, add to your `Gemfile`:
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
gem 'nano-bots', '~> 2.5.0'
|
251
|
+
```
|
252
|
+
|
253
|
+
```sh
|
254
|
+
bundle install
|
255
|
+
```
|
256
|
+
|
257
|
+
For credentials and configurations, relevant environment variables can be set in your `.bashrc`, `.zshrc`, or equivalent files, as well as in your Docker Container or System Environment. Example:
|
258
|
+
|
259
|
+
```sh
|
260
|
+
export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
261
|
+
export NANO_BOTS_END_USER=your-user
|
262
|
+
|
263
|
+
# export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
264
|
+
# export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
265
|
+
```
|
266
|
+
|
267
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
268
|
+
|
269
|
+
```sh
|
270
|
+
NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
|
271
|
+
NANO_BOTS_END_USER=your-user
|
272
|
+
|
273
|
+
# NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
|
274
|
+
# NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
|
275
|
+
```
|
355
276
|
|
356
277
|
### Cohere Command
|
357
278
|
|
358
|
-
|
279
|
+
You can obtain your credentials on the [Cohere Platform](https://dashboard.cohere.com).
|
280
|
+
|
281
|
+
```sh
|
282
|
+
export COHERE_API_KEY=your-api-key
|
283
|
+
```
|
284
|
+
|
285
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
286
|
+
|
287
|
+
```sh
|
288
|
+
COHERE_API_KEY=your-api-key
|
289
|
+
```
|
290
|
+
|
291
|
+
Create a `cartridge.yml` file:
|
359
292
|
|
360
293
|
```yaml
|
361
294
|
---
|
@@ -379,10 +312,90 @@ provider:
|
|
379
312
|
model: command
|
380
313
|
```
|
381
314
|
|
382
|
-
|
315
|
+
Read the [full specification](https://spec.nbots.io/#/README?id=cohere-command) for Cohere Command.
|
316
|
+
|
317
|
+
```bash
|
318
|
+
nb cartridge.yml - eval "Hello"
|
319
|
+
|
320
|
+
nb cartridge.yml - repl
|
321
|
+
```
|
322
|
+
|
323
|
+
```ruby
|
324
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
325
|
+
|
326
|
+
puts bot.eval('Hello')
|
327
|
+
```
|
328
|
+
|
329
|
+
### Maritaca AI MariTalk
|
330
|
+
|
331
|
+
You can obtain your API key at [MariTalk](https://chat.maritaca.ai).
|
332
|
+
|
333
|
+
Enclose credentials in single quotes when using environment variables to prevent issues with the $ character in the API key:
|
334
|
+
|
335
|
+
```sh
|
336
|
+
export MARITACA_API_KEY='123...$a12...'
|
337
|
+
```
|
338
|
+
|
339
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
340
|
+
|
341
|
+
```sh
|
342
|
+
MARITACA_API_KEY='123...$a12...'
|
343
|
+
```
|
344
|
+
|
345
|
+
Create a `cartridge.yml` file:
|
346
|
+
|
347
|
+
```yaml
|
348
|
+
---
|
349
|
+
meta:
|
350
|
+
symbol: 🤖
|
351
|
+
name: Nano Bot Name
|
352
|
+
author: Your Name
|
353
|
+
version: 1.0.0
|
354
|
+
license: CC0-1.0
|
355
|
+
description: A helpful assistant.
|
356
|
+
|
357
|
+
behaviors:
|
358
|
+
interaction:
|
359
|
+
directive: You are a helpful assistant.
|
360
|
+
|
361
|
+
provider:
|
362
|
+
id: maritaca
|
363
|
+
credentials:
|
364
|
+
api-key: ENV/MARITACA_API_KEY
|
365
|
+
settings:
|
366
|
+
model: maritalk
|
367
|
+
```
|
383
368
|
|
384
369
|
Read the [full specification](https://spec.nbots.io/#/README?id=mistral-ai) for Mistral AI.
|
385
370
|
|
371
|
+
```bash
|
372
|
+
nb cartridge.yml - eval "Hello"
|
373
|
+
|
374
|
+
nb cartridge.yml - repl
|
375
|
+
```
|
376
|
+
|
377
|
+
```ruby
|
378
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
379
|
+
|
380
|
+
puts bot.eval('Hello')
|
381
|
+
```
|
382
|
+
|
383
|
+
### Mistral AI
|
384
|
+
|
385
|
+
You can obtain your credentials on the [Mistral Platform](https://console.mistral.ai).
|
386
|
+
|
387
|
+
```sh
|
388
|
+
export MISTRAL_API_KEY=your-api-key
|
389
|
+
```
|
390
|
+
|
391
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
392
|
+
|
393
|
+
```sh
|
394
|
+
MISTRAL_API_KEY=your-api-key
|
395
|
+
```
|
396
|
+
|
397
|
+
Create a `cartridge.yml` file:
|
398
|
+
|
386
399
|
```yaml
|
387
400
|
---
|
388
401
|
meta:
|
@@ -405,9 +418,87 @@ provider:
|
|
405
418
|
model: mistral-medium
|
406
419
|
```
|
407
420
|
|
421
|
+
Read the [full specification](https://spec.nbots.io/#/README?id=mistral-ai) for Mistral AI.
|
422
|
+
|
423
|
+
```bash
|
424
|
+
nb cartridge.yml - eval "Hello"
|
425
|
+
|
426
|
+
nb cartridge.yml - repl
|
427
|
+
```
|
428
|
+
|
429
|
+
```ruby
|
430
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
431
|
+
|
432
|
+
puts bot.eval('Hello')
|
433
|
+
```
|
434
|
+
|
435
|
+
### Ollama
|
436
|
+
|
437
|
+
To install and set up, follow the instructions on the [Ollama](https://ollama.ai) website.
|
438
|
+
|
439
|
+
```sh
|
440
|
+
export OLLAMA_API_ADDRESS=http://localhost:11434
|
441
|
+
```
|
442
|
+
|
443
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
444
|
+
|
445
|
+
```sh
|
446
|
+
OLLAMA_API_ADDRESS=http://localhost:11434
|
447
|
+
```
|
448
|
+
|
449
|
+
Create a `cartridge.yml` file:
|
450
|
+
|
451
|
+
```yaml
|
452
|
+
---
|
453
|
+
meta:
|
454
|
+
symbol: 🤖
|
455
|
+
name: Nano Bot Name
|
456
|
+
author: Your Name
|
457
|
+
version: 1.0.0
|
458
|
+
license: CC0-1.0
|
459
|
+
description: A helpful assistant.
|
460
|
+
|
461
|
+
behaviors:
|
462
|
+
interaction:
|
463
|
+
directive: You are a helpful assistant.
|
464
|
+
|
465
|
+
provider:
|
466
|
+
id: ollama
|
467
|
+
credentials:
|
468
|
+
address: ENV/OLLAMA_API_ADDRESS
|
469
|
+
settings:
|
470
|
+
model: llama2
|
471
|
+
```
|
472
|
+
|
473
|
+
Read the [full specification](https://spec.nbots.io/#/README?id=ollama) for Ollama.
|
474
|
+
|
475
|
+
```bash
|
476
|
+
nb cartridge.yml - eval "Hello"
|
477
|
+
|
478
|
+
nb cartridge.yml - repl
|
479
|
+
```
|
480
|
+
|
481
|
+
```ruby
|
482
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
483
|
+
|
484
|
+
puts bot.eval('Hello')
|
485
|
+
```
|
486
|
+
|
408
487
|
### OpenAI ChatGPT
|
409
488
|
|
410
|
-
|
489
|
+
You can obtain your credentials on the [OpenAI Platform](https://platform.openai.com).
|
490
|
+
|
491
|
+
```sh
|
492
|
+
export OPENAI_API_KEY=your-access-token
|
493
|
+
```
|
494
|
+
|
495
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
496
|
+
|
497
|
+
```sh
|
498
|
+
OPENAI_API_KEY=your-access-token
|
499
|
+
```
|
500
|
+
|
501
|
+
Create a `cartridge.yml` file:
|
411
502
|
|
412
503
|
```yaml
|
413
504
|
---
|
@@ -426,19 +517,44 @@ behaviors:
|
|
426
517
|
provider:
|
427
518
|
id: openai
|
428
519
|
credentials:
|
429
|
-
address: ENV/OPENAI_API_ADDRESS
|
430
520
|
access-token: ENV/OPENAI_API_KEY
|
431
521
|
settings:
|
432
522
|
user: ENV/NANO_BOTS_END_USER
|
433
523
|
model: gpt-4-1106-preview
|
434
524
|
```
|
435
525
|
|
526
|
+
Read the [full specification](https://spec.nbots.io/#/README?id=openai-chatgpt) for OpenAI ChatGPT.
|
527
|
+
|
528
|
+
```bash
|
529
|
+
nb cartridge.yml - eval "Hello"
|
530
|
+
|
531
|
+
nb cartridge.yml - repl
|
532
|
+
```
|
533
|
+
|
534
|
+
```ruby
|
535
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
536
|
+
|
537
|
+
puts bot.eval('Hello')
|
538
|
+
```
|
539
|
+
|
436
540
|
### Google Gemini
|
437
541
|
|
438
|
-
|
542
|
+
Click [here](https://github.com/gbaptista/gemini-ai#credentials) to learn how to obtain your credentials.
|
439
543
|
|
440
544
|
#### Option 1: API Key (Generative Language API)
|
441
545
|
|
546
|
+
```sh
|
547
|
+
export GOOGLE_API_KEY=your-api-key
|
548
|
+
```
|
549
|
+
|
550
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
551
|
+
|
552
|
+
```sh
|
553
|
+
GOOGLE_API_KEY=your-api-key
|
554
|
+
```
|
555
|
+
|
556
|
+
Create a `cartridge.yml` file:
|
557
|
+
|
442
558
|
```yaml
|
443
559
|
---
|
444
560
|
meta:
|
@@ -462,8 +578,36 @@ provider:
|
|
462
578
|
model: gemini-pro
|
463
579
|
```
|
464
580
|
|
581
|
+
Read the [full specification](https://spec.nbots.io/#/README?id=google-gemini) for Google Gemini.
|
582
|
+
|
583
|
+
```bash
|
584
|
+
nb cartridge.yml - eval "Hello"
|
585
|
+
|
586
|
+
nb cartridge.yml - repl
|
587
|
+
```
|
588
|
+
|
589
|
+
```ruby
|
590
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
591
|
+
|
592
|
+
puts bot.eval('Hello')
|
593
|
+
```
|
594
|
+
|
465
595
|
#### Option 2: Service Account Credentials File (Vertex AI API)
|
466
596
|
|
597
|
+
```sh
|
598
|
+
export GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
|
599
|
+
export GOOGLE_REGION=us-east4
|
600
|
+
```
|
601
|
+
|
602
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
603
|
+
|
604
|
+
```sh
|
605
|
+
GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
|
606
|
+
GOOGLE_REGION=us-east4
|
607
|
+
```
|
608
|
+
|
609
|
+
Create a `cartridge.yml` file:
|
610
|
+
|
467
611
|
```yaml
|
468
612
|
---
|
469
613
|
meta:
|
@@ -488,8 +632,34 @@ provider:
|
|
488
632
|
model: gemini-pro
|
489
633
|
```
|
490
634
|
|
635
|
+
Read the [full specification](https://spec.nbots.io/#/README?id=google-gemini) for Google Gemini.
|
636
|
+
|
637
|
+
```bash
|
638
|
+
nb cartridge.yml - eval "Hello"
|
639
|
+
|
640
|
+
nb cartridge.yml - repl
|
641
|
+
```
|
642
|
+
|
643
|
+
```ruby
|
644
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
645
|
+
|
646
|
+
puts bot.eval('Hello')
|
647
|
+
```
|
648
|
+
|
491
649
|
#### Option 3: Application Default Credentials (Vertex AI API)
|
492
650
|
|
651
|
+
```sh
|
652
|
+
export GOOGLE_REGION=us-east4
|
653
|
+
```
|
654
|
+
|
655
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
656
|
+
|
657
|
+
```sh
|
658
|
+
GOOGLE_REGION=us-east4
|
659
|
+
```
|
660
|
+
|
661
|
+
Create a `cartridge.yml` file:
|
662
|
+
|
493
663
|
```yaml
|
494
664
|
---
|
495
665
|
meta:
|
@@ -513,10 +683,36 @@ provider:
|
|
513
683
|
model: gemini-pro
|
514
684
|
```
|
515
685
|
|
686
|
+
Read the [full specification](https://spec.nbots.io/#/README?id=google-gemini) for Google Gemini.
|
687
|
+
|
688
|
+
```bash
|
689
|
+
nb cartridge.yml - eval "Hello"
|
690
|
+
|
691
|
+
nb cartridge.yml - repl
|
692
|
+
```
|
693
|
+
|
694
|
+
```ruby
|
695
|
+
bot = NanoBot.new(cartridge: 'cartridge.yml')
|
696
|
+
|
697
|
+
puts bot.eval('Hello')
|
698
|
+
```
|
699
|
+
|
516
700
|
#### Custom Project ID
|
517
701
|
|
518
702
|
If you need to manually set a Google Project ID:
|
519
703
|
|
704
|
+
```sh
|
705
|
+
export GOOGLE_PROJECT_ID=your-project-id
|
706
|
+
```
|
707
|
+
|
708
|
+
Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
|
709
|
+
|
710
|
+
```sh
|
711
|
+
GOOGLE_PROJECT_ID=your-project-id
|
712
|
+
```
|
713
|
+
|
714
|
+
Add to your `cartridge.yml` file:
|
715
|
+
|
520
716
|
```yaml
|
521
717
|
---
|
522
718
|
provider:
|
@@ -525,6 +721,37 @@ provider:
|
|
525
721
|
project-id: ENV/GOOGLE_PROJECT_ID
|
526
722
|
```
|
527
723
|
|
724
|
+
## Cartridges
|
725
|
+
|
726
|
+
Check the Nano Bots specification to learn more about [how to build cartridges](https://spec.nbots.io/#/README?id=cartridges).
|
727
|
+
|
728
|
+
Try the [Nano Bots Clinic (Live Editor)](https://clinic.nbots.io) to learn about creating Cartridges.
|
729
|
+
|
730
|
+
Here's what a Nano Bot Cartridge looks like:
|
731
|
+
|
732
|
+
```yaml
|
733
|
+
---
|
734
|
+
meta:
|
735
|
+
symbol: 🤖
|
736
|
+
name: Nano Bot Name
|
737
|
+
author: Your Name
|
738
|
+
version: 1.0.0
|
739
|
+
license: CC0-1.0
|
740
|
+
description: A helpful assistant.
|
741
|
+
|
742
|
+
behaviors:
|
743
|
+
interaction:
|
744
|
+
directive: You are a helpful assistant.
|
745
|
+
|
746
|
+
provider:
|
747
|
+
id: openai
|
748
|
+
credentials:
|
749
|
+
access-token: ENV/OPENAI_API_KEY
|
750
|
+
settings:
|
751
|
+
user: ENV/NANO_BOTS_END_USER
|
752
|
+
model: gpt-4-1106-preview
|
753
|
+
```
|
754
|
+
|
528
755
|
### Tools (Functions)
|
529
756
|
|
530
757
|
Nano Bots can also be powered by _Tools_ (Functions):
|
@@ -550,7 +777,7 @@ The randomly generated number is 59.
|
|
550
777
|
|
551
778
|
🤖> |
|
552
779
|
```
|
553
|
-
To successfully use Tools (Functions), you need to specify a provider and a model that supports them. As of the writing of this README, the provider that supports them is [OpenAI](https://platform.openai.com/docs/models), with models `gpt-3.5-turbo-1106` and `gpt-4-1106-preview`, and [Google](https://cloud.google.com/vertex-ai/docs/generative-ai/multimodal/function-calling#supported_models), with the `vertex-ai-api` service and the model `gemini-pro`.
|
780
|
+
To successfully use Tools (Functions), you need to specify a provider and a model that supports them. As of the writing of this README, the provider that supports them is [OpenAI](https://platform.openai.com/docs/models), with models `gpt-3.5-turbo-1106` and `gpt-4-1106-preview`, and [Google](https://cloud.google.com/vertex-ai/docs/generative-ai/multimodal/function-calling#supported_models), with the `vertex-ai-api` service and the model `gemini-pro`. Other providers do not yet have support.
|
554
781
|
|
555
782
|
Check the [Nano Bots specification](https://spec.nbots.io/#/README?id=tools-functions-2) to learn more about Tools (Functions).
|
556
783
|
|
@@ -595,6 +822,128 @@ safety:
|
|
595
822
|
|
596
823
|
You can explore the Nano Bots [Marketplace](https://nbots.io) to discover new Cartridges that can help you.
|
597
824
|
|
825
|
+
## Security and Privacy
|
826
|
+
|
827
|
+
Each provider will have its own security and privacy policies (e.g. [OpenAI Policy](https://openai.com/policies/api-data-usage-policies)), so you must consult them to understand their implications.
|
828
|
+
|
829
|
+
### Cryptography
|
830
|
+
|
831
|
+
By default, all states stored in your local disk are encrypted.
|
832
|
+
|
833
|
+
To ensure that the encryption is secure, you need to define a password through the `NANO_BOTS_ENCRYPTION_PASSWORD` environment variable. Otherwise, although the content will be encrypted, anyone would be able to decrypt it without a password.
|
834
|
+
|
835
|
+
It's important to note that the content shared with providers, despite being transmitted over secure connections (e.g., [HTTPS](https://en.wikipedia.org/wiki/HTTPS)), will be readable by the provider. This is because providers need to operate on the data, which would not be possible if the content was encrypted beyond HTTPS. So, the data stored locally on your system is encrypted, which does not mean that what you share with providers will not be readable by them.
|
836
|
+
|
837
|
+
To ensure that your encryption and password are configured properly, you can run the following command:
|
838
|
+
```sh
|
839
|
+
nb security
|
840
|
+
```
|
841
|
+
|
842
|
+
Which should return:
|
843
|
+
```text
|
844
|
+
✅ Encryption is enabled and properly working.
|
845
|
+
This means that your data is stored in an encrypted format on your disk.
|
846
|
+
|
847
|
+
✅ A password is being used for the encrypted content.
|
848
|
+
This means that only those who possess the password can decrypt your data.
|
849
|
+
```
|
850
|
+
|
851
|
+
Alternatively, you can check it at runtime with:
|
852
|
+
```ruby
|
853
|
+
require 'nano-bots'
|
854
|
+
|
855
|
+
NanoBot.security.check
|
856
|
+
# => { encryption: true, password: true }
|
857
|
+
```
|
858
|
+
|
859
|
+
### End-user IDs
|
860
|
+
|
861
|
+
A common strategy for deploying Nano Bots to multiple users through APIs or automations is to assign a unique [end-user ID](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids) for each user. This can be useful if any of your users violate the provider's policy due to abusive behavior. By providing the end-user ID, you can unravel that even though the activity originated from your API Key, the actions taken were not your own.
|
862
|
+
|
863
|
+
You can define custom end-user identifiers in the following way:
|
864
|
+
|
865
|
+
```ruby
|
866
|
+
NanoBot.new(environment: { NANO_BOTS_END_USER: 'custom-user-a' })
|
867
|
+
NanoBot.new(environment: { NANO_BOTS_END_USER: 'custom-user-b' })
|
868
|
+
```
|
869
|
+
|
870
|
+
Consider that you have the following end-user identifier in your environment:
|
871
|
+
```sh
|
872
|
+
NANO_BOTS_END_USER=your-name
|
873
|
+
```
|
874
|
+
|
875
|
+
Or a configuration in your Cartridge:
|
876
|
+
```yml
|
877
|
+
---
|
878
|
+
provider:
|
879
|
+
id: openai
|
880
|
+
settings:
|
881
|
+
user: your-name
|
882
|
+
```
|
883
|
+
|
884
|
+
The requests will be performed as follows:
|
885
|
+
|
886
|
+
```ruby
|
887
|
+
NanoBot.new(cartridge: '-')
|
888
|
+
# { user: 'your-name' }
|
889
|
+
|
890
|
+
NanoBot.new(cartridge: '-', environment: { NANO_BOTS_END_USER: 'custom-user-a' })
|
891
|
+
# { user: 'custom-user-a' }
|
892
|
+
|
893
|
+
NanoBot.new(cartridge: '-', environment: { NANO_BOTS_END_USER: 'custom-user-b' })
|
894
|
+
# { user: 'custom-user-b' }
|
895
|
+
```
|
896
|
+
|
897
|
+
Actually, to enhance privacy, neither your user nor your users' identifiers will be shared in this way. Instead, they will be encrypted before being shared with the provider:
|
898
|
+
|
899
|
+
```ruby
|
900
|
+
'your-name'
|
901
|
+
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA==
|
902
|
+
|
903
|
+
'custom-user-a'
|
904
|
+
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs=
|
905
|
+
|
906
|
+
'custom-user-b'
|
907
|
+
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg=
|
908
|
+
```
|
909
|
+
|
910
|
+
In this manner, you possess identifiers if required, however, their actual content can only be decrypted by you via your secure password (`NANO_BOTS_ENCRYPTION_PASSWORD`).
|
911
|
+
|
912
|
+
### Decrypting
|
913
|
+
|
914
|
+
To decrypt your encrypted data, once you have properly configured your password, you can simply run:
|
915
|
+
|
916
|
+
```ruby
|
917
|
+
require 'nano-bots'
|
918
|
+
|
919
|
+
NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA==')
|
920
|
+
# your-name
|
921
|
+
|
922
|
+
NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs=')
|
923
|
+
# custom-user-a
|
924
|
+
|
925
|
+
NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg=')
|
926
|
+
# custom-user-b
|
927
|
+
```
|
928
|
+
|
929
|
+
If you lose your password, you lose your data. It is not possible to recover it at all. For real.
|
930
|
+
|
931
|
+
## Supported Providers
|
932
|
+
|
933
|
+
- [ ] [Anthropic Claude](https://www.anthropic.com)
|
934
|
+
- [x] [Cohere Command](https://cohere.com)
|
935
|
+
- [x] [Google Gemini](https://deepmind.google/technologies/gemini)
|
936
|
+
- [x] [Maritaca AI MariTalk](https://www.maritaca.ai)
|
937
|
+
- [x] [Mistral AI](https://mistral.ai)
|
938
|
+
- [x] [Ollama](https://ollama.ai)
|
939
|
+
- [x] [01.AI Yi](https://01.ai)
|
940
|
+
- [x] [LMSYS Vicuna](https://github.com/lm-sys/FastChat)
|
941
|
+
- [x] [Meta Llama](https://ai.meta.com/llama/)
|
942
|
+
- [x] [WizardLM](https://wizardlm.github.io)
|
943
|
+
- [x] [Open AI ChatGPT](https://openai.com/chatgpt)
|
944
|
+
|
945
|
+
01.AI Yi, LMSYS Vicuna, Meta Llama, and WizardLM are open-source models that are supported through [Ollama](https://ollama.ai).
|
946
|
+
|
598
947
|
## Docker
|
599
948
|
|
600
949
|
Clone the repository and copy the Docker Compose template:
|
@@ -607,16 +956,15 @@ cp docker-compose.example.yml docker-compose.yml
|
|
607
956
|
|
608
957
|
Set your provider credentials and choose your desired directory for the cartridges files:
|
609
958
|
|
610
|
-
### Cohere Command
|
959
|
+
### Cohere Command Container
|
611
960
|
|
612
961
|
```yaml
|
613
962
|
---
|
614
963
|
services:
|
615
964
|
nano-bots:
|
616
965
|
image: ruby:3.2.2-slim-bookworm
|
617
|
-
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.
|
966
|
+
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.0 && bash"
|
618
967
|
environment:
|
619
|
-
COHERE_API_ADDRESS: https://api.cohere.ai
|
620
968
|
COHERE_API_KEY: your-api-key
|
621
969
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
622
970
|
NANO_BOTS_END_USER: your-user
|
@@ -625,16 +973,32 @@ services:
|
|
625
973
|
- ./your-state-path:/root/.local/state/nano-bots
|
626
974
|
```
|
627
975
|
|
628
|
-
###
|
976
|
+
### Maritaca AI MariTalk Container
|
977
|
+
|
978
|
+
```yaml
|
979
|
+
---
|
980
|
+
services:
|
981
|
+
nano-bots:
|
982
|
+
image: ruby:3.2.2-slim-bookworm
|
983
|
+
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.0 && bash"
|
984
|
+
environment:
|
985
|
+
MARITACA_API_KEY: your-api-key
|
986
|
+
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
987
|
+
NANO_BOTS_END_USER: your-user
|
988
|
+
volumes:
|
989
|
+
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
|
990
|
+
- ./your-state-path:/root/.local/state/nano-bots
|
991
|
+
```
|
992
|
+
|
993
|
+
### Mistral AI Container
|
629
994
|
|
630
995
|
```yaml
|
631
996
|
---
|
632
997
|
services:
|
633
998
|
nano-bots:
|
634
999
|
image: ruby:3.2.2-slim-bookworm
|
635
|
-
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.
|
1000
|
+
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.0 && bash"
|
636
1001
|
environment:
|
637
|
-
MISTRAL_API_ADDRESS: https://api.mistral.ai
|
638
1002
|
MISTRAL_API_KEY: your-api-key
|
639
1003
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
640
1004
|
NANO_BOTS_END_USER: your-user
|
@@ -643,16 +1007,34 @@ services:
|
|
643
1007
|
- ./your-state-path:/root/.local/state/nano-bots
|
644
1008
|
```
|
645
1009
|
|
646
|
-
###
|
1010
|
+
### Ollama Container
|
1011
|
+
|
1012
|
+
Remember that your `localhost` is inaccessible from inside Docker. You need to either establish [inter-container networking](https://docs.docker.com/compose/networking/) or use the [host's address](https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host), depending on where the Ollama server is running.
|
647
1013
|
|
648
1014
|
```yaml
|
649
1015
|
---
|
650
1016
|
services:
|
651
1017
|
nano-bots:
|
652
1018
|
image: ruby:3.2.2-slim-bookworm
|
653
|
-
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.
|
1019
|
+
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.0 && bash"
|
1020
|
+
environment:
|
1021
|
+
OLLAMA_API_ADDRESS: http://host.docker.internal:11434
|
1022
|
+
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
1023
|
+
NANO_BOTS_END_USER: your-user
|
1024
|
+
volumes:
|
1025
|
+
- ./your-cartridges:/root/.local/share/nano-bots/cartridges
|
1026
|
+
- ./your-state-path:/root/.local/state/nano-bots
|
1027
|
+
```
|
1028
|
+
|
1029
|
+
### OpenAI ChatGPT Container
|
1030
|
+
|
1031
|
+
```yaml
|
1032
|
+
---
|
1033
|
+
services:
|
1034
|
+
nano-bots:
|
1035
|
+
image: ruby:3.2.2-slim-bookworm
|
1036
|
+
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.0 && bash"
|
654
1037
|
environment:
|
655
|
-
OPENAI_API_ADDRESS: https://api.openai.com
|
656
1038
|
OPENAI_API_KEY: your-access-token
|
657
1039
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
658
1040
|
NANO_BOTS_END_USER: your-user
|
@@ -661,16 +1043,16 @@ services:
|
|
661
1043
|
- ./your-state-path:/root/.local/state/nano-bots
|
662
1044
|
```
|
663
1045
|
|
664
|
-
### Google Gemini
|
1046
|
+
### Google Gemini Container
|
665
1047
|
|
666
|
-
#### Option 1: API Key (Generative Language API)
|
1048
|
+
#### Option 1: API Key (Generative Language API) Config
|
667
1049
|
|
668
1050
|
```yaml
|
669
1051
|
---
|
670
1052
|
services:
|
671
1053
|
nano-bots:
|
672
1054
|
image: ruby:3.2.2-slim-bookworm
|
673
|
-
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.
|
1055
|
+
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.0 && bash"
|
674
1056
|
environment:
|
675
1057
|
GOOGLE_API_KEY: your-api-key
|
676
1058
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -680,14 +1062,14 @@ services:
|
|
680
1062
|
- ./your-state-path:/root/.local/state/nano-bots
|
681
1063
|
```
|
682
1064
|
|
683
|
-
#### Option 2: Service Account Credentials File (Vertex AI API)
|
1065
|
+
#### Option 2: Service Account Credentials File (Vertex AI API) Config
|
684
1066
|
|
685
1067
|
```yaml
|
686
1068
|
---
|
687
1069
|
services:
|
688
1070
|
nano-bots:
|
689
1071
|
image: ruby:3.2.2-slim-bookworm
|
690
|
-
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.
|
1072
|
+
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.0 && bash"
|
691
1073
|
environment:
|
692
1074
|
GOOGLE_CREDENTIALS_FILE_PATH: /root/.config/google-credentials.json
|
693
1075
|
GOOGLE_REGION: us-east4
|
@@ -699,14 +1081,14 @@ services:
|
|
699
1081
|
- ./your-state-path:/root/.local/state/nano-bots
|
700
1082
|
```
|
701
1083
|
|
702
|
-
#### Option 3: Application Default Credentials (Vertex AI API)
|
1084
|
+
#### Option 3: Application Default Credentials (Vertex AI API) Config
|
703
1085
|
|
704
1086
|
```yaml
|
705
1087
|
---
|
706
1088
|
services:
|
707
1089
|
nano-bots:
|
708
1090
|
image: ruby:3.2.2-slim-bookworm
|
709
|
-
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.
|
1091
|
+
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.0 && bash"
|
710
1092
|
environment:
|
711
1093
|
GOOGLE_REGION: us-east4
|
712
1094
|
NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
|
@@ -716,7 +1098,7 @@ services:
|
|
716
1098
|
- ./your-state-path:/root/.local/state/nano-bots
|
717
1099
|
```
|
718
1100
|
|
719
|
-
#### Custom Project ID
|
1101
|
+
#### Custom Project ID Config
|
720
1102
|
If you need to manually set a Google Project ID:
|
721
1103
|
|
722
1104
|
```yaml
|
@@ -724,7 +1106,7 @@ environment:
|
|
724
1106
|
GOOGLE_PROJECT_ID=your-project-id
|
725
1107
|
```
|
726
1108
|
|
727
|
-
### Container
|
1109
|
+
### Running the Container
|
728
1110
|
|
729
1111
|
Enter the container:
|
730
1112
|
```sh
|
@@ -742,128 +1124,6 @@ nb assistant.yml - repl
|
|
742
1124
|
|
743
1125
|
You can exit the REPL by typing `exit`.
|
744
1126
|
|
745
|
-
## Security and Privacy
|
746
|
-
|
747
|
-
Each provider will have its own security and privacy policies (e.g. [OpenAI Policy](https://openai.com/policies/api-data-usage-policies)), so you must consult them to understand their implications.
|
748
|
-
|
749
|
-
### Cryptography
|
750
|
-
|
751
|
-
By default, all states stored in your local disk are encrypted.
|
752
|
-
|
753
|
-
To ensure that the encryption is secure, you need to define a password through the `NANO_BOTS_ENCRYPTION_PASSWORD` environment variable. Otherwise, although the content will be encrypted, anyone would be able to decrypt it without a password.
|
754
|
-
|
755
|
-
It's important to note that the content shared with providers, despite being transmitted over secure connections (e.g., [HTTPS](https://en.wikipedia.org/wiki/HTTPS)), will be readable by the provider. This is because providers need to operate on the data, which would not be possible if the content was encrypted beyond HTTPS. So, the data stored locally on your system is encrypted, which does not mean that what you share with providers will not be readable by them.
|
756
|
-
|
757
|
-
To ensure that your encryption and password are configured properly, you can run the following command:
|
758
|
-
```sh
|
759
|
-
nb security
|
760
|
-
```
|
761
|
-
|
762
|
-
Which should return:
|
763
|
-
```text
|
764
|
-
✅ Encryption is enabled and properly working.
|
765
|
-
This means that your data is stored in an encrypted format on your disk.
|
766
|
-
|
767
|
-
✅ A password is being used for the encrypted content.
|
768
|
-
This means that only those who possess the password can decrypt your data.
|
769
|
-
```
|
770
|
-
|
771
|
-
Alternatively, you can check it at runtime with:
|
772
|
-
```ruby
|
773
|
-
require 'nano-bots'
|
774
|
-
|
775
|
-
NanoBot.security.check
|
776
|
-
# => { encryption: true, password: true }
|
777
|
-
```
|
778
|
-
|
779
|
-
### End-user IDs
|
780
|
-
|
781
|
-
A common strategy for deploying Nano Bots to multiple users through APIs or automations is to assign a unique [end-user ID](https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids) for each user. This can be useful if any of your users violate the provider's policy due to abusive behavior. By providing the end-user ID, you can unravel that even though the activity originated from your API Key, the actions taken were not your own.
|
782
|
-
|
783
|
-
You can define custom end-user identifiers in the following way:
|
784
|
-
|
785
|
-
```ruby
|
786
|
-
NanoBot.new(environment: { NANO_BOTS_END_USER: 'custom-user-a' })
|
787
|
-
NanoBot.new(environment: { NANO_BOTS_END_USER: 'custom-user-b' })
|
788
|
-
```
|
789
|
-
|
790
|
-
Consider that you have the following end-user identifier in your environment:
|
791
|
-
```sh
|
792
|
-
NANO_BOTS_END_USER=your-name
|
793
|
-
```
|
794
|
-
|
795
|
-
Or a configuration in your Cartridge:
|
796
|
-
```yml
|
797
|
-
---
|
798
|
-
provider:
|
799
|
-
id: openai
|
800
|
-
settings:
|
801
|
-
user: your-name
|
802
|
-
```
|
803
|
-
|
804
|
-
The requests will be performed as follows:
|
805
|
-
|
806
|
-
```ruby
|
807
|
-
NanoBot.new(cartridge: '-')
|
808
|
-
# { user: 'your-name' }
|
809
|
-
|
810
|
-
NanoBot.new(cartridge: '-', environment: { NANO_BOTS_END_USER: 'custom-user-a' })
|
811
|
-
# { user: 'custom-user-a' }
|
812
|
-
|
813
|
-
NanoBot.new(cartridge: '-', environment: { NANO_BOTS_END_USER: 'custom-user-b' })
|
814
|
-
# { user: 'custom-user-b' }
|
815
|
-
```
|
816
|
-
|
817
|
-
Actually, to enhance privacy, neither your user nor your users' identifiers will be shared in this way. Instead, they will be encrypted before being shared with the provider:
|
818
|
-
|
819
|
-
```ruby
|
820
|
-
'your-name'
|
821
|
-
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA==
|
822
|
-
|
823
|
-
'custom-user-a'
|
824
|
-
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs=
|
825
|
-
|
826
|
-
'custom-user-b'
|
827
|
-
# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg=
|
828
|
-
```
|
829
|
-
|
830
|
-
In this manner, you possess identifiers if required, however, their actual content can only be decrypted by you via your secure password (`NANO_BOTS_ENCRYPTION_PASSWORD`).
|
831
|
-
|
832
|
-
### Decrypting
|
833
|
-
|
834
|
-
To decrypt your encrypted data, once you have properly configured your password, you can simply run:
|
835
|
-
|
836
|
-
```ruby
|
837
|
-
require 'nano-bots'
|
838
|
-
|
839
|
-
NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA==')
|
840
|
-
# your-name
|
841
|
-
|
842
|
-
NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs=')
|
843
|
-
# custom-user-a
|
844
|
-
|
845
|
-
NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg=')
|
846
|
-
# custom-user-b
|
847
|
-
```
|
848
|
-
|
849
|
-
If you lose your password, you lose your data. It is not possible to recover it at all. For real.
|
850
|
-
|
851
|
-
## Providers
|
852
|
-
|
853
|
-
Currently supported providers:
|
854
|
-
|
855
|
-
- [ ] [01.AI Yi](https://01.ai)
|
856
|
-
- [ ] [Anthropic Claude](https://www.anthropic.com)
|
857
|
-
- [x] [Cohere Command](https://docs.cohere.com/reference/about)
|
858
|
-
- [x] [Google Gemini](https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/gemini)
|
859
|
-
- [ ] [LMSYS Org FastChat Vicuna](https://github.com/lm-sys/FastChat)
|
860
|
-
- [ ] [Meta Llama](https://ai.meta.com/llama/)
|
861
|
-
- [x] [Mistral AI](https://docs.mistral.ai/api/)
|
862
|
-
- [x] [Open AI ChatGPT](https://platform.openai.com/docs/api-reference)
|
863
|
-
- [ ] [WizardLM](https://wizardlm.github.io)
|
864
|
-
|
865
|
-
Some providers offer APIs that are compatible with, for example, OpenAI, such as [FastChat](https://github.com/lm-sys/FastChat#openai-compatible-restful-apis--sdk). Therefore, it is highly probable that they will work just fine.
|
866
|
-
|
867
1127
|
## Development
|
868
1128
|
|
869
1129
|
```bash
|
@@ -872,6 +1132,9 @@ rubocop -A
|
|
872
1132
|
rspec
|
873
1133
|
|
874
1134
|
bundle exec ruby spec/tasks/run-all-models.rb
|
1135
|
+
|
1136
|
+
bundle exec ruby spec/tasks/run-model.rb spec/data/cartridges/models/openai/gpt-4-turbo.yml
|
1137
|
+
bundle exec ruby spec/tasks/run-model.rb spec/data/cartridges/models/openai/gpt-4-turbo.yml stream
|
875
1138
|
```
|
876
1139
|
|
877
1140
|
### Publish to RubyGems
|
@@ -881,5 +1144,5 @@ gem build nano-bots.gemspec
|
|
881
1144
|
|
882
1145
|
gem signin
|
883
1146
|
|
884
|
-
gem push nano-bots-2.
|
1147
|
+
gem push nano-bots-2.5.0.gem
|
885
1148
|
```
|