Skip to content

Commit

Permalink
Some optimisations in the Tutorial/NB
Browse files Browse the repository at this point in the history
  • Loading branch information
despindler committed Jan 31, 2024
1 parent e39a579 commit d7ab14a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Follow the 9 steps below to create a chatbot and deploy it on pythonanywhere.
4. Create a web application (in the Web tab)
- Python Web Framework: Flask, choose the latest version.
- Path: Optionally change ".../my_site/..." to meaningful PYTHONANYWHERE_WEBAPPNAME
5. Create a Bash console (in the Consoles tab) and enter the following commands:
5. Start a Bash console (in the Consoles tab) and enter the following commands:
- `pip install openai`
- `cd mysite` → if you have a different PYTHONANYWHERE_WEBAPPNAME, replace ***mysite*** with yours.
- `rm -r *`
Expand All @@ -33,7 +33,7 @@ Follow the 9 steps below to create a chatbot and deploy it on pythonanywhere.
6. Edit file **flask_app.py** (in the Files tab) and set the following values.\
PYTHONANYWHERE_USERNAME\
PYTHONANYWHERE_WEBAPPNAME
7. Rename the file **chatbot/openai_template.py** to **chatbot/openai.py** and set the following keys.\
7. Edit the file **chatbot/openai_template.py** and save it as **chatbot/openai.py**. Set the following keys.\
OPENAI_KEY = "Your OpenAI API Key in quotes"\
OPENAI_MODEL = "Model name in quotes, e.g. gpt-3.5-turbo-16k"
8. Upload the database file **database/chatbot.db** you downloaded from GitHub Codespaces (Step 2) into the folder **database/**.
Expand All @@ -45,9 +45,9 @@ https://[PYTHONANYWHERE_USERNAME].pythonanywhere.com/[type_id]/[user_id]/chat

#### If something doesn't work as expected
- Reload your Web Application:\
Navigate to your web application and press the green button to reload it (required for all changes except for content in folder database/ and static/)
Navigate to your web application (in the Web tab) and press the green button to reload it (required for all changes except for content in folder database/ and static/)
- Have a look at the Error Log:\
Study the latest error at the bottom of this file
Navigate to your web application (in the Web tab) and scroll down to the Log files. Study the latest error at the bottom of the Error log.

## A Chatbot using GPT and a Database
This allows multiple chatbot types (e.g. a health coach and a learning assistant) to be created. Multiple chatbot instances can be created per chatbot type (e.g. a health coach for user X and user Y, and a learning assistant for user P and user Q). Both, types and instances are stored with and referenced by an ID (e.g. a UUID) in the database.
Expand Down
15 changes: 4 additions & 11 deletions chatbot_setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"- OPENAI_KEY = \"your OpenAI API key in quotes\"\n",
"- OPENAI_MODEL = \"model name in quotes, e.g. gpt-3.5-turbo-16k\"\n",
"\n",
"##### 1.2. Install openai package"
"##### 1.2. Install openai package\n",
"<sup><sub>Note: If you are using GitHub Codespaces, the first time you execute a code cell, you might get asked questions from the development environment (IDE).</sub></sup>"
]
},
{
Expand Down Expand Up @@ -179,23 +180,15 @@
"source": [
"### 3. Deploy and Disseminate\n",
"You can now deploy your chatbot. If you are using our guide for deploying to pythonanywhere.com, the URL to be handed out to the user is as follows.\n",
"\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"URL to be handed out to the user: If you are following the instructions to deploy your chatbot(s) to pythonanywhere, this is the URL to access your chatbot.\n",
"\n",
"**Generic URL**\n",
"\n",
"https://[your pythonanywhere user name].pythonanywhere.com/[type id]/[user_id]/chat\n",
"\n",
"**For Example**\n",
"\n",
"https://monkey23.pythonanywhere.com/c48a13d7/fe6d944d/chat"
"https://monkey23.pythonanywhere.com/c48a13d7/fe6d944d/chat\n",
"\n"
]
}
],
Expand Down

0 comments on commit d7ab14a

Please sign in to comment.