Skip to content

An ever-evolving introduction to ChatGPT, AI, and machine learning (including prompt examples and Python-built chatbots)

License

Notifications You must be signed in to change notification settings

bg-write/chatGPT-cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChatGPT Beginner's Guide

Learn how to use ChatGPT's prompt portal and API, whether you're new to AI or trying to build your first chatbot.

Version 1.2.0: Updated outline to split documentation into three overall parts with introduction.

GitHub issues

image

The Summary

  • ChatGPT, and AI in general, is less like C-3PO and more like a bunch of well-meaning worms doing their best.
  • After a high-level introduction, this guide divides into sections for just using the prompt portal in Part A and then using the actual API in Part B. Part C is a reference for all users.
  • AI is only as good as the data it's trained on. The better and more specific your prompt and parameters, the more helpful ChatGPT can be.
  • Avoid sharing any private or sensitive data. Assume that everything you write to ChatGPT will eventually be hacked and printed somewhere on the Internet.

Guide Goals & Intended Audience

The goal of this open-source guide is to establish foundational knowledge of ChatGPT and basic concepts behind AI and machine learning. This could be your first-ever guide to ChatGPT, whether you've never touched code before and are only using the popular chat functionality or a developer using the API to build your first ChatGPT app.

The saying is already cliche, and it's true: AI will probably not take your job, but it will change your job.

NOTE: For the sake of simplicity and accessibility, we're using GPT-3. GPT-4 is available but only in beta. This guide will be updated once GPT-4 and future versions are more widely available.

IMPORTANT: Be mindful of everything you send to ChatGPT. Do not share private information that you would not want ChatGPT to remember and store. Assume that everything you write to ChatGPT will eventually be hacked and printed somewhere else on the Internet.


Table of Contents

