Skip to content

issues with llama_index dependency #318

Closed
@ceferisbarov

Description

@ceferisbarov

Describe the bug
llama_index is imported in multiple places without any exception handling, but it is not added to the requirements. I appreciate the idea of avoiding bloated requirements, but we should probably add a user-friendly error message. You actually have done this in some places with the unstructured library.

Ragas version: 0.0.20
Python version: 3.10.12

Code to Reproduce

from langchain.document_loaders import DirectoryLoader
from ragas.testset import TestsetGenerator

loader = DirectoryLoader("./data", glob="*.txt")
documents = loader.load()

testsetgenerator = TestsetGenerator.from_default()
test_size = 10
testset = testsetgenerator.generate(documents, test_size=test_size)

Error trace

Traceback (most recent call last):
  File "/home/jafar/projects/rag-evaluate/src/generate_testset.py", line 2, in <module>
    from ragas.testset import TestsetGenerator
  File "/home/jafar/projects/rag-evaluate/env/lib/python3.10/site-packages/ragas/testset/__init__.py", line 1, in <module>
    from ragas.testset.testset_generator import TestsetGenerator
  File "/home/jafar/projects/rag-evaluate/env/lib/python3.10/site-packages/ragas/testset/testset_generator.py", line 16, in <module>
    from llama_index.node_parser.simple import SimpleNodeParser
ModuleNotFoundError: No module named 'llama_index.node_parser.simple'

Expected behavior
The following line should be printed:

ValueError: llama_index package not found, please install it with `pip install llama_index`

Additional context
There is also another issue regarding llama_index versions. I believe that's also relevant to the discussion, so I will create a new issue and attach here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions