Welcome 🤔 🐈⬛, I guess it's your first time using this bot I…
- User
Assistant: User: User: Welcome 🤔 🐈⬛, I guess it's your first time using this bot I just added you to my database i don't care if you don't like this Assistant: Thank you for adding me to your database! I'm here to help you with any questions or tasks you have. If there's anything specific you'd like assistance with, just let me know. 😊 User: Welcome 🤔 🐈⬛ Assistant: Thank you for adding me to your database! I'm here to help with any questions or tasks you might have. If there's anything specific you'd like assistance with, feel free to let me know. 😊 User: hi i got this codes:
functions.py from g4f.client import Client as _Client import asyncio as _asyncio _client = _Client()
async def ask(messages): loop = _asyncio.get_running_loop() return await loop.run_in_executor(None, _ask, messages)
def _ask(messages): return _client.chat.completions.create( model="gpt-4o", messages=messages )
chatgpt.py: from pyrogram import Client, filters, types, enums
from ..bot.utils.functions import ask
@Client.on_message(filters.private & filters.text) async def execute(client: Client, message: types.Message): user = client.db.get(f'{message.from_user.id}') if user: client.db.push(f'{message.from_user.id}.chat_history', {"role": 'user', 'content': message.text})
codehistory = client.db.get(f'{message.from_user.id}.chat_history') completions = await ask(history) client.db.push(f'{message.from_user.id}.chat_history', {"role": 'assistant', 'content': completions.choices[0].message.content}) await message.reply(completions.choices[0].message.content, reply_to_message_id=message.id)and im getting File "/home/m/Codes/cli-bot/extensions/chatgpt.py", line 3, in from ..bot.utils.functions import ask ImportError: attempted relative import beyond top-level package Assistant: The error
ImportError: attempted relative import beyond top-level packageoccurs when you try to use a relative import in a way that goes beyond the top-level package of your project structure.To resolve this, ensure that your project is structured properly and that you run your code with the correct context. Here's how you can address the issue:
-
Project Structure: Ensure that your project's directory structure makes sense for relative imports. For example:
code
-
- Assistant
Hello! I'm here to help you with any questions or tasks you might have. Whether you need assistance with coding problems, advice on tech topics, or even just a friendly chat, feel free to let me know how I can assist you! 😊