AkashKarnatak / chatgpt-anywhere

ChatGPT Anywhere is a browser extension skeleton for seamless ChatGPT integration, interacting directly with the ChatGPT's browser API and offering developers a cost-efficient solution by eliminating the need for OpenAI's paid API calls.
GNU Affero General Public License v3.0
23 stars 5 forks source link

ChatGPT Anywhere

Why pay for ChatGPT's API when it's free in the browser?

ChatGPT Anywhere is a browser extension skeleton for seamless ChatGPT integration, interacting directly with the ChatGPT browser API and offering developers a cost-efficient solution by eliminating the need for OpenAI's paid API calls.

Features

Setup and Installation

  1. Clone the repository:

    git clone https://github.com/AkashKarnatak/chatgpt-anywhere.git
  2. Navigate to the project directory:

    cd chatgpt-anywhere
  3. Install dependencies:

    npm install
  4. Build the extension for chrome and firefox:

    npm run build
  5. After building, two folders named chrome-extension and firefox-extension will be created. You can now load these extensions into their respective browsers for testing.

Usage: Building with OpenAIConversation API

The OpenAIConversation class provided in the extension/openai.js file allows developers to easily integrate ChatGPT conversations within their browser extensions. Each instance of OpenAIConversation represents a new conversation with ChatGPT, and the ask method preserves the conversation history for ongoing interactions.

To use the API in your extension, follow these steps:

  1. Access OpenAIConversation API: content-script.js has access to the OpenAIConversation class defined in openai.js.

  2. Create a New Conversation Instance: Create a new instance of OpenAIConversation. This instance will handle the communication with ChatGPT. For example:

const conv = new OpenAIConversation({
  onMessage: (content) => {
    // Handle the response from ChatGPT here.
    // Eg: Changing text content of a div
    console.log(content);
  },
  onError: (error) => {
    // Handle any errors here.
    console.error(error);
  }
});
  1. Initiate a Conversation: Use the ask method to send a message to ChatGPT and start the conversation. Subsequent calls to ask will continue the conversation with the preserved history. For example:
conv.ask('Why does the sky appear blue?');
  1. Handle Responses and Errors: Implement the onMessage and onError callbacks to process responses and handle errors respectively.

  2. Integrate into Extension Functionality: Use the conversation object within your extension's functionality to enable dynamic interactions with ChatGPT.

Extensions Built on ChatGPT Anywhere

If you have developed an extension using "ChatGPT Anywhere" and would like to feature it here, please share details about your project in this issue.

Contributing

Contributions are welcome! If you find a bug, have an idea for an enhancement, or want to contribute in any way, feel free to open an issue or submit a pull request.

License

This project is licensed under the AGPL3 License. For details, see the LICENSE file.