Add a try/except to the llm
This commit is contained in:
parent
c17c5d6dd9
commit
7e4b561a6f
@ -158,6 +158,7 @@ async def on_message(ctx):
|
|||||||
}
|
}
|
||||||
headers = {"Content-Type": "application/json"}
|
headers = {"Content-Type": "application/json"}
|
||||||
|
|
||||||
|
try:
|
||||||
await ctx.channel.trigger_typing()
|
await ctx.channel.trigger_typing()
|
||||||
response = requests.post(url, json=payload, headers=headers)
|
response = requests.post(url, json=payload, headers=headers)
|
||||||
answer = response.json()["choices"][0]["message"]["content"]
|
answer = response.json()["choices"][0]["message"]["content"]
|
||||||
@ -167,6 +168,8 @@ async def on_message(ctx):
|
|||||||
await ctx.reply(answer[2000:].replace("<|end_of_turn|>", ""))
|
await ctx.reply(answer[2000:].replace("<|end_of_turn|>", ""))
|
||||||
else:
|
else:
|
||||||
await ctx.reply(answer.replace("<|end_of_turn|>", ""))
|
await ctx.reply(answer.replace("<|end_of_turn|>", ""))
|
||||||
|
except KeyError:
|
||||||
|
await ctx.reply("Somethings wrong, maybe the LLM crashed")
|
||||||
|
|
||||||
|
|
||||||
bot.run(os.getenv("discord_token"))
|
bot.run(os.getenv("discord_token"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user