run-llama / llama_index

LlamaIndex is a data framework for your LLM applications
https://docs.llamaindex.ai
MIT License
33.87k stars 4.77k forks source link

[Bug]: ModuleNotFoundError: No module named 'llama_index.vector_stores.qdrant' #14656

Closed LeopardCatCat closed 2 weeks ago

LeopardCatCat commented 2 weeks ago

Bug Description

when I run this code: from llama_index.core import SimpleDirectoryReader from llama_index.core.embeddings import BaseEmbedding from llama_index.core.extractors import SummaryExtractor from llama_index.core.ingestion import IngestionPipeline from llama_index.core.llms.llm import LLM from llama_index.core.vector_stores.types import BasePydanticVectorStore from llama_index.core.node_parser import SentenceSplitter from llama_index.core.schema import Document, MetadataMode from llama_index.vector_stores.qdrant import QdrantVectorStore

from llama_index.vector_stores.chroma.base import ChromaVectorStore

from qdrant_client import AsyncQdrantClient, models from qdrant_client.http.exceptions import UnexpectedResponse

from custom.template import SUMMARY_EXTRACT_TEMPLATE from custom.transformation import CustomFilePathExtractor, CustomTitleExtractor

def read_data(path: str = "data") -> list[Document]: reader = SimpleDirectoryReader( input_dir=path, recursive=True, required_exts=[ ".txt", ], ) return reader.load_data()

def build_pipeline( llm: LLM, embed_model: BaseEmbedding, template: str = None, vector_store: BasePydanticVectorStore = None, ) -> IngestionPipeline: transformation = [ SentenceSplitter(chunk_size=1024, chunk_overlap=50), CustomTitleExtractor(metadata_mode=MetadataMode.EMBED), CustomFilePathExtractor(last_path_length=4, metadata_mode=MetadataMode.EMBED),

SummaryExtractor(

    #     llm=llm,
    #     metadata_mode=MetadataMode.EMBED,
    #     prompt_template=template or SUMMARY_EXTRACT_TEMPLATE,
    # ),
    embed_model,
]

return IngestionPipeline(transformations=transformation, vector_store=vector_store)

async def build_vector_store( config: dict, reindex: bool = False ) -> tuple[AsyncQdrantClient, QdrantVectorStore]: client = AsyncQdrantClient(

url=config["QDRANT_URL"],

    location=":memory:"
)
if reindex:
    try:
        await client.delete_collection(config["COLLECTION_NAME"] or "aiops24")
    except UnexpectedResponse as e:
        print(f"Collection not found: {e}")

try:
    await client.create_collection(
        collection_name=config["COLLECTION_NAME"] or "aiops24",
        vectors_config=models.VectorParams(
            size=config["VECTOR_SIZE"] or 1024, distance=models.Distance.DOT
        ),
    )
except UnexpectedResponse:
    print("Collection already exists")
return client, QdrantVectorStore(
    aclient=client,
    collection_name=config["COLLECTION_NAME"] or "aiops24",
    parallel=4,
    batch_size=32,
)

bug:(.venv) root@gpunode:/home/gpuadmin/aiops# /home/gpuadmin/aiops/.venv/bin/python /home/gpuadmin/aiops/aiops-demo/aiops24-RAG-demo-glm/demo/pipeline/ingestion.py Traceback (most recent call last): File "/home/gpuadmin/aiops/aiops-demo/aiops24-RAG-demo-glm/demo/pipeline/ingestion.py", line 9, in from llama_index.vector_stores.qdrant import QdrantVectorStore ModuleNotFoundError: No module named 'llama_index.vector_stores.qdrant'

Version

0.10.53

Steps to Reproduce

how to resolve it

Relevant Logs/Tracbacks

No response

dosubot[bot] commented 2 weeks ago

Hey @LeopardCatCat! 👋 I'm here to help you out with any bugs or questions you have. I can also guide you on how to become a contributor to this repository. Let's tackle this together while we wait for a human maintainer.

To resolve the ModuleNotFoundError: No module named 'llama_index.vector_stores.qdrant' error, you need to install the qdrant-client package. You can do this by running the following command:

pip install qdrant-client

Additionally, ensure that you are importing the correct module path in your code. The correct import statement should be:

from llama_index.vector_stores.qdrant import QdrantVectorStore

The QdrantVectorStore class is located in the llama_index.vector_stores.qdrant.base module and is re-exported in the llama_index.vector_stores.qdrant package's __init__.py file [1][2].

To continue talking to Dosu, mention @dosu.

logan-markewich commented 2 weeks ago

Make sure its installed pip install llama-index-vector-stores-qdrant

(If you are in a notebook, restart it after installing)