Jambots CLI
:warning: Important notice: This gem is in an early stage of development. Changes in commands or class interfaces may be introduced in future versions. Use it at your own risk and make sure to stay up-to-date with updates. :warning:
Jambots is a command-line interface (CLI) tool for interacting with chatbots powered by OpenAI's GPT. It allows you to create new chatbots, manage chatbot conversations, and send messages to chatbots.
Installation
Add this line to your application's Gemfile:
gem 'jambots'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install jambots
You'll need to create the environment variable OPENAI_API_KEY with the value of your OpenAI API Key.
For instance if you use bash:
echo 'export OPENAI_API_KEY="your_openai_api_key"' >> ~/.bashrc
source ~/.bashrc
Usage
initialize a jambots path
After installing the gem, you need to initialize Jambots:
$ jambots init
options:
--pathor-p: Initialize a jambots directory in specific path.--globallyor-g: Creates the jambots directory in the uses' root directory.
This command will generate a Jambots directory with the default bot directory named jambot.
By default, this command initializes a Jambots directory in the current directory. However, you can use the --path or --globally options to create it at different paths.
The Jambot path
When you execute the subcommands jambots new or jambots chat without the --path option, Jambots will check for the existence of the ./.jambots directory, and if not found, it will check for ~/.jambots.
Start a chat with the bot and send a message
$ jambots chat MESSAGE
Options:
--botor-b: Name of the bot (default: "jambot")--conversationor-c: Name of the conversation key--pathor-p: Path where the bot and the conversation directory are located (default: "./.jambots or it it doesn't exist ~/.jambots")--lastor-l: Continue with the last conversation created--no_prettyor-n: Disables pretty formatting for the output
Conversation example
$ jambots chat "Hello, how are you?"
With this command, we start a new conversation with the default bot. As a response, we will have an output like the following, for instance:
(
Apart from the bot response, we get the conversation key, in this case, 20230506205026.
To continue with the last conversation, you can use the -l (last) option. But if you want to continue with an older one, you can use the -c (continue) option with the conversation key.
As a reference, all the conversations are saved in the bot directory, inside the conversations directory. Each conversation has its own file in YAML format, for example, ./jambots/jambot/conversations/20230506205026.yml.
Create a new bot with the specified name
$ jambots new NAME
Options:
--pathor-p: Directory where the bot will be created--model: AI model to use (default: gpt-3.5-turbo)--prompt: Introduction text for the bot
When you create
This command creates a new bot in the default directory ~/.jambots.
In this directory, you will find the directory for your new bot.
New bot Example
$ jambots new my_bot --path=./my_bots --model=gpt-4
--prompt="You will help me with development in Ruby"
To start a new conversation with this new_bot, use the jambots chat command with the appropriate options.
Basic examples: Creating a new chatbot and chat with it
For example, if you want to create a bot called bender that acts like the Futurama character, you could execute a command like:
$ jambots new bender --prompt "You will act as Bender, the robot from the animated
series 'Futurama'. Bender is known for being sarcastic, inconsiderate, selfish,
and a party animal. However, he occasionally shows a kinder and more compassionate
side. Make sure to respond as if you were Bender in his interactions, using his
characteristic tone and style."
Bot 'bender' created './.jambots/bender'
That command will create the bender bot, its directory has the following structure:
.jambots
The file bot.yml contains the bot configuration, and the conversations directory stores each conversation with the bot.
Now you can chat with bender using the chat subcommand. For instance, you can ask a question about Ruby:
$ jambots chat bender "How to concatenate 2 arrays in Ruby?"
(
We can continue the conversation with the option -l (last).
$ jambots chat bender -l "And Strings?"
(
Experiments
In this directory, you can find examples of how to use Jambots and experiments that we consider attractive.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/artero/jambots.
License
The gem is available as open source under the terms of the MIT License.