ChatGPT
ChatGPT copied to clipboard
Examples needed for AsyncChatbot usage
Is your feature request related to a problem? Please describe. Examples needed for AsyncChatbot usage.
May this help you. text mode
try:
co = await chatgpt_bot.get_chat_response(question)
print("Waiting ChatGPT")
message = co['message']
print(resp, message)
except:
print( "Error on OpenAI by "+ question)
Stream mode:
print("Try stream")
try:
cog = await chatgpt_bot.get_chat_response(question, output="stream")
i=0
async for co in cog:
if i==0:
conversation: Union[
Room, Contact] = from_contact if room is None else room
await conversation.ready()
await conversation.say("CHATGPT: waiting...")
i += 1
message = co['message']
#print(resp, message)
except Exception as e:
message = "Error from OpenAI on 【" + question +"】 by 【" + str(e) + "】"
I'm wondering in case I have multiple prompts that need to run in parallel (or with non-blocking). Can async do that or should I couple it with multiprocess?
May this help you. text mode
try: co = await chatgpt_bot.get_chat_response(question) print("Waiting ChatGPT") message = co['message'] print(resp, message) except: print( "Error on OpenAI by "+ question)
What is resp
in this snippet?
May this help you. text mode
try: co = await chatgpt_bot.get_chat_response(question) print("Waiting ChatGPT") message = co['message'] print(resp, message) except: print( "Error on OpenAI by "+ question)
What is
resp
in this snippet?
resp and question are the same var.
I'm wondering in case I have multiple prompts that need to run in parallel (or with non-blocking). Can async do that or should I couple it with multiprocess?
I Suggest don't call too many times at same time, other wise you will get "Too many requests, please slow down"
I see, would regularly refreshing the session instead of reset the chat work better to fool the server?