Zai-Kun / reverse-engineered-chatgpt

Unofficial reverse-engineered ChatGPT API in Python
Apache License 2.0
242 stars 32 forks source link

Monkey-patching official OpenAI module #2

Closed sudoAlphaX closed 10 months ago

sudoAlphaX commented 10 months ago

Is it possible to monkey-patch the official ChatGPT Python API using such a method? It will be useful if we could use the official module but with such an implementation.

Zai-Kun commented 10 months ago

Is it possible to monkey-patch the official ChatGPT Python API using such a method? It will be useful if we could use the official module but with such an implementation.

I'm not sure, but the idea seems pretty good. I will look into it.

Zai-Kun commented 10 months ago

After scratching my head for a few hours, it seems pretty darn tough. Plus, I don't really see the point, so I'm gonna pass on it.

sudoAlphaX commented 10 months ago

I have never used the ChatGPT API, but arent there other modules that leverage the ChatGPT API in them. If if it true, then we can use other modules too effectively for free.

Zai-Kun commented 10 months ago

Oh yeah, good point. But it's not gonna be easy to do it. I will try again.

Zai-Kun commented 10 months ago

How about we start fresh, just focusing on the chat feature? It seems simpler. We can then swap out the old API with this one in a virtual environment or something like that.

Zai-Kun commented 10 months ago

Here's the basic way to use the chat feature of the ChatGPT API:

import openai 
openai.api_key = 'YOUR_API_KEY'
messages = [ {"role": "system", "content": 
            "You are a intelligent assistant."} ] 
while True: 
    message = input("User : ") 
    if message: 
        messages.append( 
            {"role": "user", "content": message}, 
        ) 
        chat = openai.ChatCompletion.create( 
            model="gpt-3.5-turbo", messages=messages 
        ) 
    reply = chat.choices[0].message.content 
    print(f"ChatGPT: {reply}") 
    messages.append({"role": "assistant", "content": reply}) 
sudoAlphaX commented 10 months ago

How about we start fresh, just focusing on the chat feature? It seems simpler. We can then swap out the old API with this one in a virtual environment or something like that.

yea that seems good. and by the way. But are there any other features?

just focusing on the chat feature What are you referencing?

sudoAlphaX commented 10 months ago

BTW, how about a new project that focuses on monkey-patching the openai api and redirecting chatgpt requests to an offline model like gpt4free I think it will be pretty interesting considering the number of models we can use instead of only ChatGPT

Zai-Kun commented 10 months ago

But are there any other features?

Things related to OpenAI, such as their other projects like DALL·E, etc.

What are you referencing?

Basically, remove everything other than the chat (ChatGPT) feature because it's not going to work anyway since they all need the API key.

Zai-Kun commented 10 months ago

BTW, how about a new project that focuses on monkey-patching the openai api and redirecting chatgpt requests to an offline model like gpt4free I think it will be pretty interesting considering the number of models we can use instead of only ChatGPT

I'm not sure. Seems a little hard, we'll think about that later.

sudoAlphaX commented 10 months ago

Basically, remove everything other than the chat (ChatGPT) feature because it's not going to work anyway since they all need the API key.

oh i understand

sudoAlphaX commented 10 months ago

I'm not sure. Seems a little hard, we'll think about that later.

alright. If you decide to work on it, I'll contribute too.

Zai-Kun commented 10 months ago

So, where do we start?

sudoAlphaX commented 10 months ago

I think we need a fresh repo with a function that when called with a prompt and the ai engine, will return the response from chatgpt, through web prompts. it would be nice if the function was similar to the official openai chatgpt function in terms of args.

sudoAlphaX commented 10 months ago

By the way, I found 2 other projects that have the done the same thing. we could use those or yours. the part we need to focus on is manipulating the official openai module to redirect requests to our module.

Repo 1 Repo 2

Zai-Kun commented 10 months ago

I think we need a fresh repo with a function that when called with a prompt and the ai engine, will return the response from chatgpt, through web prompts. it would be nice if the function was similar to the official openai chatgpt function in terms of args.

Yeah cool, but there's a little issue. I don't think this reverse-engineered API is working anymore. The API is returning this error:

{"error": "Our systems have detected unusual activity from your system. Please try again later."}

Can you confirm if it returns the same thing for you too?

sudoAlphaX commented 10 months ago

alright, give me a minute. BTW, you can try a chatgpt proxy, it's a repo in github.


From: Zai @.> Sent: Monday, October 23, 2023 15:08 To: Zai-Kun/reverse-engineered-chatgpt @.> Cc: Alpha @.>; Author @.> Subject: Re: [Zai-Kun/reverse-engineered-chatgpt] Monkey-patching official OpenAI module (Issue #2)

I think we need a fresh repo with a function that when called with a prompt and the ai engine, will return the response from chatgpt, through web prompts. it would be nice if the function was similar to the official openai chatgpt function in terms of args.

Yeah cool, but there's a little issue. I don't think this reverse-engineered API is working anymore. The API is returning this error:

{"error": "Our systems have detected unusual activity from your system. Please try again later."}

Can you confirm if it returns the same thing for you too?

— Reply to this email directly, view it on GitHubhttps://github.com/Zai-Kun/reverse-engineered-chatgpt/issues/2#issuecomment-1774804148, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKLY6CUACSJMXE7WUA2ZM6LYAY3K7AVCNFSM6AAAAAA6K3WPUWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUHAYDIMJUHA. You are receiving this because you authored the thread.Message ID: @.***>

Zai-Kun commented 10 months ago

you can try a chatgpt proxy, it's a repo in github.

Oh yeah, I remember something like that.

sudoAlphaX commented 10 months ago

{'message': None, 'conversation_id': 'ae2ab303-ca88-456a-8382-ddf700144609', 'error': 'Our systems have detected unusual activity from your system. Please try again later.'}

Same issue here, and it's the first time i'm using the script

Zai-Kun commented 10 months ago

{'message': None, 'conversation_id': 'ae2ab303-ca88-456a-8382-ddf700144609', 'error': 'Our systems have detected unusual activity from your system. Please try again later.'}

Same issue here, and it's the first time i'm using the script

It used to work just fine before.

After looking into it more, I have found that you need to include something called an 'arkose_token' in the payload. For now, let's put 'Monkey-patching' on hold, and let's focus on making the API work again.

sudoAlphaX commented 10 months ago

alright