README.md in nano-bots-0.0.10 vs README.md in nano-bots-0.1.0

- old
+ new

@@ -26,43 +26,45 @@ ## Setup For a system usage: ```sh -gem install nano-bots -v 0.0.10 +gem install nano-bots -v 0.1.0 ``` To use it in a project, add it to your `Gemfile`: ```ruby -gem 'nano-bots', '~> 0.0.10' +gem 'nano-bots', '~> 0.1.0' ``` ```sh bundle install ``` 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: ```sh -export NANO_BOTS_ENCRYPTION_PASSWORD="UNSAFE" export OPENAI_API_ADDRESS=https://api.openai.com -export OPENAI_API_ACCESS_TOKEN=your-token -export OPENAI_API_USER_IDENTIFIER=your-user +export OPENAI_API_KEY=your-access-token +export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE +export NANO_BOTS_END_USER=your-user + # export NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots # export NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges ``` Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded: ```sh -NANO_BOTS_ENCRYPTION_PASSWORD="UNSAFE" OPENAI_API_ADDRESS=https://api.openai.com -OPENAI_API_ACCESS_TOKEN=your-token -OPENAI_API_USER_IDENTIFIER=your-user +OPENAI_API_KEY=your-access-token +NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE +NANO_BOTS_END_USER=your-user + # NANO_BOTS_STATE_DIRECTORY=/home/user/.local/state/nano-bots # NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges ``` ## Docker @@ -81,19 +83,19 @@ version: '3.7' services: nano-bots: image: ruby:3.2.2-slim-bullseye - command: sh -c "gem install nano-bots -v 0.0.10 && bash" + command: sh -c "gem install nano-bots -v 0.1.0 && bash" environment: - NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE OPENAI_API_ADDRESS: https://api.openai.com - OPENAI_API_ACCESS_TOKEN: your-token - OPENAI_API_USER_IDENTIFIER: your-user + OPENAI_API_KEY: your-access-token + NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE + NANO_BOTS_END_USER: your-user volumes: - - ./your-cartridges:/cartridges - # - ./your-data:/data + - ./your-cartridges:/.local/share/nano-bots/cartridges + - ./your-state:/.local/state/nano-bots ``` Enter the container: ```sh docker compose run nano-bots @@ -102,12 +104,12 @@ Start playing: ```sh nb - - eval "hello" nb - - repl -nb cartridges/assistant.yml - eval "hello" -nb cartridges/assistant.yml - repl +nb assistant.yml - eval "hello" +nb assistant.yml - repl ``` ## Usage ### Command Line @@ -254,17 +256,17 @@ behaviors: interaction: directive: You are a helpful assistant. provider: - name: openai + id: openai + credentials: + address: ENV/OPENAI_API_ADDRESS + access-token: ENV/OPENAI_API_KEY settings: + user: ENV/NANO_BOTS_END_USER model: gpt-3.5-turbo - credentials: - address: ENV/OPENAI_API_ADDRESS - access-token: ENV/OPENAI_API_ACCESS_TOKEN - user-identifier: ENV/OPENAI_API_USER_IDENTIFIER ``` Check the Nano Bots specification to learn more about [how to build cartridges](https://spec.nbots.io/#/README?id=cartridges). Try the [Nano Bots Clinic (Live Editor)](https://clinic.nbots.io) to learn about creating Cartridges. @@ -312,37 +314,52 @@ 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. You can define custom end-user identifiers in the following way: ```ruby -NanoBot.new(environment: { NANO_BOTS_USER_IDENTIFIER: 'user-a' }) -NanoBot.new(environment: { NANO_BOTS_USER_IDENTIFIER: 'user-b' }) +NanoBot.new(environment: { NANO_BOTS_END_USER: 'custom-user-a' }) +NanoBot.new(environment: { NANO_BOTS_END_USER: 'custom-user-b' }) ``` -Consider that you have have the following OpenAI user identifier: +Consider that you have the following end-user identifier in your environment: ```sh -OPENAI_API_USER_IDENTIFIER=your-name +NANO_BOTS_END_USER=your-name ``` +Or a configuration in your Cartridge: +```yml +--- +provider: + id: openai + settings: + user: your-name +``` + The requests will be performed as follows: ```ruby -NanoBot.new(environment: {NANO_BOTS_USER_IDENTIFIER: 'user-a'}) -# { user: 'your-name/user-a' } +NanoBot.new(cartridge: '-') +# { user: 'your-name' } -NanoBot.new(environment: {NANO_BOTS_USER_IDENTIFIER: 'user-b'}) -# { user: 'your-name/user-b' } +NanoBot.new(cartridge: '-', environment: { NANO_BOTS_END_USER: 'custom-user-a' }) +# { user: 'custom-user-a' } + +NanoBot.new(cartridge: '-', environment: { NANO_BOTS_END_USER: 'custom-user-b' }) +# { user: 'custom-user-b' } ``` 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: ```ruby -'your-name/user-a' -# -onBK9GWafYz-JM8-cydhn4jd4Bkfkec5FtJ1ReCrtHCDPjkhCqUjRobG1zLnAz3BLo1kFhRW3w= +'your-name' +# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA== -'your-name/user-a' -# RldW4_xxktCksEAR9G8aORuq3skPAc9ivWj3eye2ICCHQy8gG_R5qLMS3Fg-0lY6LwxKGQur5Ww= +'custom-user-a' +# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs= + +'custom-user-b' +# _O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg= ``` 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`). ## Decrypting @@ -350,15 +367,18 @@ To decrypt your encrypted data, once you have properly configured your password, you can simply run: ```ruby require 'nano-bots' -NanoBot.security.decrypt('-onBK9GWafYz-JM8-cydhn4jd4Bkfkec5FtJ1ReCrtHCDPjkhCqUjRobG1zLnAz3BLo1kFhRW3w=') -# your-name/user-b +NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZqpsAkPg4j62SeNYlgwq3kn51Ob2wmIehoA==') +# your-name -NanoBot.security.decrypt('RldW4_xxktCksEAR9G8aORuq3skPAc9ivWj3eye2ICCHQy8gG_R5qLMS3Fg-0lY6LwxKGQur5Ww=') -# your-name/user-b +NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZJgIXHCBHyADW-rn4IQr-s2RvP7vym8u5tnzYMIs=') +# custom-user-a + +NanoBot.security.decrypt('_O7OjYUESagb46YSeUeSfSMzoO1Yg0BZkjUwCcsh9sVppKvYMhd2qGRvP7vym8u5tnzYMIg=') +# custom-user-b ``` If you lose your password, you lose your data. It is not possible to recover it at all. For real. ## Providers @@ -386,7 +406,7 @@ ```bash gem build nano-bots.gemspec gem signin -gem push nano-bots-0.0.10.gem +gem push nano-bots-0.1.0.gem ```