mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
Update chatbot_ai.py
This commit is contained in:
parent
a08b43bbb8
commit
3e5fc4ceba
1 changed files with 1 additions and 3 deletions
|
|
@ -31,14 +31,12 @@ async def chatbot(c, m):
|
|||
msg = await kirimPesan(m, "Wait a moment looking for your answer..")
|
||||
try:
|
||||
response = (await http.post("https://api.openai.com/v1/chat/completions", headers=headers, json=json_data)).json()
|
||||
if err := response["error"]:
|
||||
if err := response.get("error"):
|
||||
return await editPesan(msg, err["message"])
|
||||
answer = response["choices"][0]["message"]["content"]
|
||||
await editPesan(msg, answer)
|
||||
except MessageTooLong:
|
||||
answerlink = await post_to_telegraph(False, "MissKaty ChatBot ", answer)
|
||||
await editPesan(msg, f"Question for your answer has exceeded TG text limit, check this link to view.\n\n{answerlink}", disable_web_page_preview=True)
|
||||
except (MessageNotModified, MessageIdInvalid):
|
||||
pass
|
||||
except Exception as err:
|
||||
await editPesan(msg, f"Oppss. ERROR: {str(err)}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue