nano-bots 3.0.1 → 3.2.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: 41b143719bce07dca70e81c3117e2e2c4778f7c336e6e5932fec4334985f134c
4
- data.tar.gz: 3bca5d654a4bbd0b32aa6ee2285340d20ed1fad1d1e1ccfa28757ca87b2f88d1
3
+ metadata.gz: f6ee7d534a42c2e11bc5a66d81b4a3c6baad7bb9e72ceb8ac4ad4735ac2f9d78
4
+ data.tar.gz: 8cfaf1303ad1f65b4b50f99c860252c93d2817d6e0a5b3d3ee978d08397ebaa8
5
5
  SHA512:
6
- metadata.gz: cc3a6927771552a866057a374667a767875073451b952bcb15254b3f8b59647c929dd911924cbb6f6f7430d68d6bca206fac0697711cd312d69b466d635e7971
7
- data.tar.gz: 9d398668b9bca96cc19ccbd4c6a94cb559108a7fe972ec4b49e84f30cd2eb26e65b67c1e10e3c9d1082b1d2257b6342ee48d0471555c038bfcead622d5853bfb
6
+ metadata.gz: 114798cb6c752de8d01297c5a6359b25c7d80d6b63b07a5c47f5ed4d677c0454ee0848ba412251f6ef81db02efd3ce285d6aaa08908ff3143d27d80d84315d16
7
+ data.tar.gz: 6fcbd9a54554b23aff0767fe002e6435d2f09007bf7190c98179b6998512fa003898403a59f025e4c97204e6128877dde52dd48e17b986ab9b8cd1a568dc988f
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ gemspec
6
6
 
7
7
  group :test, :development do
8
8
  gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
9
- gem 'rspec', '~> 3.12'
10
- gem 'rubocop', '~> 1.59'
11
- gem 'rubocop-rspec', '~> 2.26', '>= 2.26.1'
9
+ gem 'rspec', '~> 3.13'
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,75 +1,92 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nano-bots (3.0.1)
4
+ nano-bots (3.2.0)
5
5
  babosa (~> 2.0)
6
- cohere-ai (~> 1.0, >= 1.0.2)
7
- concurrent-ruby (~> 1.2, >= 1.2.2)
8
- dotenv (~> 2.8, >= 2.8.1)
9
- gemini-ai (~> 3.1, >= 3.1.3)
10
- maritaca-ai (~> 1.0, >= 1.0.1)
11
- mistral-ai (~> 1.1, >= 1.1.2)
12
- ollama-ai (~> 1.0, >= 1.0.1)
6
+ cohere-ai (~> 1.1)
7
+ concurrent-ruby (~> 1.3, >= 1.3.3)
8
+ dotenv (~> 3.1, >= 3.1.2)
9
+ faraday (~> 2.9, >= 2.9.2)
10
+ faraday-typhoeus (~> 1.1)
11
+ gemini-ai (~> 4.0)
12
+ maritaca-ai (~> 1.2)
13
+ mistral-ai (~> 1.2)
14
+ ollama-ai (~> 1.2, >= 1.2.1)
13
15
  pry (~> 0.14.2)
14
16
  rainbow (~> 3.1, >= 3.1.1)
15
17
  rbnacl (~> 7.1, >= 7.1.1)
16
18
  redcarpet (~> 3.6)
17
- ruby-openai (~> 6.3, >= 6.3.1)
18
- sweet-moon (~> 0.0.7)
19
+ ruby-openai (~> 7.1)
20
+ sweet-moon (~> 1.0)
21
+ typhoeus (~> 1.4, >= 1.4.1)
19
22
 
20
23
  GEM
21
24
  remote: https://rubygems.org/
22
25
  specs:
23
- addressable (2.8.6)
24
- public_suffix (>= 2.0.2, < 6.0)
26
+ addressable (2.8.7)
27
+ public_suffix (>= 2.0.2, < 7.0)
25
28
  ast (2.4.2)
