Spaces:
Runtime error
Runtime error
| import sys | |
| import os | |
| # Add the virtual environment's site-packages to sys.path | |
| # Replace 'pythonX.Y' with your Python version, e.g., 'python3.8' | |
| venv_path = os.path.join(os.path.dirname(__file__), 'venv', 'lib', 'site-packages') | |
| sys.path.append(venv_path) | |
| # Ensure the directory structure is recognized as a package | |
| # You can verify by listing the contents of the directory | |
| print("sys.path:", sys.path) | |
| print("Contents of venv_path:", os.listdir(venv_path)) | |
| # Now import the TestsetGenerator | |
| try: | |
| from ragas.testset.generator import TestsetGenerator | |
| print("Successfully imported TestsetGenerator.") | |
| except ImportError as e: | |
| print("ImportError:", e) | |
| # Use the imported function or class | |
| try: | |
| generator = TestsetGenerator() | |
| print("Successfully created a TestsetGenerator instance.") | |
| except Exception as e: | |
| print("Error creating TestsetGenerator instance:", e) | |