josStorer / chatGPTBox

Integrating ChatGPT into your browser deeply, everything you need is here
MIT License
10.03k stars 755 forks source link

How does this work? #420

Open Kimeiga opened 1 year ago

Kimeiga commented 1 year ago

I installed the chrome extension and without even having to provide any credentials, the free models seemed to work immediately

specifically these ones: chatgptFree35: { value: 'text-davinci-002-render-sha', desc: 'ChatGPT (Web)' }, chatgptFree35Mobile: { value: 'text-davinci-002-render-sha-mobile', desc: 'ChatGPT (Mobile)' },

I tried inspecting the webviews of the application via the associated button that launches chrome devtools on the extension page, but i couldn't follow what was happening in the network requests.

I'm curious how this works because I was trying to research for how to potentially call gpt from the backend of an application, and I was just looking around for if there were any free workarounds before paying for the API.

I realize the function that is calling the api is likely generateAnswersWithGptCompletionApi() from openai-api.mjs; but the extension worked with the default model without me even having to input my api key yet, so I'm confused.

Very impressed with this project; thank you for releasing all of this for free! :)

josStorer commented 1 year ago

By default, this extension uses reverse-engineered interfaces from chat.openai.com. Because the browser extension can directly access your cookie, you can use it for free after installation, just like sending a message on chat.openai.com.

josStorer commented 1 year ago

https://github.com/josStorer/chatGPTBox/blob/master/src/services/apis/chatgpt-web.mjs#L57

Kimeiga commented 1 year ago

would it be possible at all to use this strategy to write a script that runs on a server and responds with chat gpt to user's messages with me hard coding the cookie that was present on my browser? or almost certainly that cookie would expire after some time?

josStorer commented 1 year ago

Yes, you can. The cookie usually expire after one month.