The live demo version from VS Code Livestream can be found in the starter
branch.
This is a sample repo for developing OpenAI plugin using the FastAPI framework. There are three main parts of the repo, with details of each below:
- 📦 Code to help setup development environment for FastAPI framework
- 💻 Code for the FastAPI app
- 🧠 Code to turn the FastAPI app into a ChatGPT plugin
Create a Codespaces by clicking <> Code -> Codespaces -> Create codespaces on {branch}, and a containerized development environment will be set up for you on the cloud based on the contents of the following files.
The .devcontainer
folder contains files for defining a containerized development environment, specific to building this FastAPI app. It's set up in a way that makes it easy for you to use with GitHub Codespaces as well: launch a Codespace using this template, and you're ready to start developing! Learn more about devcontainers here.
The .vscode
folder contains:
json.code-snippets
file that helps to quickly write the manifest file for the OpenAI plugin. (✨ Tip: Typemanifest-openai
, pressenter
to accept the template, andtab
through the fields to quickly generate the manifest)settings.json
file that helps to validate the manifest file (ai-plugin.json
) against this schema.launch.json
file that helps to customize Run and Debug (this is not necessary for this repo, and you can easily have VS Code automatically create one for you).
If you have access to GitHub Copilot, try it out to help you write code faster. To test the app, run uvicorn main:app
in the integrated terminal, or press F5
, and debug CRUD operations at .../docs.
main.py
is the code for the API plugin. (✨ Tip: Generate the code using Copilot. The following is an example prompt to use in the Copilot chat view (Ctrl+Alt+I
) (learn more).)Write a simple Grocery List app using FastAPI, that lets the user add grocery items, list their items without requiring quantity, list a specific item, and delete an item, ensuring that the app stores item_id for each item. Assume that a docker container is running for Redis, running and accessible at local host and port 6379. Make use of the Redis container for persisting data from the Grocery List app. Include a main section which will run this app using uvicorn. The Python module where I save this code will be called main.py.
openapi.yaml
is a specification that dictates how to define the schema of the API.
ai-plugin.json
is a JSON manifest file that defines relevant metadata for the plugin. Learn more in the OpenAI docs.
- Go to PORT and set visibility of port 8000 to
public
- Copy the link and paste it on ChatGPT plugin