Ошибка в коде python, срочно нужна помощь

Ошибки

C:\Users\garma\PycharmProjects\pythonProject\.venv\Scripts\python.exe C:\Users\garma\PycharmProjects\pythonProject\.venv\dfdsfsdfds.py 
TgCrypto is missing! Pyrogram will work the same, but at a much slower speed. More info: https://docs.pyrogram.org/topics/speedups
C:\Users\garma\PycharmProjects\pythonProject\.venv\Lib\site-packages\curl_cffi\aio.py:137: RuntimeWarning: 
    Proactor event loop does not implement add_reader family of methods required.
    Registering an additional selector thread for add_reader support.
    To avoid this warning use:
        asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
    
  self.loop = _get_selector(loop if loop is not None else asyncio.get_running_loop())
C:\Users\garma\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py:88: UserWarning: Curlm alread closed! quitting from process_data
  self._context.run(self._callback, *self._args)
Извините, но я могу помочь вам только с запросами, связанными с моей областью знаний. Пожалуйста, уточните, какую конкретную информацию вы хотели бы получить о криптовалюте, чтобы я мог вам помочь.
ERROR:root:Ошибка при обращении к OpenAI: string indices must be integers, not 'str'
Traceback (most recent call last):
  File "C:\Users\garma\PycharmProjects\pythonProject\.venv\dfdsfsdfds.py", line 30, in chat_with_openai
    return response['choices'][0]['message']['content']
           ~~~~~~~~^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'
Traceback (most recent call last):
  File "C:\Users\garma\PycharmProjects\pythonProject\.venv\dfdsfsdfds.py", line 61, in <module>
    app.run()
  File "C:\Users\garma\PycharmProjects\pythonProject\.venv\Lib\site-packages\pyrogram\methods\utilities\run.py", line 85, in run
    run(idle())
  File "C:\Users\garma\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "C:\Users\garma\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 322, in run_forever
    super().run_forever()
  File "C:\Users\garma\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 641, in run_forever
    self._run_once()
  File "C:\Users\garma\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1971, in _run_once
    handle = self._ready.popleft()
             ^^^^^^^^^^^^^^^^^^^^^
IndexError: pop from an empty deque

Process finished with exit code 1
import os
import asyncio
from pyrogram import Client, filters
from pyrogram.types import Message
import g4f
import logging

# Настройка логирования
logging.basicConfig(level=logging.INFO)

# Конфигурация Pyrogram клиента
name = "traf1"  # Название сессии
api_id = 22676505  # API ID
api_hash = "50416f782db22811130526cc6b3a05bb"  # API HASH

# Список API ключей OpenAI



# Функция взаимодействия с OpenAI
async def chat_with_openai(prompt):
    try:
        # Здесь предполагается, что g4fClient уже настроен на использование OpenAI API

        response = g4f.ChatCompletion.create(
            model="gpt-3.5-turbo",
            messages=[{"role": "user", "content": prompt}]
        )
        print(response)
        return response['choices'][0]['message']['content']
    except Exception as e:
        logging.error(f"Ошибка при обращении к OpenAI: {e}", exc_info=True)
        return None


# Инициализация клиента Pyrogram
app = Client(name, api_id=api_id, api_hash=api_hash)


# Обработчик новых сообщений в каналах
@app.on_message(filters.private & filters.text, group=-1)
async def handle_new_post(client, message: Message):
    logging.info(f"Получено новое сообщение от {message.chat.title or message.from_user.username}: {message.text}")

    response = await chat_with_openai(message.text)
    if response:
        await asyncio.sleep(2)  # Задержка 180 секунд
        try:
            await client.send_message(
                chat_id=message.chat.id,
                text=response,
                reply_to_message_id=message.id
            )
            logging.info(f"Ответ отправлен пользователю {message.chat.title or message.from_user.username}")
        except Exception as e:
            logging.error(f"Ошибка при отправке сообщения: {e}")


# Запуск клиента
if __name__ == '__main__':
    app.run()

Ответы (0 шт):