sturdy-dev / codereview.gpt

Reviews your Pull/Merge Requests using ChatGPT
MIT License
529 stars 63 forks source link

Convert Chrome Extension to ChatGPT NPM module #14

Closed nickveenhof closed 1 year ago

nickveenhof commented 1 year ago

As I understood the used API was deprecated and not supported in the long run. I got here when trying to see if I could use the latest model + increase the token size. It also helps if you have a paid account to keep using the extension.

The following changes were made

  1. Use of the NPM ChatGPT module https://www.npmjs.com/package/chatgpt & in effect, the official API as the other methods will and are no longer supported: https://github.com/transitive-bullshit/chatgpt-api/issues/453
  2. Use of native options in the Chrome Extension to store the Open AI API key
  3. Truncate long patches, as ChatGPT has a maximum amount of tokens. It adds a warning if this is the case
  4. Clean up, as many of the functions that supported the streaming are no longer needed.
  5. The prompt has been split in 3 parts + a system message. 1 with the instructions, 1 with the context/description and 1 with the actual patch.

Note: I had to add wasm permissions to the extension due to the addition of this library.

ltickett commented 1 year ago

I wasn’t able to save an API key in the options dialog. Is there a trick?

When I hardcoded my generated token it returns 429 and says I need a paid plan. Which is confusing because i'm already paying for ChatGPT. Perhaps the API is a separate service? 🤔

ltickett commented 1 year ago

Thanks for fixing the issue with the missing options.js @nickveenhof 🚀

nickveenhof commented 1 year ago

looks good from my end, just if you could take care of that merge conflict, and I can re-approve this

Done. I had to refrain myself from not optimizing further. That's for a new PR