Skip to content

With this minimal code and instructions, you can get started on developing a ChatGPT Plugin. It's perfect as an example for your first plugin development.

Notifications You must be signed in to change notification settings

yoshinorisano/chatgpt-simple-todo-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Simple TODO ChatGPT Plugin

This is a proof-of-concept for a ToDo ChatGPT Plugin, implemented using Python.

The primary value of this repository is to replicate the experience of developing the ChatGPT plugin for the first time. This will allow you to rapidly acquire experience in developing a ChatGPT plugin.

This repository includes all the necessary code to run the plugin.

Here is a demonstration of the TODO plugin in action. screen capture of the TODO plugin demo

Requirements

  • Basic understanding of Python programming, JSON, and YAML.
  • Access to ChatGPT Plugins. If you don't currently have access, you can apply for it here.
  • (Optional) Access to ChatGPT GPT-4 for code generation. You can also use my code if you cannot generate expected code.

Additional Information

Since making this repository public, I've noticed that the original code is available. However, it's still worth trying out this repository compared to the original. Because the original repository lacks sufficient explanation, which could be a hurdle for beginners. As of May 14, 2023, it reflects the latest information, which is beneficial for beginners as well.

Instructions

Here is my memo. You can also follow this instruction.

  1. Watch the instruction video.

ChatGPT plugins developer experience: https://openai.com/blog/chatgpt-plugins

As you may notice, the video content is getting older.

  1. Generate a simple TODO app code using ChatGPT.

Open ChatGPT and change GPT-4 mode. Then execute the following prompt. This prompt is from the instruction video. (Thanks for the provided instruction video from OpenAI!)

Used Prompt:

Write a simple TODO app using FastAPI, that lets the user add TODOs, list their TODOs, and delete TODOs.

Include a `__main__` section which will run this app using uvicorn. The Python module where I save this code will be called `main.py`.

In addition to the normal endpoints, include a route `/.well-known/ai-plugin.json` which serves (as JSON) the contents of `./manifest.json`, located in the same directory as `main.py`. Exclude this route from the OpenAPI spec, and don’t serve any other static content.

You will get differnt code (compare to my main.py) and will not work properly. Retry generating the code, and if that does not work, modify it manually.

Add the following code to serve openapi.yaml.

# Added manually after code generation.
@app.get("/openapi.yaml", include_in_schema=False)
async def get_openapi_yaml():
    return FileResponse('openapi.yaml')
  1. Sing up CodeSandbox for developing and deploying our app.

  2. Create a python environment on CodeSandbox.

  3. Add dependency libraries to requirements.txt

fastapi
uvicorn
  1. Restart the environment to create the updated container for us.

  2. Copy the content of the generated code and paste it into the main.py.

  3. Create a manifest.json on the top directory.

Here is manifest.json. Replace <YOUR_SERVER> in https://<YOUR_SERVER>/openapi.yaml with your environment.

{
    "schema_version": "v1",
    "name_for_human": "TODO Demo",
    "name_for_model": "todo_demo",
    "description_for_human": "TODO demo app",
    "description_for_model": "An app for managing a user's TODOs",
    "auth": {
        "type": "none"
    },
    "api": {
        "type": "openapi",
        "url": "https://<YOUR_SERVER>/openapi.yaml",
        "is_user_authenticated": false
    },
    "logo_url": "https://upload.wikimedia.org/wikipedia/commons/5/50/Yes_Check_Circle.svg",
    "contact_email": "[email protected]",
    "legal_info_url": "http:https://www.example.com/legal"
}
  1. Restart again to deploy the app.

  2. Access the https://<SERVER NAME>/openapi.json to get OpenAPI specification.

I got the specification like this:

{"openapi":"3.0.2","info":{"title":"Simple TODO API","description":"This is a very simple TODO API","version":"1.0.0"},"paths":{"/todos":{"get":{"summary":"Get Todos",
[...]
  1. Copy the OpenAPI specification and paste it into Swagger Editor to convert json to yaml. Then, the Swagger Editor will pop up the dialog "Would you like to convert your JSON into YAML?" and hit OK button. Create openapi.yaml on the top directory and paste the yaml.

  2. Almost done. All you need to do is to register the plugin with ChatGPT. Open ChatGPT and then open Plugin store and then click Develop your own plugin. After that, follow the instruction shown in the display.

  3. Voilà! ChatGPT now uses our TODO plugin.

About

With this minimal code and instructions, you can get started on developing a ChatGPT Plugin. It's perfect as an example for your first plugin development.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages