nano-bots 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/README.md +180 -11
- data/components/provider.rb +1 -1
- data/components/providers/base.rb +1 -1
- data/components/providers/google.rb +34 -28
- data/components/providers/openai.rb +4 -3
- data/docker-compose.example.yml +10 -1
- data/nano-bots.gemspec +1 -1
- data/ports/dsl/nano-bots.rb +4 -0
- data/static/gem.rb +2 -1
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1cfd38c6461b14483fc0478d31b73ed3e4890f1c534b3c7a4ead6f9412466674
         | 
| 4 | 
            +
              data.tar.gz: 11f3e82a196f8b27ac1313ee2e653c93521ed7c081ef68bacf15015c8392db34
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b6a7dbb69afead0f718e2b3c688edb35dfce6f68f138ddd5168c9d72b5eaaedbdcf973b99be873709c4f6b63f71a3f35c9a5d06a0ca4efd32800c52b6de3ccc0
         | 
| 7 | 
            +
              data.tar.gz: 24bf5641942d008e7afbad2ae37fec1a4f37d28c68b3ab0ab3f560849f8b427a246f5c9c29ddc9221852bbb3cd5e86bb958c9fbff392a0cca0fab81d9c3b0171
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                nano-bots (1. | 
| 4 | 
            +
                nano-bots (2.1.0)
         | 
| 5 5 | 
             
                  babosa (~> 2.0)
         | 
| 6 6 | 
             
                  concurrent-ruby (~> 1.2, >= 1.2.2)
         | 
| 7 7 | 
             
                  dotenv (~> 2.8, >= 2.8.1)
         | 
| 8 | 
            -
                  gemini-ai (~> 1 | 
| 8 | 
            +
                  gemini-ai (~> 2.1)
         | 
| 9 9 | 
             
                  pry (~> 0.14.2)
         | 
| 10 10 | 
             
                  rainbow (~> 3.1, >= 3.1.1)
         | 
| 11 11 | 
             
                  rbnacl (~> 7.1, >= 7.1.1)
         | 
| @@ -34,7 +34,7 @@ GEM | |
| 34 34 | 
             
                  multipart-post (~> 2)
         | 
| 35 35 | 
             
                faraday-net_http (3.0.2)
         | 
| 36 36 | 
             
                ffi (1.16.3)
         | 
| 37 | 
            -
                gemini-ai (1.0 | 
| 37 | 
            +
                gemini-ai (2.1.0)
         | 
| 38 38 | 
             
                  event_stream_parser (~> 1.0)
         | 
| 39 39 | 
             
                  faraday (~> 2.7, >= 2.7.12)
         | 
| 40 40 | 
             
                  googleauth (~> 1.9, >= 1.9.1)
         | 
| @@ -54,7 +54,7 @@ GEM | |
| 54 54 | 
             
                multi_json (1.15.0)
         | 
| 55 55 | 
             
                multipart-post (2.3.0)
         | 
| 56 56 | 
             
                os (1.1.4)
         | 
| 57 | 
            -
                parallel (1. | 
| 57 | 
            +
                parallel (1.24.0)
         | 
| 58 58 | 
             
                parser (3.2.2.4)
         | 
| 59 59 | 
             
                  ast (~> 2.4.1)
         | 
| 60 60 | 
             
                  racc
         | 
| @@ -131,4 +131,4 @@ DEPENDENCIES | |
| 131 131 | 
             
              rubocop-rspec (~> 2.25)
         | 
| 132 132 |  | 
| 133 133 | 
             
            BUNDLED WITH
         | 
| 134 | 
            -
               2.4. | 
| 134 | 
            +
               2.4.22
         | 
    
        data/README.md
    CHANGED
    
    | @@ -36,13 +36,13 @@ https://user-images.githubusercontent.com/113217272/238141567-c58a240c-7b67-4b3b | |
| 36 36 | 
             
            For a system usage:
         | 
| 37 37 |  | 
| 38 38 | 
             
            ```sh
         | 
| 39 | 
            -
            gem install nano-bots -v 1. | 
| 39 | 
            +
            gem install nano-bots -v 2.1.0
         | 
| 40 40 | 
             
            ```
         | 
| 41 41 |  | 
| 42 42 | 
             
            To use it in a project, add it to your `Gemfile`:
         | 
| 43 43 |  | 
| 44 44 | 
             
            ```ruby
         | 
| 45 | 
            -
            gem 'nano-bots', '~> 1. | 
| 45 | 
            +
            gem 'nano-bots', '~> 2.1.0'
         | 
| 46 46 | 
             
            ```
         | 
| 47 47 |  | 
| 48 48 | 
             
            ```sh
         | 
| @@ -81,9 +81,34 @@ NANO_BOTS_END_USER=your-user | |
| 81 81 |  | 
| 82 82 | 
             
            Click [here](https://github.com/gbaptista/gemini-ai#credentials) to learn how to obtain your credentials.
         | 
| 83 83 |  | 
| 84 | 
            +
            #### Option 1: API Key (Generative Language API)
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            ```sh
         | 
| 87 | 
            +
            export GOOGLE_API_KEY=your-api-key
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
         | 
| 90 | 
            +
            export NANO_BOTS_END_USER=your-user
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            # export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
         | 
| 93 | 
            +
            # export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
         | 
| 94 | 
            +
            ```
         | 
| 95 | 
            +
             | 
| 96 | 
            +
            Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
         | 
| 97 | 
            +
             | 
| 98 | 
            +
            ```sh
         | 
| 99 | 
            +
            GOOGLE_API_KEY=your-api-key
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
         | 
| 102 | 
            +
            NANO_BOTS_END_USER=your-user
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            # NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
         | 
| 105 | 
            +
            # NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
         | 
| 106 | 
            +
            ```
         | 
| 107 | 
            +
             | 
| 108 | 
            +
            #### Option 2: Service Account Credentials File (Vertex AI API)
         | 
| 109 | 
            +
             | 
| 84 110 | 
             
            ```sh
         | 
| 85 111 | 
             
            export GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
         | 
| 86 | 
            -
            export GOOGLE_PROJECT_ID=your-project-id
         | 
| 87 112 | 
             
            export GOOGLE_REGION=us-east4
         | 
| 88 113 |  | 
| 89 114 | 
             
            export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
         | 
| @@ -97,7 +122,6 @@ Alternatively, if your current directory has a `.env` file with the environment | |
| 97 122 |  | 
| 98 123 | 
             
            ```sh
         | 
| 99 124 | 
             
            GOOGLE_CREDENTIALS_FILE_PATH=google-credentials.json
         | 
| 100 | 
            -
            GOOGLE_PROJECT_ID=your-project-id
         | 
| 101 125 | 
             
            GOOGLE_REGION=us-east4
         | 
| 102 126 |  | 
| 103 127 | 
             
            NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
         | 
| @@ -107,6 +131,44 @@ NANO_BOTS_END_USER=your-user | |
| 107 131 | 
             
            # NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
         | 
| 108 132 | 
             
            ```
         | 
| 109 133 |  | 
| 134 | 
            +
            #### Option 3: Application Default Credentials (Vertex AI API)
         | 
| 135 | 
            +
             | 
| 136 | 
            +
            ```sh
         | 
| 137 | 
            +
            export GOOGLE_REGION=us-east4
         | 
| 138 | 
            +
             | 
| 139 | 
            +
            export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
         | 
| 140 | 
            +
            export NANO_BOTS_END_USER=your-user
         | 
| 141 | 
            +
             | 
| 142 | 
            +
            # export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
         | 
| 143 | 
            +
            # export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
         | 
| 144 | 
            +
            ```
         | 
| 145 | 
            +
             | 
| 146 | 
            +
            Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
         | 
| 147 | 
            +
             | 
| 148 | 
            +
            ```sh
         | 
| 149 | 
            +
            GOOGLE_REGION=us-east4
         | 
| 150 | 
            +
             | 
| 151 | 
            +
            NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE
         | 
| 152 | 
            +
            NANO_BOTS_END_USER=your-user
         | 
| 153 | 
            +
             | 
| 154 | 
            +
            # NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots
         | 
| 155 | 
            +
            # NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges
         | 
| 156 | 
            +
            ```
         | 
| 157 | 
            +
             | 
| 158 | 
            +
            #### Custom Project ID
         | 
| 159 | 
            +
             | 
| 160 | 
            +
            If you need to manually set a Google Project ID:
         | 
| 161 | 
            +
             | 
| 162 | 
            +
            ```sh
         | 
| 163 | 
            +
            export GOOGLE_PROJECT_ID=your-project-id
         | 
| 164 | 
            +
            ```
         | 
| 165 | 
            +
             | 
| 166 | 
            +
            Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded:
         | 
| 167 | 
            +
             | 
| 168 | 
            +
            ```sh
         | 
| 169 | 
            +
            GOOGLE_PROJECT_ID=your-project-id
         | 
| 170 | 
            +
            ```
         | 
| 171 | 
            +
             | 
| 110 172 | 
             
            ## Docker
         | 
| 111 173 |  | 
| 112 174 | 
             
            Clone the repository and copy the Docker Compose template:
         | 
| @@ -126,7 +188,7 @@ Set your provider credentials and choose your desired directory for the cartridg | |
| 126 188 | 
             
            services:
         | 
| 127 189 | 
             
              nano-bots:
         | 
| 128 190 | 
             
                image: ruby:3.2.2-slim-bookworm
         | 
| 129 | 
            -
                command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 1. | 
| 191 | 
            +
                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.1.0 && bash"
         | 
| 130 192 | 
             
                environment:
         | 
| 131 193 | 
             
                  OPENAI_API_ADDRESS: https://api.openai.com
         | 
| 132 194 | 
             
                  OPENAI_API_KEY: your-access-token
         | 
| @@ -139,15 +201,33 @@ services: | |
| 139 201 |  | 
| 140 202 | 
             
            ### Google Gemini
         | 
| 141 203 |  | 
| 204 | 
            +
            #### Option 1: API Key (Generative Language API)
         | 
| 205 | 
            +
             | 
| 206 | 
            +
            ```yaml
         | 
| 207 | 
            +
            ---
         | 
| 208 | 
            +
            services:
         | 
| 209 | 
            +
              nano-bots:
         | 
| 210 | 
            +
                image: ruby:3.2.2-slim-bookworm
         | 
| 211 | 
            +
                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.1.0 && bash"
         | 
| 212 | 
            +
                environment:
         | 
| 213 | 
            +
                  GOOGLE_API_KEY: your-api-key
         | 
| 214 | 
            +
                  NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
         | 
| 215 | 
            +
                  NANO_BOTS_END_USER: your-user
         | 
| 216 | 
            +
                volumes:
         | 
| 217 | 
            +
                  - ./your-cartridges:/root/.local/share/nano-bots/cartridges
         | 
| 218 | 
            +
                  - ./your-state-path:/root/.local/state/nano-bots
         | 
| 219 | 
            +
            ```
         | 
| 220 | 
            +
             | 
| 221 | 
            +
            #### Option 2: Service Account Credentials File (Vertex AI API)
         | 
| 222 | 
            +
             | 
| 142 223 | 
             
            ```yaml
         | 
| 143 224 | 
             
            ---
         | 
| 144 225 | 
             
            services:
         | 
| 145 226 | 
             
              nano-bots:
         | 
| 146 227 | 
             
                image: ruby:3.2.2-slim-bookworm
         | 
| 147 | 
            -
                command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 1. | 
| 228 | 
            +
                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.1.0 && bash"
         | 
| 148 229 | 
             
                environment:
         | 
| 149 230 | 
             
                  GOOGLE_CREDENTIALS_FILE_PATH: /root/.config/google-credentials.json
         | 
| 150 | 
            -
                  GOOGLE_PROJECT_ID: your-project-id
         | 
| 151 231 | 
             
                  GOOGLE_REGION: us-east4
         | 
| 152 232 | 
             
                  NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
         | 
| 153 233 | 
             
                  NANO_BOTS_END_USER: your-user
         | 
| @@ -157,6 +237,31 @@ services: | |
| 157 237 | 
             
                  - ./your-state-path:/root/.local/state/nano-bots
         | 
| 158 238 | 
             
            ```
         | 
| 159 239 |  | 
| 240 | 
            +
            #### Option 3: Application Default Credentials (Vertex AI API)
         | 
| 241 | 
            +
             | 
| 242 | 
            +
            ```yaml
         | 
| 243 | 
            +
            ---
         | 
| 244 | 
            +
            services:
         | 
| 245 | 
            +
              nano-bots:
         | 
| 246 | 
            +
                image: ruby:3.2.2-slim-bookworm
         | 
| 247 | 
            +
                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.1.0 && bash"
         | 
| 248 | 
            +
                environment:
         | 
| 249 | 
            +
                  GOOGLE_REGION: us-east4
         | 
| 250 | 
            +
                  NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
         | 
| 251 | 
            +
                  NANO_BOTS_END_USER: your-user
         | 
| 252 | 
            +
                volumes:
         | 
| 253 | 
            +
                  - ./your-cartridges:/root/.local/share/nano-bots/cartridges
         | 
| 254 | 
            +
                  - ./your-state-path:/root/.local/state/nano-bots
         | 
| 255 | 
            +
            ```
         | 
| 256 | 
            +
             | 
| 257 | 
            +
            #### Custom Project ID
         | 
| 258 | 
            +
            If you need to manually set a Google Project ID:
         | 
| 259 | 
            +
             | 
| 260 | 
            +
            ```yaml
         | 
| 261 | 
            +
            environment:
         | 
| 262 | 
            +
              GOOGLE_PROJECT_ID=your-project-id
         | 
| 263 | 
            +
            ```
         | 
| 264 | 
            +
             | 
| 160 265 | 
             
            ### Container
         | 
| 161 266 |  | 
| 162 267 | 
             
            Enter the container:
         | 
| @@ -346,6 +451,8 @@ provider: | |
| 346 451 |  | 
| 347 452 | 
             
            Read the [full specification](https://spec.nbots.io/#/README?id=google-gemini) for Google Gemini.
         | 
| 348 453 |  | 
| 454 | 
            +
            #### Option 1: API Key (Generative Language API)
         | 
| 455 | 
            +
             | 
| 349 456 | 
             
            ```yaml
         | 
| 350 457 | 
             
            ---
         | 
| 351 458 | 
             
            meta:
         | 
| @@ -363,13 +470,75 @@ behaviors: | |
| 363 470 | 
             
            provider:
         | 
| 364 471 | 
             
              id: google
         | 
| 365 472 | 
             
              credentials:
         | 
| 366 | 
            -
                 | 
| 473 | 
            +
                service: generative-language-api
         | 
| 474 | 
            +
                api-key: ENV/GOOGLE_API_KEY
         | 
| 475 | 
            +
              options:
         | 
| 476 | 
            +
                model: gemini-pro
         | 
| 477 | 
            +
            ```
         | 
| 478 | 
            +
             | 
| 479 | 
            +
            #### Option 2: Service Account Credentials File (Vertex AI API)
         | 
| 480 | 
            +
             | 
| 481 | 
            +
            ```yaml
         | 
| 482 | 
            +
            ---
         | 
| 483 | 
            +
            meta:
         | 
| 484 | 
            +
              symbol: 🤖
         | 
| 485 | 
            +
              name: Nano Bot Name
         | 
| 486 | 
            +
              author: Your Name
         | 
| 487 | 
            +
              version: 1.0.0
         | 
| 488 | 
            +
              license: CC0-1.0
         | 
| 489 | 
            +
              description: A helpful assistant.
         | 
| 490 | 
            +
             | 
| 491 | 
            +
            behaviors:
         | 
| 492 | 
            +
              interaction:
         | 
| 493 | 
            +
                directive: You are a helpful assistant.
         | 
| 494 | 
            +
             | 
| 495 | 
            +
            provider:
         | 
| 496 | 
            +
              id: google
         | 
| 497 | 
            +
              credentials:
         | 
| 498 | 
            +
                service: vertex-ai-api
         | 
| 367 499 | 
             
                file-path: ENV/GOOGLE_CREDENTIALS_FILE_PATH
         | 
| 368 500 | 
             
                region: ENV/GOOGLE_REGION
         | 
| 369 501 | 
             
              options:
         | 
| 370 502 | 
             
                model: gemini-pro
         | 
| 371 503 | 
             
            ```
         | 
| 372 504 |  | 
| 505 | 
            +
            #### Option 3: Application Default Credentials (Vertex AI API)
         | 
| 506 | 
            +
             | 
| 507 | 
            +
            ```yaml
         | 
| 508 | 
            +
            ---
         | 
| 509 | 
            +
            meta:
         | 
| 510 | 
            +
              symbol: 🤖
         | 
| 511 | 
            +
              name: Nano Bot Name
         | 
| 512 | 
            +
              author: Your Name
         | 
| 513 | 
            +
              version: 1.0.0
         | 
| 514 | 
            +
              license: CC0-1.0
         | 
| 515 | 
            +
              description: A helpful assistant.
         | 
| 516 | 
            +
             | 
| 517 | 
            +
            behaviors:
         | 
| 518 | 
            +
              interaction:
         | 
| 519 | 
            +
                directive: You are a helpful assistant.
         | 
| 520 | 
            +
             | 
| 521 | 
            +
            provider:
         | 
| 522 | 
            +
              id: google
         | 
| 523 | 
            +
              credentials:
         | 
| 524 | 
            +
                service: vertex-ai-api
         | 
| 525 | 
            +
                region: ENV/GOOGLE_REGION
         | 
| 526 | 
            +
              options:
         | 
| 527 | 
            +
                model: gemini-pro
         | 
| 528 | 
            +
            ```
         | 
| 529 | 
            +
             | 
| 530 | 
            +
            #### Custom Project ID
         | 
| 531 | 
            +
             | 
| 532 | 
            +
            If you need to manually set a Google Project ID:
         | 
| 533 | 
            +
             | 
| 534 | 
            +
            ```yaml
         | 
| 535 | 
            +
            ---
         | 
| 536 | 
            +
            provider:
         | 
| 537 | 
            +
              id: google
         | 
| 538 | 
            +
              credentials:
         | 
| 539 | 
            +
                project-id: ENV/GOOGLE_PROJECT_ID
         | 
| 540 | 
            +
            ```
         | 
| 541 | 
            +
             | 
| 373 542 | 
             
            ### Tools (Functions)
         | 
| 374 543 |  | 
| 375 544 | 
             
            Nano Bots can also be powered by _Tools_ (Functions):
         | 
| @@ -395,7 +564,7 @@ The randomly generated number is 59. | |
| 395 564 |  | 
| 396 565 | 
             
            🤖> |
         | 
| 397 566 | 
             
            ```
         | 
| 398 | 
            -
            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 model `gemini-pro`.
         | 
| 567 | 
            +
            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`.
         | 
| 399 568 |  | 
| 400 569 | 
             
            Check the [Nano Bots specification](https://spec.nbots.io/#/README?id=tools-functions-2) to learn more about Tools (Functions).
         | 
| 401 570 |  | 
| @@ -418,7 +587,7 @@ Unlike Lua and Fennel, Clojure support is not _embedded_ in this implementation. | |
| 418 587 | 
             
            Here's [how to install Babashka](https://github.com/babashka/babashka#quickstart):
         | 
| 419 588 |  | 
| 420 589 | 
             
            ```sh
         | 
| 421 | 
            -
            curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash
         | 
| 590 | 
            +
            curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | sudo bash
         | 
| 422 591 | 
             
            ```
         | 
| 423 592 |  | 
| 424 593 | 
             
            This is a quick check to ensure that it is available and working:
         | 
| @@ -576,5 +745,5 @@ gem build nano-bots.gemspec | |
| 576 745 |  | 
| 577 746 | 
             
            gem signin
         | 
| 578 747 |  | 
| 579 | 
            -
            gem push nano-bots-1. | 
| 748 | 
            +
            gem push nano-bots-2.1.0.gem
         | 
| 580 749 | 
             
            ```
         | 
    
        data/components/provider.rb
    CHANGED
    
    | @@ -9,7 +9,7 @@ module NanoBot | |
| 9 9 | 
             
                  def self.new(provider, environment: {})
         | 
| 10 10 | 
             
                    case provider[:id]
         | 
| 11 11 | 
             
                    when 'openai'
         | 
| 12 | 
            -
                      Providers::OpenAI.new(provider[:settings], provider[:credentials], environment:)
         | 
| 12 | 
            +
                      Providers::OpenAI.new(nil, provider[:settings], provider[:credentials], environment:)
         | 
| 13 13 | 
             
                    when 'google'
         | 
| 14 14 | 
             
                      Providers::Google.new(provider[:options], provider[:settings], provider[:credentials], environment:)
         | 
| 15 15 | 
             
                    else
         | 
| @@ -6,7 +6,7 @@ module NanoBot | |
| 6 6 | 
             
              module Components
         | 
| 7 7 | 
             
                module Providers
         | 
| 8 8 | 
             
                  class Base
         | 
| 9 | 
            -
                    def initialize(_settings, _credentials, _environment: {})
         | 
| 9 | 
            +
                    def initialize(_options, _settings, _credentials, _environment: {})
         | 
| 10 10 | 
             
                      raise NoMethodError, "The 'initialize' method is not implemented for the current provider."
         | 
| 11 11 | 
             
                    end
         | 
| 12 12 |  | 
| @@ -13,26 +13,22 @@ module NanoBot | |
| 13 13 | 
             
              module Components
         | 
| 14 14 | 
             
                module Providers
         | 
| 15 15 | 
             
                  class Google < Base
         | 
| 16 | 
            +
                    SAFETY_SETTINGS = %i[category threshold].freeze
         | 
| 17 | 
            +
             | 
| 16 18 | 
             
                    SETTINGS = {
         | 
| 17 19 | 
             
                      generationConfig: %i[
         | 
| 18 20 | 
             
                        temperature topP topK candidateCount maxOutputTokens stopSequences
         | 
| 19 21 | 
             
                      ].freeze
         | 
| 20 22 | 
             
                    }.freeze
         | 
| 21 23 |  | 
| 22 | 
            -
                    SAFETY_SETTINGS = %i[category threshold].freeze
         | 
| 23 | 
            -
             | 
| 24 24 | 
             
                    attr_reader :settings
         | 
| 25 25 |  | 
| 26 26 | 
             
                    def initialize(options, settings, credentials, _environment)
         | 
| 27 27 | 
             
                      @settings = settings
         | 
| 28 28 |  | 
| 29 29 | 
             
                      @client = Gemini.new(
         | 
| 30 | 
            -
                        credentials: {
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                          project_id: credentials[:'project-id'],
         | 
| 33 | 
            -
                          region: credentials[:region]
         | 
| 34 | 
            -
                        },
         | 
| 35 | 
            -
                        settings: { model: options[:model], stream: options[:stream] }
         | 
| 30 | 
            +
                        credentials: credentials.transform_keys { |key| key.to_s.gsub('-', '_').to_sym },
         | 
| 31 | 
            +
                        options: options.transform_keys { |key| key.to_s.gsub('-', '_').to_sym }
         | 
| 36 32 | 
             
                      )
         | 
| 37 33 | 
             
                    end
         | 
| 38 34 |  | 
| @@ -58,12 +54,18 @@ module NanoBot | |
| 58 54 | 
             
                        end
         | 
| 59 55 | 
             
                      end
         | 
| 60 56 |  | 
| 57 | 
            +
                      # TODO: Does Gemini have system messages?
         | 
| 61 58 | 
             
                      %i[backdrop directive].each do |key|
         | 
| 62 59 | 
             
                        next unless input[:behavior][key]
         | 
| 63 60 |  | 
| 64 | 
            -
                        # TODO: Does Gemini have system messages?
         | 
| 65 61 | 
             
                        messages.prepend(
         | 
| 66 | 
            -
                          { role:  | 
| 62 | 
            +
                          { role: 'model',
         | 
| 63 | 
            +
                            parts: { text: 'Understood.' },
         | 
| 64 | 
            +
                            _meta: { at: Time.now } }
         | 
| 65 | 
            +
                        )
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                        messages.prepend(
         | 
| 68 | 
            +
                          { role: 'user',
         | 
| 67 69 | 
             
                            parts: { text: input[:behavior][key] },
         | 
| 68 70 | 
             
                            _meta: { at: Time.now } }
         | 
| 69 71 | 
             
                        )
         | 
| @@ -122,24 +124,9 @@ module NanoBot | |
| 122 124 | 
             
                          end
         | 
| 123 125 |  | 
| 124 126 | 
             
                          if event.dig('candidates', 0, 'finishReason')
         | 
| 125 | 
            -
                             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 128 | 
            -
                                  needs_another_round: true,
         | 
| 129 | 
            -
                                  interaction: { who: 'AI', message: nil, meta: { tool_calls: tools } } }
         | 
| 130 | 
            -
                              )
         | 
| 131 | 
            -
                              Tools.apply(
         | 
| 132 | 
            -
                                cartridge, input[:tools], tools, feedback, Logic::Google::Tools
         | 
| 133 | 
            -
                              ).each do |interaction|
         | 
| 134 | 
            -
                                feedback.call({ should_be_stored: true, needs_another_round: true, interaction: })
         | 
| 135 | 
            -
                              end
         | 
| 136 | 
            -
                            end
         | 
| 137 | 
            -
             | 
| 138 | 
            -
                            feedback.call(
         | 
| 139 | 
            -
                              { should_be_stored: !(content.nil? || content == ''),
         | 
| 140 | 
            -
                                interaction: content.nil? || content == '' ? nil : { who: 'AI', message: content },
         | 
| 141 | 
            -
                                finished: true }
         | 
| 142 | 
            -
                            )
         | 
| 127 | 
            +
                            # TODO: This does not have the same behavior as OpenAI, so you should
         | 
| 128 | 
            +
                            #       not use it as a reference for the end of the streaming.
         | 
| 129 | 
            +
                            #       Is this a bug from the Google Gemini REST API or expected behavior?
         | 
| 143 130 | 
             
                          end
         | 
| 144 131 | 
             
                        end
         | 
| 145 132 |  | 
| @@ -148,6 +135,25 @@ module NanoBot | |
| 148 135 | 
             
                            Logic::Google::Tokens.apply_policies!(cartridge, payload),
         | 
| 149 136 | 
             
                            stream: true, &stream_call_back
         | 
| 150 137 | 
             
                          )
         | 
| 138 | 
            +
             | 
| 139 | 
            +
                          if tools&.size&.positive?
         | 
| 140 | 
            +
                            feedback.call(
         | 
| 141 | 
            +
                              { should_be_stored: true,
         | 
| 142 | 
            +
                                needs_another_round: true,
         | 
| 143 | 
            +
                                interaction: { who: 'AI', message: nil, meta: { tool_calls: tools } } }
         | 
| 144 | 
            +
                            )
         | 
| 145 | 
            +
                            Tools.apply(
         | 
| 146 | 
            +
                              cartridge, input[:tools], tools, feedback, Logic::Google::Tools
         | 
| 147 | 
            +
                            ).each do |interaction|
         | 
| 148 | 
            +
                              feedback.call({ should_be_stored: true, needs_another_round: true, interaction: })
         | 
| 149 | 
            +
                            end
         | 
| 150 | 
            +
                          end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                          feedback.call(
         | 
| 153 | 
            +
                            { should_be_stored: !(content.nil? || content == ''),
         | 
| 154 | 
            +
                              interaction: content.nil? || content == '' ? nil : { who: 'AI', message: content },
         | 
| 155 | 
            +
                              finished: true }
         | 
| 156 | 
            +
                          )
         | 
| 151 157 | 
             
                        rescue StandardError => e
         | 
| 152 158 | 
             
                          raise e.class, e.response[:body] if e.response && e.response[:body]
         | 
| 153 159 |  | 
| @@ -17,13 +17,14 @@ module NanoBot | |
| 17 17 | 
             
                    DEFAULT_ADDRESS = 'https://api.openai.com'
         | 
| 18 18 |  | 
| 19 19 | 
             
                    CHAT_SETTINGS = %i[
         | 
| 20 | 
            -
                      model stream  | 
| 21 | 
            -
                      presence_penalty  | 
| 20 | 
            +
                      model stream frequency_penalty logit_bias logprobs top_logprobs
         | 
| 21 | 
            +
                      max_tokens n presence_penalty response_format seed stop temperature
         | 
| 22 | 
            +
                      top_p tool_choice
         | 
| 22 23 | 
             
                    ].freeze
         | 
| 23 24 |  | 
| 24 25 | 
             
                    attr_reader :settings
         | 
| 25 26 |  | 
| 26 | 
            -
                    def initialize(settings, credentials, environment: {})
         | 
| 27 | 
            +
                    def initialize(_options, settings, credentials, environment: {})
         | 
| 27 28 | 
             
                      @settings = settings
         | 
| 28 29 | 
             
                      @credentials = credentials
         | 
| 29 30 | 
             
                      @environment = environment
         | 
    
        data/docker-compose.example.yml
    CHANGED
    
    | @@ -2,12 +2,21 @@ | |
| 2 2 | 
             
            services:
         | 
| 3 3 | 
             
              nano-bots:
         | 
| 4 4 | 
             
                image: ruby:3.2.2-slim-bookworm
         | 
| 5 | 
            -
                command: sh -c "apt-get update && apt-get install -y --no-install-recommends build-essential libffi-dev libsodium-dev lua5.4-dev curl && curl -s https://raw.githubusercontent.com/babashka/babashka/master/install | bash && gem install nano-bots -v 1. | 
| 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 2.1.0 && bash"
         | 
| 6 6 | 
             
                environment:
         | 
| 7 7 | 
             
                  OPENAI_API_ADDRESS: https://api.openai.com
         | 
| 8 8 | 
             
                  OPENAI_API_KEY: your-access-token
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  GOOGLE_API_KEY: your-api-key
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  GOOGLE_CREDENTIALS_FILE_PATH: /root/.config/google-credentials.json
         | 
| 13 | 
            +
                  GOOGLE_PROJECT_ID: your-project-id
         | 
| 14 | 
            +
                  GOOGLE_REGION: us-east4
         | 
| 15 | 
            +
             | 
| 9 16 | 
             
                  NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE
         | 
| 10 17 | 
             
                  NANO_BOTS_END_USER: your-user
         | 
| 18 | 
            +
             | 
| 11 19 | 
             
                volumes:
         | 
| 20 | 
            +
                  - ./google-credentials.json:/root/.config/google-credentials.json
         | 
| 12 21 | 
             
                  - ./your-cartridges:/root/.local/share/nano-bots/cartridges
         | 
| 13 22 | 
             
                  - ./your-state-path:/root/.local/state/nano-bots
         | 
    
        data/nano-bots.gemspec
    CHANGED
    
    | @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| | |
| 34 34 | 
             
              spec.add_dependency 'babosa', '~> 2.0'
         | 
| 35 35 | 
             
              spec.add_dependency 'concurrent-ruby', '~> 1.2', '>= 1.2.2'
         | 
| 36 36 | 
             
              spec.add_dependency 'dotenv', '~> 2.8', '>= 2.8.1'
         | 
| 37 | 
            -
              spec.add_dependency 'gemini-ai', '~> 1 | 
| 37 | 
            +
              spec.add_dependency 'gemini-ai', '~> 2.1'
         | 
| 38 38 | 
             
              spec.add_dependency 'pry', '~> 0.14.2'
         | 
| 39 39 | 
             
              spec.add_dependency 'rainbow', '~> 3.1', '>= 3.1.1'
         | 
| 40 40 | 
             
              spec.add_dependency 'rbnacl', '~> 7.1', '>= 7.1.1'
         | 
    
        data/ports/dsl/nano-bots.rb
    CHANGED
    
    
    
        data/static/gem.rb
    CHANGED
    
    | @@ -3,7 +3,8 @@ | |
| 3 3 | 
             
            module NanoBot
         | 
| 4 4 | 
             
              GEM = {
         | 
| 5 5 | 
             
                name: 'nano-bots',
         | 
| 6 | 
            -
                version: '1. | 
| 6 | 
            +
                version: '2.1.0',
         | 
| 7 | 
            +
                specification: '2.0.1',
         | 
| 7 8 | 
             
                author: 'icebaker',
         | 
| 8 9 | 
             
                summary: 'Ruby Implementation of Nano Bots: small, AI-powered bots for OpenAI ChatGPT and Google Gemini.',
         | 
| 9 10 | 
             
                description: 'Ruby Implementation of Nano Bots: small, AI-powered bots that can be easily shared as a single file, designed to support multiple providers such as OpenAI ChatGPT and Google Gemini, with support for calling Tools (Functions).',
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: nano-bots
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 2.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - icebaker
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-12- | 
| 11 | 
            +
            date: 2023-12-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: babosa
         | 
| @@ -70,14 +70,14 @@ dependencies: | |
| 70 70 | 
             
                requirements:
         | 
| 71 71 | 
             
                - - "~>"
         | 
| 72 72 | 
             
                  - !ruby/object:Gem::Version
         | 
| 73 | 
            -
                    version: '1 | 
| 73 | 
            +
                    version: '2.1'
         | 
| 74 74 | 
             
              type: :runtime
         | 
| 75 75 | 
             
              prerelease: false
         | 
| 76 76 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 77 77 | 
             
                requirements:
         | 
| 78 78 | 
             
                - - "~>"
         | 
| 79 79 | 
             
                  - !ruby/object:Gem::Version
         | 
| 80 | 
            -
                    version: '1 | 
| 80 | 
            +
                    version: '2.1'
         | 
| 81 81 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 82 82 | 
             
              name: pry
         | 
| 83 83 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 248 248 | 
             
                - !ruby/object:Gem::Version
         | 
| 249 249 | 
             
                  version: '0'
         | 
| 250 250 | 
             
            requirements: []
         | 
| 251 | 
            -
            rubygems_version: 3. | 
| 251 | 
            +
            rubygems_version: 3.3.3
         | 
| 252 252 | 
             
            signing_key: 
         | 
| 253 253 | 
             
            specification_version: 4
         | 
| 254 254 | 
             
            summary: 'Ruby Implementation of Nano Bots: small, AI-powered bots for OpenAI ChatGPT
         |