Slice out the <think> tags
All checks were successful
Build and push / changes (push) Successful in 4s
Build and push / Lint-Python (push) Successful in 3s
Build and push / Build-and-Push-Docker (push) Successful in 23s
Build and push / sync-argocd-app (push) Successful in 4s
Build and push / post-status-to-discord (push) Successful in 3s

This commit is contained in:
Luke R 2025-01-28 12:30:07 -08:00
parent 06b5b1fc06
commit eb79aaeee9

View File

@ -118,6 +118,16 @@ async def fix_social_media_links(ctx):
return
def remove_between(text, string1, string2):
start_index = text.find(string1)
end_index = text.find(string2, start_index + len(string1))
if start_index != -1 and end_index != -1:
return text[:start_index] + text[end_index + len(string2) :]
else:
return text # Return original text if delimiters not found
@bot.event
async def on_message(ctx):
if str(bot.user.id) in ctx.content:
@ -170,11 +180,7 @@ async def on_message(ctx):
response = requests.post(url, json=payload, headers=headers)
answer = response.json()["message"]["content"]
if len(answer) > 2000:
await ctx.reply(answer[:2000].replace("<end▁of▁sentence>", ""))
await ctx.reply(answer[2000:].replace("<end▁of▁sentence>", ""))
else:
await ctx.reply(answer.replace("<end▁of▁sentence>", ""))
await ctx.reply(remove_between(answer, "<think>", "</think>"))
except Exception as e:
print(e)
await ctx.reply("Somethings wrong, maybe the LLM crashed")