Запускаю скрипт, проходит один запрос и выдается ошибка:
ОшибкаException in callback Task.task_wakeup()
handle: )>
Traceback (most recent call last):
File "/usr/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task wait_for=> while another task cb=[gather.._done_callback() at /usr/lib/python3.11/asyncio/tasks.py:754]> is being executed.
Task was destroyed but it is pending!
task: wait_for=>
Polling is stopped.
Вот сам код:
from aiogram import Bot, executor, Dispatcher, types
from aiogram.types import ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton, ContentType
import g4f
#Токен
TOKEN_API = "Токен"
#Подключение к боту
bot = Bot(TOKEN_API)
db = Dispatcher(bot)
@db.message_handler(commands=['start'])
async def start(message: types.Message):
await message.answer_sticker(sticker="CAACAgIAAxkBAAMnZOnyFrp5lQOCx_JFL1f_1E7IpR8AAiwRAAILPilIcvTrpWESf9swBA")
await message.answer(text="Привет")
await message.delete()
@db.message_handler()
async def start(message: types.Message):
response = g4f.ChatCompletion.create(
model=g4f.models.gpt_4,
messages=[{"role": "user", "content": message.text}],
) # alternative model setting
await message.answer(text=response)
if __name__ == "__main__":
executor.start_polling(db, skip_updates=True)