EmeraldCreator's picture
Update app.py
62c0d8a verified
raw
history blame contribute delete
801 Bytes
import asyncio
import os
from aiogram import Bot, Dispatcher, types
from duckduckgo_search import DDGS
# Берем токен из секретов
TOKEN = os.environ.get("TG_TOKEN")
bot = Bot(token=TOKEN)
dp = Dispatcher()
def ask_ai(text):
try:
with DDGS() as ddgs:
return ddgs.chat(text, model='llama-3-70b')
except:
return "🤖 Ележка: Бля, чет я приуныл... Повтори вопрос!"
@dp.message()
async def handle(message: types.Message):
await bot.send_chat_action(chat_id=message.chat.id, action="typing")
response = ask_ai(message.text)
await message.answer(response)
async def main():
print("🚀 ЕЛЕЖКА В СЕТИ!")
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())