26
29
  babosa (2.0.0)
30
+ base64 (0.2.0)
27
31
  byebug (11.1.3)
28
32
  coderay (1.1.3)
29
- cohere-ai (1.0.2)
33
+ cohere-ai (1.1.0)
30
34
  faraday (~> 2.9)
31
- concurrent-ruby (1.2.2)
32
- diff-lcs (1.5.0)
33
- dotenv (2.8.1)
35
+ faraday-typhoeus (~> 1.1)
36
+ concurrent-ruby (1.3.3)
37
+ diff-lcs (1.5.1)
38
+ dotenv (3.1.2)
39
+ ethon (0.16.0)
40
+ ffi (>= 1.15.0)
34
41
  event_stream_parser (1.0.0)
35
- faraday (2.9.0)
42
+ faraday (2.9.2)
36
43
  faraday-net_http (>= 2.0, < 3.2)
37
44
  faraday-multipart (1.0.4)
38
45
  multipart-post (~> 2)
39
46
  faraday-net_http (3.1.0)
40
47
  net-http
41
- ffi (1.16.3)
42
- gemini-ai (3.1.3)
48
+ faraday-typhoeus (1.1.0)
49
+ faraday (~> 2.0)
50
+ typhoeus (~> 1.4)
51
+ ffi (1.17.0)
52
+ gemini-ai (4.0.0)
43
53
  event_stream_parser (~> 1.0)
44
54
  faraday (~> 2.9)
55
+ faraday-typhoeus (~> 1.1)
45
56
  googleauth (~> 1.8)
46
- google-cloud-env (2.1.0)
57
+ typhoeus (~> 1.4, >= 1.4.1)
58
+ google-cloud-env (2.1.1)
47
59
  faraday (>= 1.0, < 3.a)
48
- googleauth (1.9.1)
60
+ googleauth (1.11.0)
49
61
  faraday (>= 1.0, < 3.a)
50
62
  google-cloud-env (~> 2.1)
51
63
  jwt (>= 1.4, < 3.0)
52
64
  multi_json (~> 1.11)
53
65
  os (>= 0.9, < 2.0)
54
66
  signet (>= 0.16, < 2.a)
55
- json (2.7.1)
56
- jwt (2.7.1)
67
+ json (2.7.2)
68
+ jwt (2.8.2)
69
+ base64
57
70
  language_server-protocol (3.17.0.3)
58
- maritaca-ai (1.0.1)
71
+ maritaca-ai (1.2.0)
72
+ event_stream_parser (~> 1.0)
59
73
  faraday (~> 2.9)
60
- method_source (1.0.0)
61
- mistral-ai (1.1.2)
74
+ faraday-typhoeus (~> 1.1)
75
+ method_source (1.1.0)
76
+ mistral-ai (1.2.0)
62
77
  event_stream_parser (~> 1.0)
63
78
  faraday (~> 2.9)
79
+ faraday-typhoeus (~> 1.1)
64
80
  multi_json (1.15.0)
65
- multipart-post (2.3.0)
81
+ multipart-post (2.4.1)
66
82
  net-http (0.4.1)
67
83
  uri
68
- ollama-ai (1.0.1)
84
+ ollama-ai (1.2.1)
69
85
  faraday (~> 2.9)
86
+ faraday-typhoeus (~> 1.1)
70
87
  os (1.1.4)
71
- parallel (1.24.0)
72
- parser (3.3.0.3)
88
+ parallel (1.25.1)
89
+ parser (3.3.3.0)
73
90
  ast (~> 2.4.1)
74
91
  racc
75
92
  pry (0.14.2)
@@ -78,60 +95,58 @@ GEM
78
95
  pry-byebug (3.10.1)
79
96
  byebug (~> 11.0)
80
97
  pry (>= 0.13, < 0.15)
