[HAI5016] Week 13: Loading up dr. Kingo
In one of the student presentations, a good example of chatbot lacking interaction skills was given: SKKU’s own Kingobot. Ever since that presentation, I have been thinking…
With all this wonderful tools we have equiped ourselves with this semester, and with some of the largest AI models at our disposal, I take on the challenge to build a better chatbot together in de remaining 3 classes of this semester. Let’s not waste any time and get started building our own mr-know-it-all: dr. Kingo!
Disclaimer: This blog provides instructions and resources for the workshop part of my lectures. It is not a replacement for attending class; it may not include some critical steps and the foundational background of the techniques and methodologies used. The information may become outdated over time as I do not update the instructions after class.
1. The boiler plate
For the sake of time, I have prepared a boiler plate repository that contains some files and folders to quickly set up our developer environment. We will fork this repository to our own GitHub account and then create a codespace from it to develop our chatbot.
Explore the repository
Let’s examine the files and folders in the boiler plate repository. This boiler plate includes the following:
- A
.devcontainer
folder with adevcontainer.json
file. This configuration as code will automate the installation of our development environment (container) and will install all nessecary python packages and VS Code extensions into our new codespace - A
.gitignore
file to tell Git to ignore the environment variables and log folders - An
env
file which is a template for the later .env file to store our environment variables in - A
requirements.txt
file with all the python packages that we need for this project
- A
Fork the boiler plate to your GitHub account
Click the ‘Fork’ button in the top right corner of the repository page and select
+ create a new fork
- Check the details in the Create a new fork page and click the Create fork button
- Wait for the fork to be created and you will be redirected to your own fork of the repository
2. Github Codespace
- Go to your repositories on the GitHub website and open the
dr-kingo
repository - Click on the ‘Code’ button and select ‘Create codespace on main’
Sit back and relax while your codespace is being created
Thanks to the
.devcontainer
file in the repository, all the convenient VS code extensions and python packages that we want to use for this project will be installed automatically installed into this codespace. Because of this, the first to start the codespace will take a little longer than usual. If you are curious about the progress of the container build, you can open the command palette (Ctrl+Shift+P
) and search forCodespaces: View Creation Log
3. Environment variables
Rename the env
file to .env
, open it in codespace editor and follow the instructions below to collect your environment variables. Make sure to leave no spaces between the =
sign and the variable values.
Supabase connection string (updated 2024-12-13)
To interact with our brand new Supabase database, we need to collect the connection string from the Supabase dashboard and add it to our .env file. The connection string is a combination of the url from the endpoint and the credentials to access the database in one string.
- Open your Supabase dashboard (https://supabase.com/dashboard/) and click on your project name
- Click on the
Connect
button somewhere located on the top of the page In the “Connect to your project” dialog, find the
Session pooler
section in the bottom:Copy the session pooler URL and paste it into your .env file as
DATABASE_URL
. It should look something like this:1
DATABASE_URL=postgresql://postgres.fjdsarewqr:[YOUR-PASSWORD]@aws-5-us-east-9.pooler.supabase.com:6543/postgres
- Replace the
[YOUR-PASSWORD]
part of the connectionstring with the password of your Supabase databaseIf you forgot your password, you can reset it by going to the project settings > Database > Reset database password
3. Run the scripts
In the repository, you will find 3 python files:
database.py
: We will use this module to interact with our Supabase database. It houses the table classes for our ORM and when ran as a script, it will create the tables in our databaseurl_loader.py
: To save time, I have prepared a list of URLs of the SKKU website that contain the data relevant to our simple (but better) chatbot. This module will download the excel file from my website and save the urls into the skku_urls` table in our databasedownloader.py
:
Let’s open, discuss and then run each script in the codespace editor. As we run these scripts. Take note of the logs folder, that will be populated with log files as we’re running the scripts to provide us with valuable insights into the scripts’ operations and progress.