r/reactnative • • Jan 31 '23

I reverse-engineered ChatGPT to create a React Native wrapper. Full access to all its features - serverless, streamed responses, keep track of conversations, etc. Expo compatible

437 Upvotes

68 comments sorted by

102

u/mcdngr Jan 31 '23

This isn’t “reverse engineering”, but cool nonetheless

-8

u/rauliyohmc Jan 31 '23 edited Jan 31 '23

There are several interesting pieces in the implementation that overcome the following challenges:

- ChatGPT has no documented API to access the conversations model, as opposed to other pre-trained models, like Text Completion, Code Completion and Image Generation, which you can access through an API_KEY

- React Native doesn't support streamed responses

57

u/zuluana Jan 31 '23

I think the problem they have is that you said you reserve engineered ChatGPT when you actually reverse engineered the ChatGPT Web App.

I agree it was reverse engineered, and it seems to have been done well. It also seems like the down-voters are off to their typical pattern of cyber-superiority, and it’s unnecessary.

15

u/Horror-Student-5990 Feb 01 '23

You made something cool and the reddit mob decided to heavily downvote you because you used a wrong term. Zero comment replies, zero constructive criticism. Just push the arrow down to show your displeasure with someone's work.

What a shithole.

7

u/[deleted] Feb 01 '23

Another way to look at this would be:

Someone misrepresented what they accomplished, and the community disagreed with their misrepresentation.

It doesn’t take away from the work, it just means that fewer people get to see it as it wasn’t advertised correctly.

2

u/degenerate-playboy Feb 01 '23

How did you solve those problems?

12

u/spacezombiejesus Jan 31 '23

Cause I haven’t see anyone else here say it, well done! Great work at reversing their web apis! One of the biggest barriers getting anyone I know to test out chatgpt is their awful mobile experience.

4

u/rauliyohmc Feb 01 '23

Thank you for your kind words!

25

u/OddTuning Jan 31 '23

What exactly are you reverse engineering…?

12

u/kbcool iOS & Android Jan 31 '23

Title definitely belongs in the Web3/Crypto/Flutter bros subs

0

u/[deleted] Jan 31 '23

[deleted]

29

u/birbelbirb Jan 31 '23

So... You integrated their existing public facing API into your client. You didn't reverse-engineer ChatGPT, you reversed-engineered their internal API integration.

Big difference there. Cool project though, thanks for sharing!

2

u/rauliyohmc Jan 31 '23

Yes, that's definitely more accurate!

There are already unofficial Python and Node.js packages that use a similar approach. This is no exception, just wanted to have something that doesn't need a server and you can integrate easily

1

u/IronMan8901 Jan 31 '23

I think you mean web scrapping ?

2

u/AggravatingSir891 Jan 31 '23

LOL

-7

u/rauliyohmc Jan 31 '23 edited Jan 31 '23

I don't know if you are surprised or just trying to discredit me without any knowledge, so let me clarify just in case.

OpenAPI has documented APIs for most of its pre-trained models, like Text Completion, Code Completion and Image Generation, but NOT for Conversations, which is the model ChatGPT uses.

5

u/AggravatingSir891 Jan 31 '23

Great work. However, I find it funny how you presented that as "reverse engineering". You wonder why you have so many down votes?

0

u/rauliyohmc Jan 31 '23

I accept the critique for using such clickbait, but people think the implementation for this is trivial.

They assume I am using an API key and calling an endpoint and that's the whole library. I encourage people to check the source code, there are some cool tricks.

For instance, since React Native doesn't support streamed based responses, but a web browser does, it's injecting custom code into a web-view to call an internal endpoint from there and sending back the response to RN in batches, which is how we can achieve the same behaviour of the web playground, getting a response as soon as its available.

12

u/[deleted] Jan 31 '23

Thats called cloning, not reverse engineering. You remade the look and feel and made API calls.

If anything... you're... programming.

-6

u/rauliyohmc Jan 31 '23 edited Jan 31 '23

ChatGPT has no public API to make calls

-2

u/[deleted] Jan 31 '23

Not sure if you mean "free" when you say "public" but you most definitely can make calls to ChatGPT... or at least the language model underneath if you want to argue that ChatGPT is more of the front-facing bit.