81
- public_suffix (5.0.4)
82
- racc (1.7.3)
98
+ public_suffix (6.0.0)
99
+ racc (1.8.0)
83
100
  rainbow (3.1.1)
84
101
  rbnacl (7.1.1)
85
102
  ffi
86
103
  redcarpet (3.6.0)
87
- regexp_parser (2.9.0)
88
- rexml (3.2.6)
89
- rspec (3.12.0)
90
- rspec-core (~> 3.12.0)
91
- rspec-expectations (~> 3.12.0)
92
- rspec-mocks (~> 3.12.0)
93
- rspec-core (3.12.2)
94
- rspec-support (~> 3.12.0)
95
- rspec-expectations (3.12.3)
104
+ regexp_parser (2.9.2)
105
+ rexml (3.3.0)
106
+ strscan
107
+ rspec (3.13.0)
108
+ rspec-core (~> 3.13.0)
109
+ rspec-expectations (~> 3.13.0)
110
+ rspec-mocks (~> 3.13.0)
111
+ rspec-core (3.13.0)
112
+ rspec-support (~> 3.13.0)
113
+ rspec-expectations (3.13.1)
96
114
  diff-lcs (>= 1.2.0, < 2.0)
97
- rspec-support (~> 3.12.0)
98
- rspec-mocks (3.12.6)
115
+ rspec-support (~> 3.13.0)
116
+ rspec-mocks (3.13.1)
99
117
  diff-lcs (>= 1.2.0, < 2.0)
100
- rspec-support (~> 3.12.0)
101
- rspec-support (3.12.1)
102
- rubocop (1.59.0)
118
+ rspec-support (~> 3.13.0)
119
+ rspec-support (3.13.1)
120
+ rubocop (1.64.1)
103
121
  json (~> 2.3)
104
122
  language_server-protocol (>= 3.17.0)
105
123
  parallel (~> 1.10)
106
- parser (>= 3.2.2.4)
124
+ parser (>= 3.3.0.2)
107
125
  rainbow (>= 2.2.2, < 4.0)
108
126
  regexp_parser (>= 1.8, < 3.0)
109
127
  rexml (>= 3.2.5, < 4.0)
110
- rubocop-ast (>= 1.30.0, < 2.0)
128
+ rubocop-ast (>= 1.31.1, < 2.0)
111
129
  ruby-progressbar (~> 1.7)
112
130
  unicode-display_width (>= 2.4.0, < 3.0)
113
- rubocop-ast (1.30.0)
114
- parser (>= 3.2.1.0)
115
- rubocop-capybara (2.20.0)
116
- rubocop (~> 1.41)
117
- rubocop-factory_bot (2.25.1)
118
- rubocop (~> 1.41)
119
- rubocop-rspec (2.26.1)
120
- rubocop (~> 1.40)
121
- rubocop-capybara (~> 2.17)
122
- rubocop-factory_bot (~> 2.22)
123
- ruby-openai (6.3.1)
131
+ rubocop-ast (1.31.3)
132
+ parser (>= 3.3.1.0)
133
+ rubocop-rspec (3.0.1)
134
+ rubocop (~> 1.61)
135
+ ruby-openai (7.1.0)
124
136
  event_stream_parser (>= 0.3.0, < 2.0.0)
125
137
  faraday (>= 1)
126
138
  faraday-multipart (>= 1)
127
139
  ruby-progressbar (1.13.0)
128
- signet (0.18.0)
140
+ signet (0.19.0)
129
141
  addressable (~> 2.8)
130
142
  faraday (>= 0.17.5, < 3.a)
131
143
  jwt (>= 1.5, < 3.0)
132
144
  multi_json (~> 1.10)
133
- sweet-moon (0.0.7)
134
- ffi (~> 1.15, >= 1.15.5)
145
+ strscan (3.1.0)
146
+ sweet-moon (1.0.0)
147
+ ffi (~> 1.17)
148
+ typhoeus (1.4.1)
149
+ ethon (>= 0.9.0)
135
150
  unicode-display_width (2.5.0)
