acheong08 / ChatGPT

Reverse engineered ChatGPT API
GNU General Public License v2.0
28.01k stars 4.48k forks source link

[Bug]: wrong begavior in async version #1412

Closed vgdh closed 1 year ago

vgdh commented 1 year ago

Is there an existing issue for this?

What happened?

got only the part of answer, till the first quote char. the error is in the code:

# DO NOT REMOVE THIS
line = line.replace('\\"', '"')
line = line.replace("\\'", "'")
line = line.replace("\\\\", "\\")

when i deleted it, i got the whole version of the answer

code example, for reproduce:

from revChatGPT.V1 import AsyncChatbot
import asyncio

async def amain():
    chatbot = AsyncChatbot(config={
        "access_token": "key"
    })

    gpt_q = f"There is a sentence 'bla bla' "
    gpt_q += f"can I write it that way: 'bugaga'\n"
    gpt_q += f"Does it have any errors?"

    response = ""
    gen = chatbot.ask(gpt_q)

    async for data in gen:
        response = data["message"]
    print(response)

asyncio.run(amain())

Steps to reproduce the problem

run the code

What should have happened?

get my answer

Version where the problem happens

6.1.3

What Python version are you running this with?

3.11

What is your operating system ?

No response

Command Line Arguments

none

Console logs

none

Additional information

No response