Test with privatebin

This commit is contained in:
Yasir Aris M 2024-09-01 12:32:52 +07:00 committed by GitHub
parent 954bdb637f
commit 04294c7f4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View file

@ -4,6 +4,7 @@
# * Copyright ©YasirPedia All rights reserved # * Copyright ©YasirPedia All rights reserved
import asyncio import asyncio
import html import html
import privatebinapi
from cachetools import TTLCache from cachetools import TTLCache
from openai import APIConnectionError, APIStatusError, AsyncOpenAI, RateLimitError from openai import APIConnectionError, APIStatusError, AsyncOpenAI, RateLimitError
@ -51,11 +52,9 @@ async def get_openai_stream_response(is_stream, key, base_url, model, messages,
num = 0 num = 0
await bmsg.edit_msg(f"{html.escape(answer)}\n\n<b>Powered by:</b> <code>GPT 4o</code>") await bmsg.edit_msg(f"{html.escape(answer)}\n\n<b>Powered by:</b> <code>GPT 4o</code>")
except MessageTooLong: except MessageTooLong:
answerlink = await post_to_telegraph( answerlink = await privatebinapi.send_async("https://bin.yasirweb.eu.org", text=html.escape(f"<code>{answer}</code>"), expiration="1week", formatting="markdown")
False, "MissKaty ChatBot ", html.escape(f"<code>{answer}</code>")
)
await bmsg.edit_msg( await bmsg.edit_msg(
strings("answers_too_long").format(answerlink=answerlink), strings("answers_too_long").format(answerlink=answerlink.get("full_url")),
disable_web_page_preview=True, disable_web_page_preview=True,
) )
except APIConnectionError as e: except APIConnectionError as e:
@ -127,7 +126,7 @@ async def openai_chatbot(self, ctx: Message, strings):
ai_response = await get_openai_stream_response(True, OPENAI_KEY, "https://models.inference.ai.azure.com" if uid in SUDO else "https://duckai.yasirapi.eu.org/v1", "gpt-4o" if uid in SUDO else "gpt-4o-mini", gptai_conversations[uid], msg, strings) ai_response = await get_openai_stream_response(True, OPENAI_KEY, "https://models.inference.ai.azure.com" if uid in SUDO else "https://duckai.yasirapi.eu.org/v1", "gpt-4o" if uid in SUDO else "gpt-4o-mini", gptai_conversations[uid], msg, strings)
if not ai_response: if not ai_response:
gptai_conversations[uid].pop() gptai_conversations[uid].pop()
if len(_conversations[uid]) == 1: if len(gptai_conversations[uid]) == 1:
gptai_conversations.pop(uid) gptai_conversations.pop(uid)
return return
gptai_conversations[uid].append({"role": "assistant", "content": ai_response}) gptai_conversations[uid].append({"role": "assistant", "content": ai_response})

View file

@ -286,10 +286,10 @@ async def nekopaste(_, message):
try: try:
x = ( x = (
await fetch.post( await fetch.post(
"https://nekobin.com/api/documents", json={"content": data} "https://bin.mayuri.my.id/api/documents", json={"content": data}
) )
).json() ).json()
url = f"https://nekobin.com/{x['result']['key']}" url = f"https://bin.mayuri.my.id/{x['result']['key']}"
except Exception as e: except Exception as e:
return await msg.edit_msg(f"ERROR: {e}") return await msg.edit_msg(f"ERROR: {e}")

View file

@ -20,6 +20,7 @@ python-dateutil
telegraph telegraph
hachoir hachoir
Pillow==10.4.0 Pillow==10.4.0
PrivateBinAPI
httpx[http2] httpx[http2]
git+https://github.com/yasirarism/vcsi git+https://github.com/yasirarism/vcsi
git+https://github.com/yasirarism/iytdl git+https://github.com/yasirarism/iytdl