136
151
  uri (0.13.0)
137
152
 
@@ -141,9 +156,9 @@ PLATFORMS
141
156
  DEPENDENCIES
142
157
  nano-bots!
143
158
  pry-byebug (~> 3.10, >= 3.10.1)
144
- rspec (~> 3.12)
145
- rubocop (~> 1.59)
146
- rubocop-rspec (~> 2.26, >= 2.26.1)
159
+ rspec (~> 3.13)
160
+ rubocop (~> 1.64, >= 1.64.1)
161
+ rubocop-rspec (~> 3.0, >= 3.0.1)
147
162
 
148
163
  BUNDLED WITH
149
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.0.1
12
+ gem install nano-bots -v 3.2.0
13
13
  ```
14
14
 
15
15
  ```bash
@@ -50,7 +50,7 @@ provider:
50
50
  access-token: ENV/OPENAI_API_KEY
51
51
  settings:
52
52
  user: ENV/NANO_BOTS_END_USER
53
- model: gpt-4-1106-preview
53
+ model: gpt-4o
54
54
  ```
55
55
 
56
56
  ```bash
@@ -59,7 +59,7 @@ nb gpt.yml - eval "hi"
59
59
  ```
60
60
 
61
61
  ```ruby
62
- gem 'nano-bots', '~> 3.0.1'
62
+ gem 'nano-bots', '~> 3.2.0'
63
63
  ```
64
64
 
65
65
  ```ruby
@@ -76,43 +76,43 @@ end
76
76
 
