/logseq-chatgpt

Talk to ChatGPT directly from Logseq

Primary LanguageJavaScriptMIT LicenseMIT

UPDATE: Project not maintained. Please use logseq-plugin-gpt3-openai

DISCLAIMER: The code needs some serious testing and polishing, and it's far from feature complete. All feedbacks welcome. I'll submit it to the marketplace once it becomes more mature.

logseq-chatgpt

logseq-chatgpt is a Logseq plugin that lets you interact with ChatGPT directly from Logseq, similar to the Logseq GPT3 plugin.

Usage

In Logseq, enable developer mode in Settings > Advanced. Download the repo, unzip it, and load the plugin manually by choosing the "logseq-chatgpt" folder.

In Logseq, type / to find and run the chatgpt-reply command, then wait for the response from ChatGPT to show up. Here's a demo:

The plugin only works for Chrome (probably other Chromium-based browsers as well) at the moment.

Setup

To use this plugin, some setup is needed, but I assure you it's very simple:

  • Close Chrome, and launch it with a command line argument --remote-debugging-port=9222 It's recommended to create a shortcut to always run Chrome with this option, see the guidance, but you can also do it manually:

    • Windows

      /path/to/chrome.exe --remote-debugging-port=9222
      
    • Mac

      /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
      
    • Linux

      chrome --remote-debugging-port=9222
      
  • Login to ChatGPT and keep tab open
    https://chat.openai.com/chat

    Make sure you're logged in while using this plugin (refresh the page if the session expires).

How it works

As I'm writing this, there's no official API for ChatGPT. Though there are some reverse-engineered APIs out there, there's no guarantee that they'll always work reliably, as I've seen OpenAI trying very hard to kill some of these efforts.

Therefore, logseq-chatgpt takes a different yet more straightforward approach: it assumes users have already logged into ChatGPT, so it only needs to automate the process of entering inputs, and fetching responses. I use puppeteer-web to do it, the communication is done via the Chrome DevTools Protocol, and that's we need to run Chrome with --remote-debugging-port.