File size: 1,312 Bytes
056f521 fcf1b11 056f521 8a289d9 90d533e 98e9bcf 056f521 fcf1b11 37d8b40 fcf1b11 8a289d9 98e9bcf 0ded348 9b56000 fcf1b11 2fc8b63 fcf1b11 056f521 98e9bcf fcf1b11 056f521 8a289d9 056f521 8a289d9 056f521 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
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
# Send the "giving results" message first
result_msg = await message.reply("🔥")
try:
# Use the Gemini API to generate a response
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}")
# Extract only the reply text
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}"
# Delete the "giving results" message
await result_msg.delete()
# Send the chatbot response to the user
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"
|