But OpenAI, has language model pricing easily findable in one search.

6

u/rauliyohmc Jan 31 '23

I don't know if we are talking about the same thing, but let me clarify just in case.

OpenAPI has documented APIs for most of its pre-trained models, like Text Completion, Code Completion and Image Generation, which you can access through an API_KEY.

However, there is no publicly available documentation as to how to access the model for Conversations, which is a different model ChatGPT uses.

2

u/[deleted] Jan 31 '23

Then how do you explain the large number of projects that come out in the past month and a half or whatever that use it?

6

u/rauliyohmc Jan 31 '23

There are other folks that already released unofficial Python and Node.js packages that use a similar approach, I just wanted to eliminate having a server from the equation

1

u/[deleted] Jan 31 '23

OpenAI provides the ChatGPT API, which can be accessed via an API key. The API endpoint allows you to send a prompt and receive a generated response. With its ability to understand and develop human-like text, the ChatGPT API is a valuable resource for any developer working with natural language data.

https://www.powershellcenter.com/2023/01/25/chatgpt_api/#:~:text=OpenAI%20provides%20the%20ChatGPT%20API,working%20with%20natural%20language%20data

7

u/rauliyohmc Jan 31 '23

Omg, that article is wrongly using the word ChatGPT and trying to drive traffic by misleading people.

https://www.powershellcenter.com/2023/01/25/chatgpt_api/#:~:text=Type%20the%20following%20URL%20in%20the%20Enter%20request%20URL%20textbox%20https%3A//api.openai.com/v1/completions

By taking a quick look, you can spot it's using the completion API from GPT-3, which has been there since 2020. Basically, the API allows you to send a prompt, and get an article back, for instance.

I challenge you to try to have a conversation with that API endpoint, so that it remembers what you said previously, or to get a streamed response (text/event-stream).

Please stop spreading misinformation without knowing what you are talking about. I am just trying to share something cool you can use for free. If you don't like it, that's fine. But trying to discredit people without any foundation is not very nice of you.

Peace.

3

u/[deleted] Jan 31 '23

You're spreading misinformation too.... telling people that you "reverse-engineered" something that took 6 months to train and you add on the time of development of the non-AI parts of the project.

ChatGPT came out in November. How'd you make something in a third of the time that some of the world's best could?

7

u/rauliyohmc Jan 31 '23 edited Jan 31 '23

It was a catchy headline, I accept the critique.

The reverse-engineering term was more on the side of understanding how the web playground performs all the calls, including authorisation and once broken down, being able to mimic it.

Finally, the goal was to create something that is 100% client side, without the need to spin up your own server, like other unofficial node/python libraries require you to

12

u/kalamari_bachelor Jan 31 '23

I don't know why people are complaining too much about the "reverse-engineered". Is clearly a clickbait.

But good job! I was messing around with GPT-3 API trying to mimic the sense of a conversation flow. You can use it to summarize its own responses and include in the next requests. The problem is the token limit 😅

It's easier just to use their public facing API instead, but we need to keep in mind that this will be dead soon when they release the actual API.

Anyway, fun project! I'll take a look on the cool tricks you did there

7

u/_mochi Feb 01 '23 edited Feb 01 '23

Reversed engineered…

Library: simulate browser to make calls and verification to chatgpt

Take info spit out on a rebuilt client😂

Not to mention this thing won’t last past 2 months when they roll out their monetization model and official API

Anyone building projects for Chatgpt should instead just use the Official APIs that are available for now and swap in the URL when chatGPT api gets released instead of having something that’s gonna break on the day it releases and having to go back and write it the proper way

NOT saying u got inspired by it and not credited someone but there are plenty of people that did this minor differences but the idea is the same

1

u/degenerate-playboy Feb 01 '23

Anyone building projects for Chatgpt should instead just use the Official APIs that are available for now and swap in the URL when chatGPT api gets released instead of having something that’s gonna break on the day it releases and having to go back and write it the proper way

What are some good business models for chatgpt apps?

1

u/_mochi Feb 02 '23

Depends what your doing but you want to at the very least recoup the cost of tokens

