Slice out the <think> tags
This commit is contained in:
parent
e0505e8815
commit
79fa8df54b
16
app/bot.py
16
app/bot.py
@ -118,6 +118,16 @@ async def fix_social_media_links(ctx):
|
|||||||
return
|
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
|
@bot.event
|
||||||
async def on_message(ctx):
|
async def on_message(ctx):
|
||||||
if str(bot.user.id) in ctx.content:
|
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)
|
response = requests.post(url, json=payload, headers=headers)
|
||||||
answer = response.json()["message"]["content"]
|
answer = response.json()["message"]["content"]
|
||||||
|
|
||||||
if len(answer) > 2000:
|
await ctx.reply(remove_between(answer, "<think>", "</think>"))
|
||||||
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|>", ""))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
await ctx.reply("Somethings wrong, maybe the LLM crashed")
|
await ctx.reply("Somethings wrong, maybe the LLM crashed")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user