Skip to content

Latest commit

 

History

History

00-playground

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Playground

Some basic examples using OpenAI APIs with Python.

Setup

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.

Getting started

  • 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.

Check the notebook

Prompt design

  • controlling the output format.
  • summarizing text.
  • extracting data.
  • analyzing sentiments.
  • thinking step by step.
  • transforming text.

Check the notebook

Color palette generator

  • writing the color palette generator prompt.
  • writing a color-swatch rendering function.

Check the notebook

Important API parameters

  • understanding temperature and top P.
  • using frequency penalty and presence penalty.
  • streaming responses.

Check the notebook

The Chat API & GPT-4

  • 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.

Check the notebook

Working with GPT-4 and code

  • 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.

Check the notebook

Cost estimation with TikToken

  • counting tokens with TikToken.
  • counting GPT-4 message tokens.

Check the notebook

GPT-4 AI Spotify Playlist Generator

  • writing the playlist generating prompt.

Check the notebook

Embeddings

  • generating a single embedding.

Check the notebook

The DALL-E API

  • making a DALL-E API request.
  • saving DALL-E images from the generated URL and from JSON.
  • requesting image variations.
  • editing DALL-E images.

Check the notebook

Prompt Engineering

Utility Scripts

Using ChatGPT for Programming Development

ChatGPT for Non-Developers & Developers

Using GPT APIs

Using LangChain

Chatting with data using LangChain

These examples are based on three courses:

We are also relying on three short courses: