ragas icon indicating copy to clipboard operation
ragas copied to clipboard

metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Open vohoangkh4ng opened this issue 1 year ago • 1 comments

[ ] I checked the documentation and related resources and couldn't find an answer to my question.

Your Question when i import library from ragas i get metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Code Examples from ragas.metrics import faithfullness from ragas import evaluate

Additional context What version of ragas i can use ?

vohoangkh4ng avatar Oct 09 '24 16:10 vohoangkh4ng

Hey @vohoangkh4ng! I'm here to help you out with any bugs or questions you have. Let's tackle this issue together!

The error you're encountering is related to a metaclass conflict, which can occur when a class inherits from multiple base classes with different metaclasses. Unfortunately, I don't have specific information on metaclass conflicts or version requirements for the Ragas library.

To resolve this, you can try the following steps:

  1. Check for Updates: Ensure you are using the latest version of Ragas. Sometimes, such conflicts are resolved in newer releases.

  2. Review Dependencies: Check if there are any specific dependencies or Python version requirements that might affect metaclass behavior.

  3. Simplify Imports: Try importing only the necessary components to isolate the issue.

If these steps don't help, consider checking the Ragas repository for any recent commits or issues related to metaclass conflicts.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Oct 09 '24 16:10 dosubot[bot]

I encountered this issue too after migration to langchain-core==0.3.x and switching from Pydantic v1 to v2. It would be great if Ragas could be updated to be compatible.

VMinB12 avatar Oct 24 '24 10:10 VMinB12

I am getting the same error but with Django viewsets

Mukhsin0508 avatar Oct 25 '24 02:10 Mukhsin0508

@VMinB12 @Mukhsin0508 are you guys using v0.2+ we do support the libs you mentioned now with that update

jjmachan avatar Oct 25 '24 16:10 jjmachan

@vohoangkh4ng There's a typo in your import: you wrote faithfullness instead of faithfulness

# Solution 1: Clean installation with specific versions
# First, uninstall existing packages
pip uninstall ragas langchain datasets -y

# Install specific versions known to work together
pip install ragas==0.0.22
pip install langchain==0.0.350
pip install datasets==2.14.7

# Your imports should now work
from ragas.metrics import faithfulness  # Note the correct spelling
from ragas import evaluate

Check your Python version (Ragas works best with Python 3.8-3.10) b. Make sure you don't have conflicting packages in your environment c. Try running:

pythonCopypip freeze | grep -i "ragas\|langchain\|datasets"

Mukhsin0508 avatar Oct 28 '24 19:10 Mukhsin0508

thanks alot @Mukhsin0508 for the fix ❤️ closing this now

jjmachan avatar Nov 08 '24 04:11 jjmachan