joshcho / ChatGPT.el

ChatGPT in Emacs
GNU General Public License v3.0
397 stars 34 forks source link

Support for ChatGPT API #38

Closed jimeh closed 1 year ago

jimeh commented 1 year ago

The ChatGPT API has now launched.

Fuco1 commented 1 year ago

I think at this point it would be nice to create a dedicated "low-level" SDK for all of the openai APIs, including embeddings or completions which are super useful. We can then build various "front-end" UI tools for emacs, such as

The possibilities of having this on an emacs key binding are freaking wow.

How about creating an organization emacs-openai where we could gather all the AI tools for Emacs? I made this recently but it could be cleaned up and packaged as more general tool as well.

joshcho commented 1 year ago

I will be working on incorporating the ChatGPT API over the next couple weekends. @Fuco1 makes some good points; a collaborated dedicated effort sounds appropriate.

jimeh commented 1 year ago

The API looks exciting, but I believe it's worth keeping the current method of communicating with ChatGPT as an option after API support is added.

I'm mostly saying that because the API does require a paid account, and even when paying, the pricing is usage based compared to ChatGPT Plus which is a fixed monthly fee for what I at least assume is unlimited usage.

Fuco1 commented 1 year ago

It's worth noting that the usage based pricing unless you are extreme customer is order of magnitude less expensive. With the usage-based scheme, the $20 gives you ten million tokens, which is 20 thousand pages of conversation. Hardly what you would ever use with the normal chat.

OTOH, the API does not actually implement the chatgpt as available on chat.openai.com. You would have to emulate the way they pass context and conversation history to the model, which I'm not sure is public knowledge.

karthink commented 1 year ago

You would have to emulate the way they pass context and conversation history to the model, which I'm not sure is public knowledge

According to the API docs, you can do this by sending the whole conversation in each POST request. I imagine this will increase the token cost of conversations considerably.

Fuco1 commented 1 year ago

Actually, there is an organization https://github.com/emacs-openai which exists since january. It's a good place to develop a generic API package and some goodies.

jcs090218 commented 1 year ago

I'm creating a generic API package for OpenAI. It already supports most of the requests, including ChatGPT. Feel free to try it out! :D

joshcho commented 1 year ago

Indirectly supported via chatgpt-wrapper, see https://github.com/joshcho/ChatGPT.el/commit/c38c9150b4f156c90c44f330aa0cd2497d66f8c5