I. Introduction

  • Overview of ChatGPT
  • How You Can Use ChatGPT
  • Metaphors For What ChatGPT Can (and Can't) Do

II. Getting Started (Prompt Portal)

  • Step-by-Step Guide
  • Writing Your First Prompt
  • The Art of a Good Prompt

III. Examples of ChatGPT Prompts

  • General Learning, Troubleshooting, Or Brainstorming
  • Editing, Summarizing, and Translating Text
  • Creating Your Own Study Guide
  • Generating Project Ideas
  • Preparing Your Resume For A Specific Application
  • Preparing For A Job Interview
  • Working In Excel
  • Writing Shell (Linux) Commands
  • Writing Git Commands
  • Improving Code & Getting Feedback
  • Extracting Data
  • Generating Dummy Data
  • Generating Documentation
  • Understanding and Fixing Errors
  • Writing Tests
  • Building An API
  • Natural Language Programming
  • Python Examples
  • HTML, CSS, and JavaScript Examples
  • React Examples
  • SQL Examples

IV. Getting Started (ChatGPT's API)

  • System Requirements
  • Installing Dependencies
  • Running the Code

V. Usage

  • Overview of API Features
  • Using chat_cli.py (ChatGPT in the Command Line)
  • Using chat_ui.py (ChatGPT Deployed on Localhost)

VI. API Reference

  • API Documentation & Quick Links
  • Obtaining an API key
  • API Example Applications

VII. Giving Thanks

  • Closing Credits
  • Cited Sources
  • Open-Source Contributing

VIII. Glossary

  • Artificial Intelligence (AI)
  • Machine Learning
  • Natural Language Processing (NLP)
  • Chatbot
  • Deep Learning
  • Neural Network
  • Generative Model
  • Transformer Model
  • API (Application Programming Interface)

image

I. Introduction

This section introduces ChatGPT and the concepts of AI, machine learning, natural language processing, and the Transformer model, while also sharing initial use cases and metaphors for non-developers and software engineers.

Return to top

Overview of ChatGPT

ChatGPT is a computer program that can understand and generate human-like language to have conversations with people.

This is the answer I got when I asked ChatGPT to explain itself in one sentence to someone who knows nothing about ChatGPT or AI.

Here's a more specific definition:

ChatGPT is a state-of-the-art, large-scale natural language processing model based on the Transformer architecture, which can generate human-like text and perform various language-related tasks with high accuracy.

This time, I asked ChatGPT to sum itself up in one sentence to an AI and machine learning expert. Pretty cool, right?

OK ... but what does this all mean?

AI (Artificial Intelligence) is a type of computer technology that allows machines to perform tasks that normally require human intelligence. Machine Learning is a subset of AI that enables machines to learn from data and improve their performance without being explicitly programmed; in a way, it's learning from itself. Give it a goal and a data set to learn from and it'll do the rest.

So in relation to AI and machine learning, ChatGPT is a particular machine learning model that has been trained on a lot of text data to generate human-like responses and carry out natural language processing tasks.

Natural language processing models are AI models that enable computers to understand, interpret, and generate human language, allowing them to interact with humans through speech or text. There are many types of AI models, and more details will come in a future version of this guide. For now, it's important to know that ChatGPT uses the Transformer model. Compared to other AI models, the Transformer model is better at generating responses that focus on the context of a conversation. What makes ChatGPT special is that it can be picky and focus on the most relevant parts of a user's input instead of having to process an entire sequence at once.

If you'd like to read more on AI and machine learning beyond this guide, my favorite book right now is Janelle Shane's 'You Look Like a Thing and I Love You,' which informs a lot of the high-level concepts found in this guide.


How You Can Use ChatGPT

For non-developers, some examples include:

  • Ask questions or give commands to ChatGPT to then take specific actions and steps.
    • i.e. Explain JavaScript like I'm a 5-year-old, and then explain it to me like I'm a senior engineer.
  • Generate ideas, documentation, or dummy data.
    • i.e. I need some sample data. I need a JSON array of 10 colleges with at least 10 fields each.
  • Extract summaries, key words, and other data from text, links, or other online resources.
    • i.e. I'm applying for this role [paste in job posting URL or text] what keywords should I include on my resume?
  • Draft personalized study guides for future learning.
    • i.e. Give me a study plan to learn Python for data science within a month with free video resources.
  • Create first drafts of various text content.
    • i.e. I have three years of experience coding in HTML, CSS, and JavaScript. Write a resume for me.
  • Present high-level or technical problems and ask ChatGPT for potential solutions and examples.
    • i.e. Write an Excel formula to add up values in cells B2 through B10.
  • Refine text or code with specific goals.
    • i.e. Here is my resume [paste in text] do you spot any typos? If so, please list them.

For software engineers, more examples include:

  • Develop chatbots for customer service or sales.
  • Create virtual assistants for personal or business use.
  • Integrate ChatGPT with NLP tools to automate tasks.
  • Generate actual content drafts for marketing or advertising campaigns.

Metaphors For What ChatGPT Can (and Can't) Do

There are a few different ways to approach ChatGPT. Here are a few metaphors to get you started:

ChatGPT is like a very tech-savvy intern

ChatGPT is helpful when assisting you in work that might be too repetitive or time-consuming and involves a lot of known data. If you feel comfortable handing off work to ChatGPT that you also can fact-check and fine-tune on your own, you're in good hands. And though interns are helpful, we still need to review the results before putting them into practice; if you submit your work and something goes wrong, do you want to tell your boss, "Well, that's what ChatGPT gave me?"

ChatGPT is like a Rabbi, Mullah, or Priest of the Internet

If the Internet is its sacred text, ChatGPT interprets and conveys its information in a way that's easy to read and digest for as many people as possible. This communication can help visualize and break-down complicated or abstract ideas. It should also be taken with a grain of salt and not be a substitute for your own knowledge or abilities. AI is only as good and bias as the data it's trained on. ChatGPT is only as informed as the Internet allows it to be.

ChatGPT is like a very knowledgeable person (but not a very smart person)

ChatGPT's access to information is impressive. Still, dumb questions don't yield smart answers. ChatGPT will not be able to always figure out the intent or context of your questions unless you explicitly tell it so. This is where the famous expression "garbage in, garbage out" comes in. The better your questions and data, the better ChatGPT can help.

ChatGPT is like a dog that wants to play fetch

It's very excited to play fetch with you (retrieve whatever data is needed to help you solve your problem) but it can't understand what you're trying to do. You can train a dog to fetch a stick (like you can train an algorithm with machine learning to do a specific task), but a dog doesn't understand what a "stick" is like a human understands a stick; a dog can only understand that you want "stick." ChatGPT only wants a treat and to be told it's a good boy. (Janelle Shane)

ChatGPT is like an impressionable child

It learns by example (like algorithms learning from data) and has no idea what it should or shouldn't imitate, unless you tell it so. (Janelle Shane)

ChatGPT is NOT like C-3PO (it's more like a swarm of flies ... or a pile of worms)

Janelle Shane's five principles of "AI Weirdness":

  1. The dangers of AI is not that it's too smart but that it's not smart enough.
  2. AI has the approximate brainpower of a worm.
  3. AI doesn't really understand the problem you want it to solve.
  4. AI, however, will do exactly what you tell it to do (or at least try its best).
  5. AI will take the path of least resistance.

So ChatGPT is less an intelligent machine that's timid and uptight from its own knowledge and servitude and more like a bunch of well-meaning worms doing their best.

image

PART A: ChatGPT's Prompt Portal

Part A provides a beginner's guide to ChatGPT for non-developers and software engineers who want to use ChatGPT's prompt portal to generate responses to their text inputs.

II. Getting Started (Prompt Portal)

Return to top

This section provides steps for getting started with ChatGPT's prompt portal and how to write your first prompts.

Step-by-Step Guide

All you need is a free OpenAI account:

  1. Sign up for OpenAI.
  2. Access the prompt portal.
  3. Enter your text input.
  4. Watch ChatGPT generate its output.

TROUBLESHOOTING: Sometimes when using ChatGPT on the web, if you don't use it after a few minutes, you'll get errors with each new prompt you try to enter. Refreshing your web browser fixes this issue.


Writing Your First Prompt

All you have to do is write your prompt in the "Send a message" text box, press enter, and watch ChatGPT respond.

Try entering this prompt to start: "Tell me a dad joke."


The Art of a Good Prompt

ChatGPT is only as good as your prompt. Here are some starting tips on writing good prompts:

  • Keep your prompt clear and concise.
  • Ask a specific question or give a clear command. Don't write something broad or open-ended.
  • Provide context for your prompt; ChatGPT will not be able to pick this up on its own.
  • Use correct grammar and spelling.
  • Avoid biased or discriminatory language.

A Bad Prompt

Where to eat in Chi.

An OK Prompt

Can you recommend any good restaurants in Chicago?

A Good Prompt

I'm visiting Chicago for the first time this summer and am looking for some great places to eat. Specifically, I'm interested in seafood and italian cuisine. Do you have any recommendations for restaurants that fit this criteria? The closer these recommendations are to mass transit, the better. I don't want to spend more than $100 on a meal if possible.

image

III. Examples of ChatGPT Prompts

Return to top

This section provides real ChatGPT prompt examples and their sources as needed. Each bullet point is a prompt that you would type into ChatGPT, and each sub-bullet is a follow-up prompt that you can write in the same open window.

General Learning, Troubleshooting, Or Brainstorming

  • What are the top 3 books for learning Java? (Mosh)
  • List 10 science fiction books. (OpenAI)
  • What are the key takeaways from Kurt Vonnegut's novel 'Slaughterhouse-Five'? (Mosh)
  • What does the word "monozygotic" mean?
    • Now give me a synonym.
    • Now use it in 10 sentences. (Santrel)
  • How do I become a front-end developer? (Mosh)
  • I want to hire a graphic designer to design my website. We've agreed that they will deliver the first draft in two weeks and offer three iterations free of charge. Any iteration after will be charged at $50/hour. Write a contract draft for us that I'll then review with my lawyer. (Mosh)
  • Write an email to my boss asking for a raise. I've worked at this company for 2 years and successfully delivered several projects on time. (Mosh)
  • I want to learn about the fetch API. What are the steps that I should take?
    • Tell me more about #2.
    • Show me an example of the fetch API and a POST request.
    • Show me this example using async await.
    • What are some good books about the fetch API?
    • What about YouTube videos? (Traversy)
  • Give me some ideas for an app that uses the geolocation API.

Editing, Summarizing, and Translating Text

  • Correct this to standard English: [Paste in text you wish to correct]. (OpenAI)
  • Summarize this for a second-grade student: [Paste in text you wish to summarize]. (OpenAI)
  • Translate this into 1. French, 2. Spanish and 3. Japanese: What rooms do you have available? (OpenAI)
  • Convert movie titles into emoji: Back to the Future, Batman, Transformers, and Star Wars. (OpenAI)
  • A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei. Tl;dr. (OpenAI)
  • Create an analogy for this phrase: Questions are like arrows. (OpenAI)
  • Convert this from first-person to third person (gender female): I decided to make a movie about Ada Lovelace. (OpenAI)

Creating Your Own Study Guide

  • Give me a study plan to learn Python for data science with resources and a timeline. (Tina Huang)
  • Act as a coding tutor that creates study plans to help people learn to code. You will be provided with the goal of the student, their time commitment, and resource preferences. You will create a study plan with timelines and links to resources. Only include relevant resources because time is limited. My first request: "I want to become a data scientist but I do not know how to code. I can study 10 hours per week and only want video resources. I want to learn to code in Python. Create a study plan for me." (Tina Huang)

Generating Project Ideas

  • Act as an expert data scientist and create an exploratory data analysis Python data science project about Naruto the anime. (Tina Huang)

Preparing Your Resume For A Specific Application

  • I'm applying for this role; its application text is below in quotes. Please return keywords that I should include in my resume. "[Paste in the text of the application]."
    • I also need to write a cover letter for this application. What information should I include?
    • Here is the company's website [paste in website URL] are there any details I should add to my resume and cover letter based on their website?
    • I've updated my resume to include these keywords [paste in text of the updated resume] does this resume text properly incorporate the keywords of this job position? Don't mind the structure or format of the resume text.

Preparing For A Job Interview

  • I have three years of experience coding in HTML, CSS, and JavaScript. Write a resume for me. (Mosh)
  • I'm applying for a front-end engineer role at Netflix. Write a cover letter for me. (Mosh)
  • Act as a technical interviewer and ask me 5 questions about JavaScript
    • What is the answer to the first question? (Mosh)
  • You are conducting an interview for a senior Front End developer role. I want you to ask me difficult React.js, HTML, CSS, and JavaScript interview questions. Your response should contain the difficulty rating, but do not give me the answer or any other information. Start by asking me one question. (Web Dev Simplified)
  • Can you give me an HTML question about accessibility? (Web Dev Simplified)
  • Explain JavaScript like I'm a 5-year-old. (Fireship)
  • What are the three most important concepts to know in React.js? (Fireship)

Working In Excel

  • Write an Excel formula to add up values in cells B2 through B10.
  • Write an Excel formula to calculate the profit. The revenue is in cell A2 and the cost is in B2. (Kevin Stratvert)
  • Write an Excel formula to find "Sugar Cookie" in a table and return the price.
  • Write an Excel formula to extract all the text before the @ character in cell A2. (Kevin Stratvert)
  • Write an Excel formula to count the number of unique values in a list. (Kevin Stratvert)
  • Write an Excel macro to send emails. Use the following subject: "Kevin Cookie Company Invoice." Use the following text: "You owe the Kevin Cookie Company X." Take the value X from column A. Send it to the email address listed in column B. (Kevin Stratvert)

Writing Shell (Linux) Commands

  • Write a bash command to find the name of all jpeg files in a directory and write them all to a text file. (Mosh)

Writing Git Commands

  • How do I know how many lines of code I've committed to a Git repository? (Mosh)

Improving Code & Getting Feedback

  • How can I improve this code? [Then paste the code.] (Mosh)
  • Can you provide some feedback on this code? [Then paste the code.] (Traversy)
  • As a senior technical writer, please review and give feedback on the README to this GitHub project: [paste in GitHub URL]. This README acts like documentation for a beginner's guide to ChatGPT. This URL includes an example of documentation that is considered "good" and which I'd like to use as a reference: [paste in URL]. This ChatGPT README should incorporate the DITA documentation concepts of Concept, Procedure/Task, and API. The README should have imperative voice and should avoid implicit voice, adverbs, and filler words that don't add any value.
    • Search this README and return any words with implicit voice, any words that are adverbs, and any filler words.

Extracting Data

  • Based on this Wikipedia article, when was the first Model T made? [Then paste in the article text or wiki url.]
    • Now output that as a Python variable. (Santrel)

Generating Dummy Data

  • Generate dummy data for a table called Customers. Each customer should have an ID, first name, last name, and city. I don't need a Python script. Just give me the data.
    • Create a Python class for storing these objects. (Mosh)
  • I need some sample data. I need a JSON array of 10 coding bootcamps with at least 10 fields each.
    • Take out the programming languages field.
    • Give me the same data in XML. (Traversy)

Generating Documentation

  • Generate the documentation for this API. [Then paste in the GitHub repo URL.] (Traversy)
  • I need to make a glossary for a study guide I'm making on ChatGPT. What key terms should I include in this new glossary to help beginners who are new to ChatGPT, AI, and machine learning?

Understanding and Fixing Errors

  • Uncaught TypeError: Cannot read property 'bar' of undefined (Mosh)
  • Can you tell me what this error message means and how to fix it? [Then paste in code and error message.] (Traversy)

Writing Tests

  • Can you generate a unit test for the searchStates function using JEST? [Paste in code.] (Traversy)

Building An API

  • I need an API built with Express.js to return the list of products. Each product should have attributes like ID, title, description, price, and imageURL.
    • Modify the code and retrieve the products from a MongoDB database.
    • Use TypeScript in this code.
    • Generate this API using Python and FastAPI. (Mosh)

Natural Language Programming

  • I need a REST API built with Rust. It should have products with the fields of id, name, description, and category_id. The category_id should have a relationship with another resource called categories. Categories should have an id and a name field. Let's use an SQLite database. Use any frameworks and libraries that you see fit. (Traversy)

Python Examples

  • Write a python function for generating a random password.
    • What does [line of code I don't understand] do in this code?
    • What is the time complexity of this function?
    • Write unit tests for this function.
    • Convert this Python code to JavaScript. (Mosh)
  • How can I scrape a web page using Python? (Traversy)
  • Give me a function to convert c to f in Python. (Traversy)

HTML, CSS, and JavaScript Examples

  • Write the HTML and CSS code for displaying a card. Add a button below the card content. When I hover my mouse over the card, I want the card to slightly slide up.
    • Can you rewrite this code using TailwindCSS?
    • When I click on the button, send an HTTP request to /api/products. Instead of the fetch API, use Axios. (Mosh)
  • I need the HTML and CSS in separate files for a blog homepage with a navbar with a logo on the left and links on the right. A hero area with a background image and centered text. Under that should be 3 cards in a horizontal flexbox. The cards should have light gray background and a box shadow. Use light blues and greens and use the poppies font. (Traversy)
  • Give the background-color CSS code for a color like a blue sky at dusk. (OpenAI)

React Examples

  • Create a React component for displaying a card.
    • Deconstruct the props parameter. (Mosh)
  • Create a basic react component that says hello world. CODE ONLY.
    • Add a button that toggles the visibility of the text.
    • Now write a test for this app using Playwright.
    • Document this code. (Fireship)

SQL Examples

  • Write an SQL query to generate a table called products with 4 columns. (Mosh)
  • Write an SQL query to generate a table called products with these columns: Id (int), Title (string), Category (int), unitPrice (float), and imageUrl (string). (Mosh)
  • Write an SQL query to retrieve the top 5 customers in Manhattan.
    • Revise this query and join the customers table with the orders table to find out how much each customer has spent. Then pick the top 5 who have spent the most. (Mosh)

image

PART B: ChatGPT's API

Part B provides a beginner's guide to ChatGPT for software engineers who want to integrate ChatGPT into their own applications.

IV. Getting Started (ChatGPT's API)

Return to top

This section reviews the technology and packages needed to get started with ChatGPT's API and how to run this guide's example code.

System Requirements

ChatGPT

Mac

  • macOS 10.15 or later
  • At least 4GB of RAM
  • 2GHz Intel Core i5 or equivalent CPU

Windows:

  • Windows 10 or later
  • At least 4GB of RAM
  • 2GHz Intel Core i5 or equivalent CPU

Linux:

  • Ubuntu 18.04 or later, or a similar Linux distribution
  • At least 4GB of RAM
  • 2GHz Intel Core i5 or equivalent CPU

Installing Dependencies

Both chatbot examples in this guide are written in Python, so download the latest version of the following:

As of this writing, this guide is using the API model version "gpt-3.5-turbo," though this may be updated in a future release.

Though this guide focuses on Python, other languages can use OpenAI's API. For example, Fireship has a great video on using ChatGPT to build a "Hello, World" React app, and Web Dev Simplified made a great video reviewing the basics of creating a chatbot with vanilla JavaScript.


Running the Code

This GitHub includes the Python files chat_cli.py and chat_ui.py. These are simple examples that we'll use to visualize ChatGPT's API in action. To run the code in either .py file:

  1. Open a new terminal.
  2. Run the python command and the name of the file. (i.e python chat_cli.py or python chat_ui.py).
  3. The terminal will provide next steps.

When you want to stop either program:

  1. Go into the terminal where you're running the chat.
  2. On your keyboard, keypress control + c.

image

V. Usage

Return to top

This section introduces the actual uses of the ChatGPT API and reviews the beginner examples found in chat_cli.py and chat_ui.py. These concepts will be explored even further in the API Reference section.

Overview of Features

ChatGPT is unique in how much it can offer to users. Notable features include:

  • Easy integration: you only need a few lines of code to add ChatGPT into your app. See chat_cli.py and chat_ul.py to see this code in action.
  • Customizable response parameters: it's possible to control a response's length, its temperature (rate of randomness), the number of responses at a time, and more.
  • Rich responses: ChatGPT can be flexible with the type of content it responds with, including longform prose, bullet-point lists, and code snippets.
  • Multi-turn conversations: ChatGPT can remember previous user inputs and take them into consideration when generating new responses.

ChatGPT is constantly changing and updating. To see all updates made so far, please refer to OpenAI's ever-evolving release notes.


Using chat_cli.py (ChatGPT in the Command Line)

This is a very simple example of how to build your own chatbot that runs in the command line with ChatGPT. The file's main feature is its chatbot function, which is broken down like so:

message_history = []

We first create an empty list called message_history that'll store our chat's conversation. We then create a while loop that'll repeat until the user manually stop the app. The following code snippets live inside this while loop.

user_input = input("USER PROMPT > ")
print(f"YOU ASKED: '{user_input}' ...")

We prompt the user to input data, which we store in our new variable user_input. Printing user_input confirms to the user what they entered.

message_history.append({"role": "user", "content": user_input})

We then append our new user_input into message_history, as well as its role as a "user." We then create a try-except block that'll handle potential errors.

completion = openai.ChatCompletion.create(
  model="gpt-3.5-turbo",
  messages=message_history,
  max_tokens=1024,
  n=1,
  stop=None,
  temperature=0.5,
)

This is how we finally begin talking to ChatGPT - by creating a completion. This basic openai.ChatCompletion.create() method includes the following:

  • model: the specific GPT-3 language model we're using.
  • messages: our chat history.
  • max_tokens: the max number of tokens to generate in a response.
  • n: the number of responses to return at a time.
  • stop: define any specific conditions that'll stop a response.
  • temperature: the level of randomness in a generated response; from 0 to 1, the closer to 1 - the "higher" the temperature - the more random the response.
reply_content = completion.choices[0].message.content
print("CHATGPT RESPONSE:", reply_content)

Our new reply_content variable extracts and stores our API's completion. The API provides a lot of information, but reply_content is only concern with the content of the actual message. Printing reply_content allows the user to see the API's response and only the information they want to see.

message_history.append({
  "role": "assistant",
  "content": reply_content
})

We then append our new reply_content to message_history, and note its role as an "assistant."

This cycle repeats until the user manually stops the app with the keypress control + c.

except openai.error.OpenAIError as error:
  print("OpenAI API error:", error)

All the above code under the try block is executed when there are no issues. When issues do come up, this except block kicks in. This is an exception handler that'll print any errors to the user for future troubleshooting.


Using chat_ui.py (ChatGPT Deployed on Localhost)

This an example of how to deploy a simple chatbot locally in your web browser. The overall structure is similar to chat_cli.py, but it's worth nothing this important difference:

messages = [{
    "role":
    "system",
    "content":
    "You are a music curator with decades of experience in the music industry who helps people discover great new music from any era or genre. You value the classics yet always try to steer new listeners to discover music they might not have heard before."
}]

By defining messages early with this specific "system" content, we're setting the context for our chatbot. With this example, the chatbot now acts like a music curator. However, it's easy to change the system's content to set the chatbot to talk like a financial planner, or a sassy middle school teacher.

image

VI. API Reference

Return to top

This section breaks down ChatGPT's overall documentation with related links on obtaining API keys and example projects to get you started. When in doubt, you can always go straight to the source and explore from there: https://platform.openai.com/


API Documentation & Quick Links

For the scope of this guide, it's best to start with these documentation sections:

  1. Introduction
  2. Quickstart
  3. Text completion
  4. Chat completion

Get started

  • Introduction
    • Overview
    • Key concepts: Prompts, Tokens, and Models
    • Next steps
  • Quickstart
    • Introduction: An intro to "Completion"
    • Start with an instruction
    • Add some examples
    • Adjust your settings: An intro to "Temperature"
    • Build your application (Node.js or Python/Flask)
    • Pricing
    • Closing
    • Next steps
  • Libraries
    • Python
    • Node.js
    • Community libraries (multiple languages)
  • Models
    • Overview
    • Model compatibility: API endpoints and model names
    • Model updates
    • GPT-4 (limited beta)
    • GPT-3.5
    • DALL-E (beta): generate and edit images using NLP
    • Whisper (beta): convert audio into text
    • Embeddings: convert text into a numerical form
    • Moderation: detection of sensitive or unsafe text
    • GPT-3
  • Tutorials
    • Website Q&A with Embeddings

Guides

  • Text completion
    • Introduction
    • Prompt design: showing and telling, providing quality data, checking your settings, and more
    • Inserting text
    • Editing text
  • Chat completion
    • Introduction: examples of the API response format and managing tokens
    • Instructing chat models
    • Chat vs Completions
    • FAQ
  • Image generation w/ DALL-E
    • Introduction
    • Usage: Generations, Edits, and Variations
    • Language-specific tips: Node.js, TypeScript, and error handling
  • Fine-tuning
    • Preparing your dataset
    • Advanced usage
    • Weights & Biases
    • Example notebooks: Classification and Question answering
  • Embeddings
    • Overview
    • Use cases
    • Limitations & risks
  • Speech to text w/ Whisper
    • Overview
    • Quickstart: Transcriptions and Translations
    • Supported languages
    • Longer inputs
    • Prompting
  • Moderation
    • Overview
    • Quickstart
  • Rate limits
    • Overview
    • Error mitigation
    • Rate limit increase
  • Error codes
    • API errors: 401, 429, and 500
    • Python library errors
  • Safety best practices
    • The Moderation API
    • Adversarial testing
    • Human in the loop (HITL)
    • Prompt engineering
    • Know your customer (KYC)
    • Constrain user input and limit output tokens
    • Allow users to report issues
    • Understand and communicate limitations
    • End-user IDs
  • Production best practices

Chat Plugins (limited alpha)

Other Helpful Links


Obtaining an API key

After you've created an OpenAI account, head to the API keys page and follow its steps. Always keep this key safe and secret.


API Example Applications

ChatGPT's API is a powerful tool that can address a wide range of problems. OpenAI's Examples page includes a long list of example applications that use ChatGPT in different use cases. Here are some popular examples:

Answering & Conversing

Classifying & Extracting

Coding & Translating

Generating & Transforming

image

PART C: Conclusion & References

Part C provides credits, cited sources, contribution steps, and a glossary for both non-developers and software engineers.

VII. Giving Thanks

Return to top

This section includes the credits and cited sources that made this guide possible, as well as how you can contribute to this open-source guide.

Closing Credits

A shout-out to Nick Arocho for his initial guidance on where to get started with ChatGPT. Videos by The AI Advantage and sentdex helped me get started with ChatGPT's API in Python and Gradio. Doodles by Doodle Ipsum. And again, Janelle Shane's book is a must-read.


Cited Sources

The following videos were vital in helping me make this guide. For further learning, I encourage you to watch these videos by the following creators:


Open-Source Contributing

Contributions to this guide are welcomed.

This guide aims to solve the problems of accessibility with getting started with ChatGPT, which can be confusing for developers new to AI. This guide is build with markdown and Python.

Goals & Objections

This guide has the following goals and objectives:

  • Get rid of any README typos or improper grammar.
  • Refactor chat_cli.py and chat_ui.py to be as simple and readable as possible.
  • Create pytest for chat_cli.py and chat_ui.py.
  • Include JavaScript API code samples to mirror the logic and workflow of chat_cli.py and chat_ui.py.
  • Flesh out the API Reference section to include more concrete examples and breakdowns of key concepts so that users don't have to always click on the reference links. (i.e. Why do we call it a "Completion"? Can we quickly explain what it is in this README?)
  • Add more necessary terms to this README's Glossary.
  • Expand the Introduction section to include brief histories of AI, machine learning, OpenAI, and ChatGPT. (No more than a paragraph for each.)
  • Add more helpful prompts to the Examples of ChatGPT Prompts section.
  • Translate README text into another language for those whose native reading language is not English.
  • Include screenshots and more helpful visual aids.

Contributions that help achieve these goals are welcomed.

Coding Standards & Conventions

Please follow these coding standards and conventions when making changes to the codebase:

  • Use consistent indentation.
  • Use descriptive variable names and avoid abbreviations or acronyms that are not widely recognized.
  • Use comments to explain non-obvious code.

Bug Reporting & Issue Tracking

If you encounter a bug or issue, please report it using the issue tracker. To ensure that we can reproduce and fix the issue, please provide the following information:

  • Provide clear steps to reproduce the bug or issue.
  • Include any relevant error messages or screenshots.
  • Indicate the severity of the bug or issue.

Submitting Changes

To contribute:

  1. Fork this repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes, test your changes, and commit them with descriptive commit messages.
  4. Push your changes to your forked repository.
  5. Open a pull request to this repository.

Your pull request will be reviewed and merged if it meets our guidelines and standards. Thank you for contributing to our project.

Code of Conduct

We expect all contributors to adhere to the code of conduct based on the Contributor Covenant.

Don't be a dork. Be decent.

image

VIII. Glossary

Return to top

This section provides a glossary for the terms frequently used in this guide that may not be familiar with all readers.

Artificial Intelligence (AI)

The ability of machines to perform tasks that would typically require human intelligence, such as learning, problem-solving, and decision-making.

Machine Learning

A subfield of AI that involves training machines to learn from data, so they can make predictions or decisions without being explicitly programmed.

Natural Language Processing (NLP)

A subfield of AI that focuses on the interaction between machines and humans using natural language, such as speech or text.

Chatbot

A computer program that uses NLP to simulate conversation with human users, typically through messaging applications or voice assistants.

Deep Learning

A subfield of machine learning that involves training neural networks with many layers to recognize patterns in data.

Neural Network

A type of machine learning algorithm that is modeled after the structure of the human brain and consists of interconnected nodes or neurons that process information.

Generative Model

A type of AI model that generates new data that is similar to the training data it was trained on, such as text or images.

Transformer Model

A type of neural network that is widely used for NLP tasks, such as language translation, text summarization, and question answering.

API (Application Programming Interface)

A set of rules and protocols that allows different software applications to communicate with each other. In the context of this project, it refers to the programming interface provided by ChatGPT that allows developers to integrate the model into their own applications.


© 2023 Brady Gerber. All Rights Reserved.

Return to top

Releases

No releases published

Packages

No packages published

Languages