4

u/ForcibleBlackhead Feb 01 '23

In OPs defense he’s not wrong on Reverse Engineering. RE isn’t just pulling apart an alien craft and figuring out how it works. You can literally RE any process. It’s called deductive reasoning…

4

u/rookietotheblue1 Feb 01 '23

Yea the guy used the wring terminology, did everyone really have to be such an ass with a superiority problem ?

4

u/mojdasti Feb 01 '23

Unfortunately such a common occurrence now on programming/CS threads. It’s exhausting. People can’t post questions, projects, etc without people jerking themselves off by being assholes whenever they can. I don’t get it

2

u/LamentablyTrivial Feb 01 '23

Just dipping my toe into the react ecosystem (and react native in particular) I really appreciate how clean and structured your code is. Is this confirming to some pattern I can learn more about somewhere?

3

u/Costas_2 Jan 31 '23

Nice work!

2

u/prashantjdrew Jan 31 '23

Nice work man

2

u/marcusjribeiro3 Jan 31 '23

impressive man!

2

u/beepboopnoise Jan 31 '23

wow, this is pretty slick! I'll have to give it a go when I wake up.

3

u/Consistent-Dentist46 Jan 31 '23

You need to go to sleep for that

2

u/beepboopnoise Jan 31 '23

was referring to pulling the repo down etc, and my time zone it was pretty late.

1

u/[deleted] Jan 31 '23

This is awesome!

1

u/[deleted] Jan 31 '23

Great work!

1

u/_Figaro Jan 31 '23

Could you elaborate more?

1

u/[deleted] Feb 01 '23

Impressive!

1

u/Gravy_Pouch Feb 01 '23

This shit is awesome fuck the comments

1

u/Grigerny Feb 01 '23

People too hung up on reverse engineered. Nice work. Keep building cool stuff!

1

u/0knots Feb 01 '23

did you use IDA Pro to reverse engineer this?

1

u/HumbleRevolter Feb 01 '23

This is cool man, made my time. I was trying to sth similar back in when conversation history feature wasn’t available. Thanks for making it open source.

Can you tell briefly how you did it or at least where you read from web-view and streamed it?

1

u/National_Diver_4161 Feb 01 '23

Bro, I love your chatgpt setup

1

u/b3user007 Feb 01 '23

this looks awesome, well done! I hope to see the completed work of it when the ChatGPT API will be released publicly in the near future!

1

u/KernelPanic_42 Feb 01 '23

“Reverse engineered” 😂🤣

1

u/Chaddersatz Feb 01 '23

Great work!! This is awesome

1

u/Channel_Lazy Feb 01 '23

Good job man !!

1

u/Healthy-Grab-7819 iOS & Android Feb 16 '23

Is this not more a wrapper? I mean, what you basically have here is a Web view.

On another note, we'll done. It looks really clean.

1

u/brsmr123 Jan 31 '23

You create a RN app and used ChatGPT api in it. This is what I see here. Cool I guess.

0

u/esreveReverse Jan 31 '23

I wonder how legal this is

1

u/rauliyohmc Jan 31 '23

There are already unofficial Python and Node.js packages that use a similar approach and are endorsed/supported by OpenAI

2

u/_mochi Feb 01 '23

The only supported packages are just API call wrappers that make simpler for using their Official API

Source: someone that use it daily

What your doing is building a work around for a endpoint that is not meant to use for development or integrated into projects very different

2

u/esreveReverse Feb 01 '23

Yeah, no, not even close. Those are clients for their official API. You are injecting JavaScript into their site and hijacking the window's fetch to intercept requests. That is not even close to "a similar approach" to API wrapper packages.

-1

u/noortherapy Jan 31 '23

Legal as tech companies have it with user data.

0

u/DavidXkL Jan 31 '23

Is this using OpenAI's GPT-3 API? If so it's using the davinci-3 model which is different from what ChatGPT is using.

Go google it and see the difference

ChatGPT is more like davinci-3.5

Source: I also made a RN chat bot app using GPT-3 lol

-2

u/Legitimate_Gap1698 Jan 31 '23

That's amazing. Cause I was just gonna do something similar for my client