Tes bard AI

This commit is contained in:
yasirarism 2023-06-10 11:51:19 +07:00 committed by GitHub
parent e50348be68
commit 4dbbf5e363
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,16 +9,26 @@ from pyrogram.errors import MessageTooLong
from misskaty import app
from misskaty.helper.localization import use_chat_lang
from misskaty.helper import post_to_telegraph, check_time_gap
from misskaty.helper.http import http
from misskaty.core.decorator.ratelimiter import ratelimiter
from misskaty.vars import COMMAND_HANDLER, OPENAI_API, SUDO
openai.api_key = OPENAI_API
# This only for testing things, since maybe in future it will got blocked
@app.on_message(filters.command("bard", COMMAND_HANDLER))
async def bard_chatbot(self: Client, ctx: Message, strings):
if len(ctx.command) == 1:
return await ctx.reply_msg(strings("no_question").format(cmd=ctx.command[0]), quote=True, del_in=5)
msg = await ctx.reply_msg(strings("find_answers_str"), quote=True)
data = {'message': ctx.input, 'session_id':'XAjzKUFvf_nQtNg4bt0pG54rCLnaWeJFE1_FXuQnVjNyfmjDhkKZyoqXqW5cgBmmnf8Eqg.'}
req = await http.post("https://bard-api-rho.vercel.app/ask", json=data)
await msg.edit_msg(req.get("content"))
@app.on_message(filters.command("ask", COMMAND_HANDLER))
@ratelimiter
@use_chat_lang()
async def chatbot(self: Client, ctx: Message, strings):
async def openai_chatbot(self: Client, ctx: Message, strings):
if len(ctx.command) == 1:
return await ctx.reply_msg(strings("no_question").format(cmd=ctx.command[0]), quote=True, del_in=5)
uid = ctx.from_user.id if ctx.from_user else ctx.sender_chat.id
@ -47,4 +57,4 @@ async def chatbot(self: Client, ctx: Message, strings):
await msg.edit_msg(strings("answers_too_long").format(answerlink=answerlink), disable_web_page_preview=True)
except Exception as err:
await msg.edit_msg(f"ERROR: {str(err)}")
await openai.aiosession.get().close()
await openai.aiosession.get().close()