RoundTable is an AI chatbot which simulates a round table discussion between Albert Einstein, Isaac Newton, and Nikola Tesla.
The goal of the project is to serve as an opinionated starting point for developers looking to build their own AI chatbot as quickly as possible.
This project assumes basic programming knowledge, but aims to be accessible to anyone who is willing to learn.
roundtable-video-demo.mov
- Fully functional chatbot with a custom system prompt
- Real-time UI updates with Turbo Streams
- Works with any AI provider which uses the OpenAI completion API
- Ready to be deployed to Heroku
- Docker for a quick contained postgres and redis instances
- rbenv to install ruby
- local AI provider (ollama, llama.cpp, etc) or OpenAI API key
- overmind to orchestrate everything in the development environment
On Mac you can install most of these with homebrew.
Ollama is a great choice for an AI backend if you're just getting started.
First let's get the code and install the dependencies.
cd ~/Source # or wherever you keep your projects
git clone https://github.com/satoramoto/roundtable.git
cd roundtable
rbenv install && bundle installOn Mac you may run into an issue with the pg gem, which must be built natively.
You can install the libpq library with homebrew and then configure the bundler to use it during build.
brew install libpq
bundle config build.pg --with-pg-config=/usr/local/opt/libpq/bin/pg_configNext we create a .env.development file with the following contents. For simplicity, we'll use the OpenAI API.
OPEN_AI_BACKEND=https://api.openai.com
OPEN_AI_API_KEY=your-api-key-here
OPEN_AI_MODEL_NAME=gpt-4o-miniNext lets bootstrap postgres with the database and the schema.
docker-compose up -d postgres
rails db:setup && rails db:migrate
docker-compose downFinally, we can start the project with overmind.
overmind start -f Procfile.developmentThe application will be available at http://localhost:5000.
These instructions are untested, but should give you the general idea of how to deploy this project to Heroku. You can also use the Heroku UI to set up the project. Here we'll use the Heroku CLI.
Before we do anything, install the Heroku CLI and login.
brew tap heroku/brew && brew install heroku
heroku loginNow we can create a new Heroku app and add the Redis and Postgres addons.
heroku create your-app-name
heroku addons:create heroku-redis:hobby-dev
heroku addons:create heroku-postgresql:hobby-devNext, set the environment variables on Heroku.
heroku config:set OPEN_AI_BACKEND=https://api.openai.com
heroku config:set OPEN_AI_API_KEY=your-api-key-here
heroku config:set OPEN_AI_MODEL_NAME=gpt-4o-miniIn order to deploy the code, we need to set up the heroku remote.
heroku git:remoteFinally, push the code to Heroku to trigger a deployment.
git push heroku mainThere were a number of features/approaches/etc I considered when doing this project, most of which were trade-offs between speed and complexity.
I wanted to make this project as simple as possible to get started with, so I made a lot of decisions that may not be the best for every use case.
By no means is this a production-ready chatbot, but it should be a good starting point for most people.
I welcome pull requests if you have a better way to do something, or generally want to improve this example.
I built this project because I wanted to learn more about AI and chatbots. I chose Rails because it's a mature framework with a large community and a lot of resources.
Rails is opinionated, which means it makes a lot of decisions for you, which can be a good thing when you're just getting started.
Ruby itself is a very readable language, which makes it easy to understand what's going on in the code. Even if you're not familiar with Ruby, you should be able to follow along. Python developers will feel right at home.
Speaking of opinions, this project uses the Turbo and Hotwire libraries instead of React or some other fancy front-end framework.
Because we want to go fast. You wanted to learn about AI, not JavaScript frameworks, right?
Turbo and Hotwire are libraries from the creators of Rails that make it easy to build interactive web applications without writing a lot of JavaScript.
I think you'll find it easier to get started with Turbo and Hotwire than with React or another front-end framework.
But if you're already comfortable with those libraries,
you can fork this project and use react-rails or whatever else to build your front-end.
Fork this repository and don't look back! Take whatever you need and ditch the rest.
This project is meant to get you started quickly with all the basics.
You should be able to copy the patterns here to do things like:
- Add a user system using the
ActiveRecordmodels - Change the system prompt to make that perfect assistant
- Iterate quickly on your own user interface
Or you can lift some of the infrastructure and build your own chatbot from scratch.
You may find the following bits interesting:
- The System Prompt
- The GitHub actions for CI/CD
- Turbo and Hotwire as an alternative to React
If you found this project helpful, please consider giving it a star on GitHub.
If you want to say thanks, you can buy me a coffee at ko-fi.com/ryangavin.
BTC: bc1qxsvryfcse92qzgdug2ujh6wqxpq6u2pp5sd9r0
XMR: 46oxUJ9iLX92SG1USCqNN2fezvcE26xBoef7dSCX9BhkT9ohnEk8uxhjc2r6961fBnUCJGBmryJMBAe5ronUxB3CADFT9eR
This project is licensed under the MIT License. See LICENSE.txt for details.