diff options
-rw-r--r-- | README.md | 327 |
1 files changed, 199 insertions, 128 deletions
@@ -1,27 +1,29 @@ # Nano Bots 💎 🤖 -A Ruby implementation of the [Nano Bots](https://github.com/icebaker/nano-bots) specification. +A Ruby implementation of the [Nano Bots](https://github.com/icebaker/nano-bots) specification with support for [OpenAI ChatGPT](https://openai.com/chatgpt), [Mistral AI](https://mistral.ai), and [Google Gemini](https://deepmind.google/technologies/gemini). - -_Image artificially created by Midjourney through a prompt generated by a Nano Bot specialized in Midjourney._ + https://user-images.githubusercontent.com/113217272/238141567-c58a240c-7b67-4b3b-864a-0f49bbf6e22f.mp4 - [Setup](#setup) - [OpenAI ChatGPT](#openai-chatgpt) + - [Mistral AI](#mistral-ai) - [Google Gemini](#google-gemini) - - [Docker](#docker) - - [OpenAI ChatGPT](#openai-chatgpt-1) - - [Google Gemini](#google-gemini-1) - [Usage](#usage) - [Command Line](#command-line) - [Library](#library) - [Cartridges](#cartridges) - - [OpenAI ChatGPT](#openai-chatgpt-2) - - [Google Gemini](#google-gemini-2) + - [OpenAI ChatGPT](#openai-chatgpt-1) + - [Mistral AI](#mistral-ai-1) + - [Google Gemini](#google-gemini-1) - [Tools (Functions)](#tools-functions) - [Experimental Clojure Support](#experimental-clojure-support) - [Marketplace](#marketplace) +- [Docker](#docker) + - [OpenAI ChatGPT](#openai-chatgpt-1) + - [Mistral AI](#mistral-ai-1) + - [Google Gemini](#google-gemini-1) - [Security and Privacy](#security-and-privacy) - [Cryptography](#cryptography) - [End-user IDs](#end-user-ids) @@ -51,12 +53,7 @@ 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: -### OpenAI ChatGPT - ```sh -export OPENAI_API_ADDRESS=https://api.openai.com -export OPENAI_API_KEY=your-access-token - export NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE export NANO_BOTS_END_USER=your-user @@ -67,9 +64,6 @@ export NANO_BOTS_END_USER=your-user Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded: ```sh -OPENAI_API_ADDRESS=https://api.openai.com -OPENAI_API_KEY=your-access-token - NANO_BOTS_ENCRYPTION_PASSWORD=UNSAFE NANO_BOTS_END_USER=your-user @@ -77,6 +71,38 @@ NANO_BOTS_END_USER=your-user # NANO_BOTS_CARTRIDGES_DIRECTORY=/home/user/.local/share/nano-bots/cartridges ``` +### OpenAI ChatGPT + +You can obtain your credentials on the [OpenAI Platform](https://platform.openai.com). + +```sh +export OPENAI_API_ADDRESS=https://api.openai.com +export OPENAI_API_KEY=your-access-token +``` + +Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded: + +```sh +OPENAI_API_ADDRESS=https://api.openai.com +OPENAI_API_KEY=your-access-token +``` + +### Mistral AI + +You can obtain your credentials on the [Mistral Platform](https://console.mistral.ai). + +```sh +export MISTRAL_API_ADDRESS=https://api.mistral.ai +export MISTRAL_API_KEY=your-api-key +``` + +Alternatively, if your current directory has a `.env` file with the environment variables, they will be automatically loaded: + +```sh +MISTRAL_API_ADDRESS=https://api.mistral.ai +MISTRAL_API_KEY=your-api-key +``` + ### Google Gemini Click [here](https://github.com/gbaptista/gemini-ai#credentials) to learn how to obtain your credentials. @@ -169,117 +195,6 @@ Alternatively, if your current directory has a `.env` file with the environment GOOGLE_PROJECT_ID=your-project-id ``` -## Docker - -Clone the repository and copy the Docker Compose template: - -``` -git clone https://github.com/icebaker/ruby-nano-bots.git -cd ruby-nano-bots -cp docker-compose.example.yml docker-compose.yml -``` - -Set your provider credentials and choose your desired directory for the cartridges files: - -### OpenAI ChatGPT - -```yaml ---- -services: - nano-bots: - image: ruby:3.2.2-slim-bookworm - 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.2.0 && bash" - environment: - OPENAI_API_ADDRESS: https://api.openai.com - OPENAI_API_KEY: your-access-token - NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE - NANO_BOTS_END_USER: your-user - volumes: - - ./your-cartridges:/root/.local/share/nano-bots/cartridges - - ./your-state-path:/root/.local/state/nano-bots -``` - -### Google Gemini - -#### Option 1: API Key (Generative Language API) - -```yaml ---- -services: - nano-bots: - image: ruby:3.2.2-slim-bookworm - 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.2.0 && bash" - environment: - GOOGLE_API_KEY: your-api-key - NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE - NANO_BOTS_END_USER: your-user - volumes: - - ./your-cartridges:/root/.local/share/nano-bots/cartridges - - ./your-state-path:/root/.local/state/nano-bots -``` - -#### Option 2: Service Account Credentials File (Vertex AI API) - -```yaml ---- -services: - nano-bots: - image: ruby:3.2.2-slim-bookworm - 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.2.0 && bash" - environment: - GOOGLE_CREDENTIALS_FILE_PATH: /root/.config/google-credentials.json - GOOGLE_REGION: us-east4 - NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE - NANO_BOTS_END_USER: your-user - volumes: - - ./google-credentials.json:/root/.config/google-credentials.json - - ./your-cartridges:/root/.local/share/nano-bots/cartridges - - ./your-state-path:/root/.local/state/nano-bots -``` - -#### Option 3: Application Default Credentials (Vertex AI API) - -```yaml ---- -services: - nano-bots: - image: ruby:3.2.2-slim-bookworm - 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.2.0 && bash" - environment: - GOOGLE_REGION: us-east4 - NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE - NANO_BOTS_END_USER: your-user - volumes: - - ./your-cartridges:/root/.local/share/nano-bots/cartridges - - ./your-state-path:/root/.local/state/nano-bots -``` - -#### Custom Project ID -If you need to manually set a Google Project ID: - -```yaml -environment: - GOOGLE_PROJECT_ID=your-project-id -``` - -### Container - -Enter the container: -```sh -docker compose run nano-bots -``` - -Start playing: -```sh -nb - - eval "hello" -nb - - repl - -nb assistant.yml - eval "hello" -nb assistant.yml - repl -``` - -You can exit the REPL by typing `exit`. - ## Usage ### Command Line @@ -447,6 +362,32 @@ provider: model: gpt-4-1106-preview ``` +### Mistral AI + +Read the [full specification](https://spec.nbots.io/#/README?id=mistral-ai) for Mistral AI. + +```yaml +--- +meta: + symbol: 🤖 + name: Nano Bot Name + author: Your Name + version: 1.0.0 + license: CC0-1.0 + description: A helpful assistant. + +behaviors: + interaction: + directive: You are a helpful assistant. + +provider: + id: mistral + credentials: + api-key: ENV/MISTRAL_API_KEY + settings: + model: mistral-medium +``` + ### Google Gemini Read the [full specification](https://spec.nbots.io/#/README?id=google-gemini) for Google Gemini. @@ -564,7 +505,7 @@ The randomly generated number is 59. 🤖> | ``` -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`. +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`. Mistral AI does not support tools. Check the [Nano Bots specification](https://spec.nbots.io/#/README?id=tools-functions-2) to learn more about Tools (Functions). @@ -609,6 +550,135 @@ safety: You can explore the Nano Bots [Marketplace](https://nbots.io) to discover new Cartridges that can help you. +## Docker + +Clone the repository and copy the Docker Compose template: + +``` +git clone https://github.com/icebaker/ruby-nano-bots.git +cd ruby-nano-bots +cp docker-compose.example.yml docker-compose.yml +``` + +Set your provider credentials and choose your desired directory for the cartridges files: + +### OpenAI ChatGPT + +```yaml +--- +services: + nano-bots: + image: ruby:3.2.2-slim-bookworm + 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.2.0 && bash" + environment: + OPENAI_API_ADDRESS: https://api.openai.com + OPENAI_API_KEY: your-access-token + NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE + NANO_BOTS_END_USER: your-user + volumes: + - ./your-cartridges:/root/.local/share/nano-bots/cartridges + - ./your-state-path:/root/.local/state/nano-bots +``` + +### Mistral AI + +```yaml +--- +services: + nano-bots: + image: ruby:3.2.2-slim-bookworm + 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.2.0 && bash" + environment: + MISTRAL_API_ADDRESS: https://api.mistral.ai + MISTRAL_API_KEY: your-api-key + NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE + NANO_BOTS_END_USER: your-user + volumes: + - ./your-cartridges:/root/.local/share/nano-bots/cartridges + - ./your-state-path:/root/.local/state/nano-bots +``` + +### Google Gemini + +#### Option 1: API Key (Generative Language API) + +```yaml +--- +services: + nano-bots: + image: ruby:3.2.2-slim-bookworm + 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.2.0 && bash" + environment: + GOOGLE_API_KEY: your-api-key + NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE + NANO_BOTS_END_USER: your-user + volumes: + - ./your-cartridges:/root/.local/share/nano-bots/cartridges + - ./your-state-path:/root/.local/state/nano-bots +``` + +#### Option 2: Service Account Credentials File (Vertex AI API) + +```yaml +--- +services: + nano-bots: + image: ruby:3.2.2-slim-bookworm + 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.2.0 && bash" + environment: + GOOGLE_CREDENTIALS_FILE_PATH: /root/.config/google-credentials.json + GOOGLE_REGION: us-east4 + NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE + NANO_BOTS_END_USER: your-user + volumes: + - ./google-credentials.json:/root/.config/google-credentials.json + - ./your-cartridges:/root/.local/share/nano-bots/cartridges + - ./your-state-path:/root/.local/state/nano-bots +``` + +#### Option 3: Application Default Credentials (Vertex AI API) + +```yaml +--- +services: + nano-bots: + image: ruby:3.2.2-slim-bookworm + 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.2.0 && bash" + environment: + GOOGLE_REGION: us-east4 + NANO_BOTS_ENCRYPTION_PASSWORD: UNSAFE + NANO_BOTS_END_USER: your-user + volumes: + - ./your-cartridges:/root/.local/share/nano-bots/cartridges + - ./your-state-path:/root/.local/state/nano-bots +``` + +#### Custom Project ID +If you need to manually set a Google Project ID: + +```yaml +environment: + GOOGLE_PROJECT_ID=your-project-id +``` + +### Container + +Enter the container: +```sh +docker compose run nano-bots +``` + +Start playing: +```sh +nb - - eval "hello" +nb - - repl + +nb assistant.yml - eval "hello" +nb assistant.yml - repl +``` + +You can exit the REPL by typing `exit`. + ## Security and Privacy 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. @@ -720,6 +790,7 @@ If you lose your password, you lose your data. It is not possible to recover it Currently supported providers: - [x] [Open AI ChatGPT](https://platform.openai.com/docs/api-reference) +- [x] [Mistral AI](https://docs.mistral.ai/api/) - [x] [Google Gemini](https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/gemini) - [ ] [Anthropic Claude](https://www.anthropic.com) - [ ] [Cohere Command](https://cohere.com) |