ChatGPT icon indicating copy to clipboard operation
ChatGPT copied to clipboard

TypeError: object generator can't be used in 'await' expression

Open arwooy opened this issue 1 year ago • 2 comments

when run this:

async def printMessage(): async for i in await chatbot.get_chat_response("hello", output="stream"): print(i['message'])

asyncio.run(printMessage())

error report: async for i in await chatbot.get_chat_response("hello", output="stream"): TypeError: object generator can't be used in 'await' expression

arwooy avatar Dec 12 '22 12:12 arwooy

As it says, you can't use await for streams. If you want to stream data, using a normal loop through the normal Chatbot with output="stream" would send the data asynchronously

acheong08 avatar Dec 12 '22 12:12 acheong08

@arwooy make sure you import the async version of the chatbot:

from revChatGPT.revChatGPT import AsyncChatbot

works for me with Python 3.10+

n3d1117 avatar Dec 12 '22 17:12 n3d1117