Spaces:
Configuration error
Configuration error
| 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 "🤖 Ележка: Бля, чет я приуныл... Повтори вопрос!" | |
| 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()) | |