Git Product home page Git Product logo

groceries-chatgpt-plugin's Introduction

Building an Open AI plugin with Codespaces

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

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.

.devcontainer

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.

.vscode

The .vscode folder contains:

  • json.code-snippets file that helps to quickly write the manifest file for the OpenAI plugin. (โœจ Tip: Type manifest-openai, press enter to accept the template, and tab 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).

๐Ÿ’ป Code for the FastAPI app

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.

๐Ÿง  Code to turn the FastAPI app into a ChatGPT plugin

  • ai-plugin.json is a JSON manifest file that defines relevant metadata for the plugin. Learn more in the OpenAI docs.

๐Ÿ’ฌ Register the app on ChatGPT

  • Go to PORT and set visibility of port 8000 to public
  • Copy the link and paste it on ChatGPT plugin

groceries-chatgpt-plugin's People

Contributors

minsa110 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.