Coder Social home page Coder Social logo

vasu018 / chatgpt_plugins Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abhinav-upadhyay/chatgpt_plugins

0.0 0.0 0.0 6.04 MB

Code for the article showing how to use the function call feature of OpenAI's chat APIs to create ChatGPT plugins

Home Page: https://codeconfessions.substack.com/p/creating-chatgpt-plugins-using-the

License: MIT License

Python 73.24% HTML 26.76%

chatgpt_plugins's Introduction

Creating ChatGPT Plugins using the Function Call Feature

The introduction of the function call features in the chat completions API of OpenAI opens up the possibilities of implmenting plugins similar to the plugins supported in ChatGPT. However, OpenAI documentation does not show how this can be done. I took the opportunity to try to do this myself by building a chat application powered by GPT and then using the function call feature to design and implment plugins.

Write-Ups

Structure of a Plugin

Creating a plugin in this system requires doing two things.

  • Extend the PluginInterface class, which defines the API that a plugin should follow
  • Implement the 4 API methods expected by a plugin. These are:
    • get_name: Returns the name of the plugin
    • get_description: Provides a description of what the plugin does
    • get_parameters: Gives a JSON specification of the parameters of the plugin.
    • execute: This is the meat of the plugin, where it receives the parameters as declared by it in the get_parameters method and it executes its function.

Implemented Plugins

Setup Requirements for Running This Locally

Install following Python packages in a virtual environment:

pip install openai --upgrade
pip install flask requests python-dotenv

Create an OpenAI API Key

OPEN_AI_KEY="<your api key here>"

Create Brave Search API Key

This is required for the web search/browser plugin. For this, you need to create an account with Brave at: https://brave.com/search/api/. Next, you need to create an API key from Brave. You can select the Free plan to start with. The free plan allows 2000 requests per month. Once you have generated the key, put this also in the .env file as shown below:

BRAVE_API_KEY="<your Brave API key>"

Generating a key for Flask

Flask also needs a secret key in order to create a user session. You can use something like uuid to generate the key. For example:

import uuid
print(str(uuid.uuid4()))

Put the generated value from the above code in the .env, as shown below:

CHAT_APP_SECRET_KEY="<your secret key>"

Running the Application

Use the following command to run the application:

flask --app run.py run

Demo

Following is the web search plugin in action: Web search plugin in action

chatgpt_plugins's People

Contributors

abhinav-upadhyay 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.