Sync with latest openai lib

Signed-off-by: Yasir Aris M <git@yasirdev.my.id>
This commit is contained in:
Yasir Aris M 2023-11-17 16:18:25 +07:00
parent 4af39b0da6
commit 6868906ecb

View file

@ -68,10 +68,8 @@ async def openai_chatbot(_, ctx: Message, strings):
stream=True,
)
async for chunk in response:
if not chunk.choices[0].message or chunk.choices[0].message.get("role"):
continue
num += 1
answer += chunk.choices[0].message.content
answer += chunk.choices[0].delta.content
if num == 30:
await msg.edit_msg(answer)
await asyncio.sleep(1.5)