|
from pyrogram import filters |
|
|
|
from Mikobot import app |
|
from Mikobot.state import state |
|
|
|
import os |
|
import google.generativeai as genai |
|
|
|
|
|
@app.on_message(filters.text) |
|
async def palm_chatbot(client, message): |
|
if not message.text.startswith("flash"): |
|
return |
|
|
|
query = " ".join(message.text.split()[1:]) |
|
|
|
if not query: |
|
await message.reply("Please provide a query after flash.") |
|
return |
|
|
|
|
|
result_msg = await message.reply("π₯") |
|
|
|
try: |
|
|
|
genai.configure(api_key="AIzaSyBM0m9lnb1GlbnWcGWDe0otQ-aVnpIF974") |
|
model = genai.GenerativeModel("gemini-1.5-pro") |
|
response = model.generate_content(f"Generate a response to the following query: {query}") |
|
|
|
|
|
reply_text = response.candidates[0].content.parts[0].text |
|
|
|
except Exception as e: |
|
reply_text = f"Error: An error occurred while calling the Gemini API. {e}" |
|
|
|
|
|
await result_msg.delete() |
|
|
|
|
|
await message.reply(reply_text) |
|
|
|
|
|
__help__ = """ |
|
β¦ *Write Miko with any sentence it will work as chatbot.* |
|
|
|
*Example*: Miko are you a bot? |
|
""" |
|
|
|
__mod_name__ = "CHATBOT" |
|
|