Open dividor opened 3 weeks ago
To resolve the ImportError
when trying to generate synthetic data using the RAGAs documentation code with Ragas version 0.1.14 and Python version 3.11.4, you need to ensure that the _version
module is available and correctly imported. The provided code snippet from src/ragas/__init__.py
shows that the import of _version
is wrapped in a try-except block, which sets __version__
to "unknown version" if the import fails.
Here is the relevant part of the code:
try:
from ._version import version as __version__
except ImportError:
__version__ = "unknown version"
To fix the ImportError
, you should check the following:
_version.py
file exists in the ragas
directory._version.py
file contains a version
variable.For example, the _version.py
file should look something like this:
# src/ragas/_version.py
version = "0.1.14"
If the _version.py
file is missing or incorrectly named, create it with the appropriate content. This should resolve the ImportError
and allow you to proceed with generating synthetic data using the RAGAs documentation code.
Additionally, ensure you have installed the Ragas package correctly. You can install it using pip:
pip install ragas
Or, if you prefer to install it from the source:
pip install git+https://github.com/explodinggradients/ragas
Here is a small example program from the Ragas documentation to see it in action:
from datasets import Dataset
import os
from ragas import evaluate
from ragas.metrics import faithfulness, answer_correctness
os.environ["OPENAI_API_KEY"] = "your-openai-key"
data_samples = {
'question': ['When was the first super bowl?', 'Who won the most super bowls?'],
'answer': ['The first superbowl was held on Jan 15, 1967', 'The most super bowls have been won by The New England Patriots'],
'contexts' : [['The First AFL–NFL World Championship Game was an American football game played on January 15, 1967, at the Los Angeles Memorial Coliseum in Los Angeles,'],
['The Green Bay Packers...Green Bay, Wisconsin.','The Packers compete...Football Conference']],
'ground_truth': ['The first superbowl was held on January 15, 1967', 'The New England Patriots have won the Super Bowl a record six times']
}
dataset = Dataset.from_dict(data_samples)
score = evaluate(dataset, metrics=[faithfulness, answer_correctness])
score.to_pandas()
Refer to the Ragas documentation for more details [1][2].
To continue talking to Dosu, mention @dosu.
[X ] I have checked the documentation and related resources and couldn't resolve my bug.
Describe the bug I am following this RAGAs documentation to generate test data, but I get a module import error.
Ragas version: 0.1.14 Python version: 3.11.4
Code to Reproduce Code from RAGAs documentation ...
Error trace
Additional context Thanks!