Fix mention escaping in conversations due to non-ascii removal

Rene Teigen 2 years ago
parent a46528ba90
commit cff7d09013

@ -934,10 +934,8 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
response_text = response_text.strip()
response_text = f"***{prompt}***\n\n{response_text}"
# If GPT3 tries to ping somebody, don't let it happen
# If gpt3 tries writing a user mention try to replace it with their name
response_text = await self.replace_mention(ctx, response_text)
# escape any other metnions
response_text = discord.utils.escape_mentions(response_text)
# If the user is conversing, add the GPT response to their conversation history.
if (
@ -981,9 +979,12 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
custom_api_key=custom_api_key,
)
# Cleanse
# Cleanse again
response_text = self.cleanse_response(response_text)
# escape any other mentions like @here or @everyone
response_text = discord.utils.escape_mentions(response_text)
# If we don't have a response message, we are not doing a redo, send as a new message(s)
if not response_message:
if len(response_text) > self.TEXT_CUTOFF:

@ -74,6 +74,7 @@ class ImgPromptOptimizer(discord.Cog, name="ImgPromptOptimizer"):
user = ctx.user
final_prompt = self.OPTIMIZER_PRETEXT
# replace mentions with nicknames for the prompt
final_prompt += await self.converser_cog.replace_mention(ctx, prompt)
# If the prompt doesn't end in a period, terminate it.
@ -100,7 +101,7 @@ class ImgPromptOptimizer(discord.Cog, name="ImgPromptOptimizer"):
# also relatively cost-effective
response_text = response["choices"][0]["text"]
# escape any mentions
response_text = discord.utils.escape_mentions(response_text)
response_message = await ctx.respond(

Loading…
Cancel
Save