Skip to content

Latest commit

 

History

History
32 lines (19 loc) · 2.69 KB

README.md

File metadata and controls

32 lines (19 loc) · 2.69 KB

Building a GPT-3 Knowledge Base App (Next.js)

YouTube Video

This is code for building a GPT-3 powered knowledge base application using Next.js. It's adapted from the example in the book Exploring GPT-3. To deploy and run this code you'll need the following:

Getting Started

  1. Watch the tutorial video.
  2. Create and/or copy an API key from the OpenAI API Keys Page.
  3. Click the 'Deploy with Vercel' button below to begin deploying this app to your vercel.com account.

Deploy with Vercel

  1. Enter your OpenAI API key for the environment variable named OPENAI_API_KEY.
  2. Add your own content to the documents defined in the routes/answers.json file.
  3. Test the app by visiting the Vercel generated app URL.

Using an answers file

By default the code uses a JavaScript array of documents in routes/answers.json for the knowledge base. Alternately, you can store documents in an answers file. There is an example answers file named answers.jsonl in the root, along with a file named upload.js that provides code you can use to upload an answers file to the OpenAI API. If you use the answers file, you'll also need to setup a secret / environment variable named ANSWERS_FILE with the OpenAI filename for the value.

An array of documents is used by default because because it's simpler. However, there are two primary advantages to using a documents file. First, you can include more than 200 documents. Second, the the API will throw a 404 error if there isn't a matching result. Meaning, the app could be setup to log questions that should be added to the documents - unanswered questions. This is not currently a feature but is planned for a future release.

For more details on using answer files, see the OpenAI Documentation.

Question and comments

If you have questions or comments, please post them on the Exploring GPT-3 Discord Server or in the GitHub Issues page for this repository. Thanks so much!