Some basic examples using OpenAI APIs with Python.
You need to create a virtual env and install the packages listed in requirements.txt
. You can then run Jupyter Notebooks in VS Code.
Follow these steps: How to Work with Python Virtual Environments, Jupyter Notebooks and VS Code.
You need to create a .env
file with your OPENAI_API_KEY
.
For Stable Diffusion, you need to add your STABILITY_AI_KEY
. You can find it in your DreamStudio account once it's created.
- setting up a dev environment to run Jupyter Notebooks in VS Code.
- hiding our API key.
- defining max_tokens.
- stopping sequences.
- generating N choices and echoing the prompt.
- understanding the various completion models.
- comparing model performance and pricing.
- controlling the output format.
- summarizing text.
- extracting data.
- analyzing sentiments.
- thinking step by step.
- transforming text.
- writing the color palette generator prompt.
- writing a color-swatch rendering function.
- understanding temperature and top P.
- using frequency penalty and presence penalty.
- streaming responses.
- writing a request to the Chat API.
- prompting with system, assistant, and user messages.
- rewriting a completion prompt in chat format.
- using Chat API parameters.
- asking GPT-4 to explain code.
- calculating time complexity with GPT-4.
- translating JavaScript to Python with GPT-4.
- generating code from scratch with GPT-4.
- counting tokens with TikToken.
- counting GPT-4 message tokens.
- writing the playlist generating prompt.
- generating a single embedding.
- making a DALL-E API request.
- saving DALL-E images from the generated URL and from JSON.
- requesting image variations.
- editing DALL-E images.
- generating a Python script to delete images.
- creating a CV website with HTML and CSS.
- writing a newsletter email.
- using Python and Node to encode a string.
- renaming files in a folder.
- reorganizing files.
- calculating and displaying the total size of files modified today using a Bash script.
- calculating total duration of video files in a directory.
- creating a URL shortener using Flask and SQLite.
- classifying files in different folders according to their formats.
- creating a basic website.
- recreating the bouncing DVD logo screen.
- debugging code.
- creating a Monster Slayer game.
- building a NodeJS REST API.
- recreating a simple ChatGPT clone.
- creating a text summarization tool.
- processing text from a file and creating a new file.
These examples are based on three courses:
- Mastering OpenAI Python APIs: Unleash the Power of GPT4 by Colt Steele (2023).
- The Ultimate Guide To ChatGPT & Midjourney by Colt Steele (2023).
- ChatGPT - The Complete Guide to ChatGPT & OpenAI APIs by Maximilian Schwarzmüller (2023).