Fix async response handling in indu function and update chat completion method
This commit is contained in:
parent
93077e7d49
commit
7b010bfd0f
2 changed files with 4 additions and 4 deletions
botbotbot
|
@ -264,7 +264,7 @@ async def voice_random_nicks(member, before, after):
|
|||
async def indu(ctx, prompt):
|
||||
logger.info(f"INDU {ctx.author} {prompt}")
|
||||
await ctx.defer()
|
||||
res_stream = aibot.get_response_stream(prompt)
|
||||
res_stream = await aibot.get_response_stream(prompt)
|
||||
|
||||
embed = discord.Embed(
|
||||
title=prompt,
|
||||
|
@ -275,8 +275,8 @@ async def indu(ctx, prompt):
|
|||
message = await ctx.respond(embed=embed)
|
||||
|
||||
async for chunk in res_stream:
|
||||
if chunk.choices[0].delta.content is not None:
|
||||
embed.description += chunk.choices[0].delta.content
|
||||
if chunk.data.choices[0].delta.content is not None:
|
||||
embed.description += chunk.data.choices[0].delta.content
|
||||
await message.edit(embed=embed)
|
||||
|
||||
embed.color = None
|
||||
|
|
|
@ -11,7 +11,7 @@ class AIBot:
|
|||
self.system_message = system_message
|
||||
|
||||
def get_responses(self, message):
|
||||
return self.client.chat(
|
||||
return self.client.chat.complete(
|
||||
model=self.model,
|
||||
messages=self.base_message + [{"role": "user", "content": message}],
|
||||
max_tokens=self.max_tokens,
|
||||
|
|
Loading…
Add table
Reference in a new issue