Giter Club home page Giter Club logo

openai-plugin's Introduction

Building an Open AI plugin with Codespaces

โ˜๏ธ To deploy your app on Azure using Azure Developer CLI and Container Apps, see the demo-azd branch.

This is a sample repo for developing OpenAI plugin using the FastAPI framework. There are two main parts of the repo:

  • Code to help setup development environment for FastAPI framework
  • Code for the FastAPI app

๐Ÿ“ฆ 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.

๐Ÿ’ป 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.)
    Write a simple TODO app using FastAPI, that lets the user add TODOs, list their TODOs, list specific TODOs, and delete TODOs, ensuring that the app stores todo_id for each todo item. 
    
    Assume that a docker container is running for Redis, running and accessible at host "redis" and port 6379 as specified in the docker-compose.yml file. Make use of the Redis container for persisting data from the TODO 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.
    
    Mount static files in the .well-known directory to the path /.well-known, which should at minimum contain ai-plugin.json that serves (as JSON).
  • 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.

๐Ÿ’ฌ 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

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