Use my mirror api for Gemini because my VPS region is not supported

Signed-off-by: Yasir Aris M <git@yasirdev.my.id>
This commit is contained in:
Yasir Aris M 2024-05-13 13:18:51 +07:00 committed by GitHub
parent cbbd7c3080
commit da6b6e5a4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -36,25 +36,8 @@ async def gemini_chatbot(_, ctx: Message, strings):
return await ctx.reply_msg("GOOGLEAI_KEY env is missing!!!")
msg = await ctx.reply_msg(strings("find_answers_str"), quote=True)
try:
params = {
'key': GOOGLEAI_KEY,
}
json_data = {
'contents': [
{
'parts': [
{
'text': ctx.text.split(maxsplit=1)[1],
},
],
},
],
}
response = await fetch.post(
'https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent',
params=params,
json=json_data,
timeout=20.0,
response = await fetch.get(
f'https://yasirapi.eu.org/gemini?query={ctx.text.split(maxsplit=1)}'
)
if not response.json().get("candidates"):
await ctx.reply_msg("⚠️ Sorry, the prompt you sent maybe contains a forbidden word that is not permitted by AI.")