Gregor Schafroth
Posted on December 15, 2023
👋 Hi everyone,
🤖 I’m here as a programming beginner on the journey to build and offer personalized AI Chatbots to clients.
ℹ️ In a bit more detail: After going through two of Harvards introductory programming classes ‘CS50X’ and ‘CS50 Python’ my goal is to build my own ChatBot that accesses the OpenAI Assistant’s API. The chatbot should work on any websites and it also needs to access a knowledge base (e.g., company documents).
🍪 I already spent the last 2 weeks or so working on this ChatBot and I already got a simple Cookie Recommender Chatbot working, but there is still a long way to go from there. I’ll share more details about my current struggles in upcoming blogposts.
🎯 With this new blog I hope to achieve 3 things:
- Find a community and friends to discuss problems and celebrate successes.
- Reinforce and document my learnings by writing down my progress.
- Help other new programmers who want to learn how to interact with OpenAI via Python
😊 I intend to post regularly and I hope this will be useful and interesting to someone out there. Please never hesitate to reach out, I’d love to interact with some fellow programmers 🤗
💻 As a setup I’m using a Mac and Visual Studio Code
With that being said, let’s jump into the content of my first post. Below is my list of basic Terminal commands, with some specifically related to Python & OpenAI. I use many of them very frequently. Do you think I am missing anything important? 🤔
Navigating the Terminal
-
cd
orcd ~
(change directory) | brings you back to the home folder (where you start be default when you open the terminal) -
cd /
| brings you back to the root directory of the file system (which I never used, but still interesting) -
cd <foldername>
(change directory) | moves you to the folder called -
cd ..
| takes you up one level in the directory hierarchy (to the parent directory) -
clear
| cleans up the terminal -
ls
| lists everything in current folder -
pwd
(print working directory) | shows you where you are at -
man <terminal command>
(manual) | shows you what a specified is good for. (leave the manual again with ‘q’)
Creating, editing, & deleting files
-
code <name>
| opens a new or existing file called in Visual Studio Code (and for me replacestouch
) -
code .
| opens Virtual Studio Code from the current folder (I use the Mac Terminal app to do this rather than the VSC integrated terminal) -
nano <name>
| opens or creates a file called and edits it directly in the terminal. (save with ‘Ctrl’ + ‘0’ then Enter, exit with ‘Ctrl’ + ‘X’) -
open <name>
| opens the file called in the current directory with the default program -
touch <name> (<name>)
| creates a file called . multiple files can be created at the same time by adding additional s. (Often I usecode <name>
instead if it’s a file related to programming). -
rm <name>
(remove file) | deletes the file called
Creating & deleting folders
-
mkdir <foldername>
| creates a new folder called -
rmdir <foldername>
| deletes an empty folder. If the folder is not empty it will return an error message -
rm -r <foldername>
(r = recursive) | deletes the folder called and all files in it
Moving & copying files & folders
-
cp <source object> <destination object>
(cp = copy) | copies a file or folder to a given location with a given name -
git <various commands>
| allows you to upload and manage objects in a git repository. I use this all the time for my online chatbot (running on Heroku) -
mv <source object> <destination object>
| moves a file or folder from one location to another. It can also be used for renaming files and directories, since in computer logic a name is just a location.
Python-Related Commands
-
brew install <name>
| conveniently installs important software to your Mac. For example I usedbrew install python
andbrew install git
-
python <.py file>
orpython3 <.py file>
| opens and runs the python code from the given <.py file> -
pip install <package_name>
| installs specified packages and libraries. For examplepip install openai
installs the OpenAI Python API library - Virtual Environments (I am using a Mac, this might be a bit different on Windows)
-
python -m venv venv
| creates a new virtual environment -
source venv/bin/activate
| activates the virtual environment -
deactivate
| deactivates the virtual environment again
-
OpenAI-Related Commands
-
curl
| without going in more detail here, this can be used to make HTTP requests to the OpenAI API. I found this very useful in the beginning to test if I can actually access the API even before I had any graphical interface.
Have a great day everyone! 🤗
Gregor 🇬🇧
Posted on December 15, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.