77
77
  - [TL;DR and Quick Start](#tldr-and-quick-start)
78
78
  - [Usage](#usage)
79
- - [Command Line](#command-line)
80
- - [Debugging](#debugging)
81
- - [Library](#library)
79
+ - [Command Line](#command-line)
80
+ - [Debugging](#debugging)
81
+ - [Library](#library)
82
82
  - [Setup](#setup)
83
- - [Cohere Command](#cohere-command)
84
- - [Maritaca AI MariTalk](#maritaca-ai-maritalk)
85
- - [Mistral AI](#mistral-ai)
86
- - [Ollama](#ollama)
87
- - [OpenAI ChatGPT](#openai-chatgpt)
88
- - [Google Gemini](#google-gemini)
89
- - [Option 1: API Key (Generative Language API)](#option-1-api-key-generative-language-api)
90
- - [Option 2: Service Account Credentials File (Vertex AI API)](#option-2-service-account-credentials-file-vertex-ai-api)
91
- - [Option 3: Application Default Credentials (Vertex AI API)](#option-3-application-default-credentials-vertex-ai-api)
92
- - [Custom Project ID](#custom-project-id)
83
+ - [Cohere Command](#cohere-command)
84
+ - [Maritaca AI MariTalk](#maritaca-ai-maritalk)
85
+ - [Mistral AI](#mistral-ai)
86
+ - [Ollama](#ollama)
87
+ - [OpenAI ChatGPT](#openai-chatgpt)
88
+ - [Google Gemini](#google-gemini)
89
+ - [Option 1: API Key (Generative Language API)](#option-1-api-key-generative-language-api)
90
+ - [Option 2: Service Account Credentials File (Vertex AI API)](#option-2-service-account-credentials-file-vertex-ai-api)
91
+ - [Option 3: Application Default Credentials (Vertex AI API)](#option-3-application-default-credentials-vertex-ai-api)
92
+ - [Custom Project ID](#custom-project-id)
93
93
  - [Cartridges](#cartridges)
94
- - [Tools (Functions)](#tools-functions)
95
- - [Experimental Clojure Support](#experimental-clojure-support)
96
- - [Marketplace](#marketplace)
94
+ - [Tools (Functions)](#tools-functions)
95
+ - [Experimental Clojure Support](#experimental-clojure-support)
96
+ - [Marketplace](#marketplace)
97
97
  - [Security and Privacy](#security-and-privacy)
98
- - [Cryptography](#cryptography)
99
- - [End-user IDs](#end-user-ids)
100
- - [Decrypting](#decrypting)
98
+ - [Cryptography](#cryptography)
99
+ - [End-user IDs](#end-user-ids)
100
+ - [Decrypting](#decrypting)
101
101
  - [Supported Providers](#supported-providers)
102
102
  - [Docker](#docker)
103
- - [Cohere Command Container](#cohere-command-container)
104
- - [Maritaca AI MariTalk Container](#maritaca-ai-maritalk-container)
105
- - [Mistral AI Container](#mistral-ai-container)
106
- - [Ollama Container](#ollama-container)
107
- - [OpenAI ChatGPT Container](#openai-chatgpt-container)
108
- - [Google Gemini Container](#google-gemini-container)
109
- - [Option 1: API Key (Generative Language API) Config](#option-1-api-key-generative-language-api-config)
110
- - [Option 2: Service Account Credentials File (Vertex AI API) Config](#option-2-service-account-credentials-file-vertex-ai-api-config)
111
- - [Option 3: Application Default Credentials (Vertex AI API) Config](#option-3-application-default-credentials-vertex-ai-api-config)
112
- - [Custom Project ID Config](#custom-project-id-config)
113
- - [Running the Container](#running-the-container)
103
+ - [Cohere Command Container](#cohere-command-container)
104
+ - [Maritaca AI MariTalk Container](#maritaca-ai-maritalk-container)
105
+ - [Mistral AI Container](#mistral-ai-container)
106
+ - [Ollama Container](#ollama-container)
107
+ - [OpenAI ChatGPT Container](#openai-chatgpt-container)
108
+ - [Google Gemini Container](#google-gemini-container)
109
+ - [Option 1: API Key (Generative Language API) Config](#option-1-api-key-generative-language-api-config)
110
+ - [Option 2: Service Account Credentials File (Vertex AI API) Config](#option-2-service-account-credentials-file-vertex-ai-api-config)
111
+ - [Option 3: Application Default Credentials (Vertex AI API) Config](#option-3-application-default-credentials-vertex-ai-api-config)
112
+ - [Custom Project ID Config](#custom-project-id-config)
113
+ - [Running the Container](#running-the-container)
114
114
  - [Development](#development)
115
- - [Publish to RubyGems](#publish-to-rubygems)
115
+ - [Publish to RubyGems](#publish-to-rubygems)
116
116
 
117
117
  ## Usage
118
118
 
@@ -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.0.1
253
+ gem install nano-bots -v 3.2.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.0.1'
259
+ gem 'nano-bots', '~> 3.2.0'
260
260
  ```
261
261
 
262
262
  ```sh
@@ -372,7 +372,7 @@ provider:
372
372
  credentials:
373
373
  api-key: ENV/MARITACA_API_KEY
374
374
  settings:
375
- model: maritalk
375
+ model: sabia-2-medium
376
376
  ```
377
377
 
378
378
  Read the [full specification](https://spec.nbots.io/#/README?id=mistral-ai) for Mistral AI.
@@ -424,7 +424,7 @@ provider:
424
424
  credentials:
425
425
  api-key: ENV/MISTRAL_API_KEY
426
426
  settings:
427
- model: mistral-medium
427
+ model: mistral-medium-latest
428
428
  ```
429
429
 
430
430
  Read the [full specification](https://spec.nbots.io/#/README?id=mistral-ai) for Mistral AI.
@@ -476,7 +476,7 @@ provider:
476
476
  credentials:
477
477
  address: ENV/OLLAMA_API_ADDRESS
478
478
  settings:
479
- model: llama2
479
+ model: llama3
480
480
  ```
481
481
 
482
482
  Read the [full specification](https://spec.nbots.io/#/README?id=ollama) for Ollama.
@@ -529,7 +529,7 @@ provider:
529
529
  access-token: ENV/OPENAI_API_KEY
530
530
  settings:
531
531
  user: ENV/NANO_BOTS_END_USER
532
- model: gpt-4-1106-preview
532
+ model: gpt-4o
533
533
  ```
534
534
 
535
535
  Read the [full specification](https://spec.nbots.io/#/README?id=openai-chatgpt) for OpenAI ChatGPT.
@@ -758,7 +758,7 @@ provider:
758
758
  access-token: ENV/OPENAI_API_KEY
759
759
  settings:
760
760
  user: ENV/NANO_BOTS_END_USER
761
- model: gpt-4-1106-preview
761
+ model: gpt-4o
762
762
  ```
763
763
 
764
764
  ### Tools (Functions)
@@ -786,7 +786,7 @@ The randomly generated number is 59.
786
786
 
787
787
  🤖> |
788
788
  ```
789
- 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.
789
+ 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-4o`, 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.
790
790
 
791
791
  Check the [Nano Bots specification](https://spec.nbots.io/#/README?id=tools-functions-2) to learn more about Tools (Functions).
792
792
 
@@ -945,10 +945,10 @@ If you lose your password, you lose your data. It is not possible to recover it
945
945
  - [x] [Maritaca AI MariTalk](https://www.maritaca.ai)
946
946
  - [x] [Mistral AI](https://mistral.ai)
947
947
  - [x] [Ollama](https://ollama.ai)
948
- - [x] [01.AI Yi](https://01.ai)
949
- - [x] [LMSYS Vicuna](https://github.com/lm-sys/FastChat)
950
- - [x] [Meta Llama](https://ai.meta.com/llama/)
951
- - [x] [WizardLM](https://wizardlm.github.io)
948
+ - [x] [01.AI Yi](https://01.ai)
949
+ - [x] [LMSYS Vicuna](https://github.com/lm-sys/FastChat)
950
+ - [x] [Meta Llama](https://ai.meta.com/llama/)
951
+ - [x] [WizardLM](https://wizardlm.github.io)
952
952
  - [x] [Open AI ChatGPT](https://openai.com/chatgpt)
953
953
 
954
954
  01.AI Yi, LMSYS Vicuna, Meta Llama, and WizardLM are open-source models that are supported through [Ollama](https://ollama.ai).
@@ -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.2.2-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.0.1 && bash"
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.2.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.2.2-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.0.1 && bash"
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.2.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.2.2-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.0.1 && bash"
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.2.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.2.2-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.0.1 && bash"
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.2.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.2.2-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.0.1 && bash"
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.2.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.2.2-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.0.1 && bash"
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.2.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.2.2-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.0.1 && bash"
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.2.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.2.2-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.0.1 && bash"
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.2.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.0.1.gem
1164
+ gem push nano-bots-3.2.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)
@@ -66,10 +68,7 @@ module NanoBot
66
68
  end
67
69
  end
68
70
 
69
- # TODO: Does Gemini have system messages?
70
- %i[backdrop directive].each do |key|
71
- next unless input[:behavior][key]
72
-
71
+ if input[:behavior][:backdrop]
73
72
  messages.prepend(
74
73
  { role: 'model',
75
74
  parts: { text: 'Understood.' },
@@ -78,13 +77,27 @@ module NanoBot
78
77
 
79
78
  messages.prepend(
80
79
  { role: 'user',
81
- parts: { text: input[:behavior][key] },
80
+ parts: { text: input[:behavior][:backdrop] },
82
81
  _meta: { at: Time.now } }
83
82
  )
84
83
  end
85
84
 
86
85
  payload = { contents: messages, generationConfig: { candidateCount: 1 } }
87
86
 
87
+ if input[:behavior][:directive] && @service == 'vertex-ai-api'
88
+ payload[:system_instruction] = {
89
+ role: 'user',
90
+ parts: { text: input[:behavior][:directive] }
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
+ )
99
+ end
100
+
88
101
  if @settings
89
102
  SETTINGS.each_key do |key|
90
103
  SETTINGS[key].each do |sub_key|
@@ -120,13 +133,13 @@ module NanoBot
120
133
  # TODO: How to better handle finishReason == 'OTHER'?
121
134
  return if event.dig('candidates', 0, 'finishReason') == 'OTHER'
122
135
 
123
- partial_content = event.dig('candidates', 0, 'content', 'parts').filter do |part|
136
+ partial_content = event.dig('candidates', 0, 'content', 'parts')&.filter do |part|
124
137
  part.key?('text')
125
- end.map { |part| part['text'] }.join
138
+ end&.map { |part| part['text'] }&.join || ''
126
139
 
127
- partial_tools = event.dig('candidates', 0, 'content', 'parts').filter do |part|
140
+ partial_tools = event.dig('candidates', 0, 'content', 'parts')&.filter do |part|
128
141
  part.key?('functionCall')
129
- end
142
+ end || []
130
143
 
131
144
  tools.concat(partial_tools) if partial_tools.size.positive?
132
145
 
@@ -138,10 +151,9 @@ module NanoBot
138
151
  )
139
152
  end
140
153
 
141
- if event.dig('candidates', 0, 'finishReason')
142
- # TODO: This does not have the same behavior as OpenAI, so you should
143
- # not use it as a reference for the end of the streaming.
144
- # 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}"
145
157
  end
146
158
  end
147
159
 
@@ -193,9 +205,13 @@ module NanoBot
193
205
  end
194
206
 
195
207
  content = result.map do |answer|
196
- answer.dig('candidates', 0, 'content', 'parts').filter do |part|
197
- part.key?('text')
198
- end.map { |part| part['text'] }.join
208
+ parts = answer.dig('candidates', 0, 'content', 'parts')
209
+
210
+ if parts
211
+ parts.filter { |part| part.key?('text') }.map { |part| part['text'] }.join
212
+ else
213
+ ''
214
+ end
199
215
  end.join
200
216
 
201
217
  feedback.call(
@@ -15,7 +15,7 @@ module NanoBot
15
15
  attr_reader :settings
16
16
 
17
17
  CHAT_SETTINGS = %i[
18
- max_tokens model do_sample temperature top_p repetition_penalty stopping_tokens
18
+ max_tokens model stream do_sample temperature top_p repetition_penalty stopping_tokens
19
19
  ].freeze
20
20
 
21
21
  def initialize(options, settings, credentials, _environment)
@@ -27,13 +27,14 @@ module NanoBot
27
27
  {}
28
28
  end
29
29
 
30
- unless maritaca_options.key?(:stream)
31
- maritaca_options[:stream] = Logic::Helpers::Hash.fetch(
32
- Logic::Cartridge::Default.instance.values, %i[provider options stream]
30
+ unless @settings.key?(:stream)
31
+ @settings = Marshal.load(Marshal.dump(@settings))
32
+ @settings[:stream] = Logic::Helpers::Hash.fetch(
33
+ Logic::Cartridge::Default.instance.values, %i[provider settings stream]
33
34
  )
34
35
  end
35
36
 
36
- maritaca_options[:server_sent_events] = maritaca_options.delete(:stream)
37
+ maritaca_options[:server_sent_events] = @settings[:stream]
37
38
 
38
39
  @client = ::Maritaca.new(
39
40
  credentials: credentials.transform_keys { |key| key.to_s.gsub('-', '_').to_sym },
@@ -71,7 +72,7 @@ module NanoBot
71
72
  content = ''
72
73
 
73
74
  stream_call_back = proc do |event, _raw|
74
- partial_content = event['answer']
75
+ partial_content = event['text']
75
76
 
76
77
  if partial_content
77
78
  content += partial_content