Search code examples
llama-index

cannot import name 'VectorStoreIndex' from 'llama_index'


Unable to find the imports in LlamaIndex even after correct imports as of there latest docs

from llama_index.vector_stores.types import MetadataInfo, VectorStoreInfo
vector_store_info = VectorStoreInfo(
    content_info="brief biography of celebrities",
    metadata_info=[
        MetadataInfo(
            name="category",
            type="str",
            description=(
                "Category of the celebrity, one of [Sports, Entertainment,"
                " Business, Music]"
            ),
        ),
        MetadataInfo(
            name="country",
            type="str",
            description=(
                "Country of the celebrity, one of [United States, Barbados,"
                " Portugal]"
            ),
        ),
    ],
)

Solution

  • Yes, the correct import is from: llama_index.core.vector_stores.types

    Why the additional core?

    Just to clarify, especially for other people who run into import problems, the new versions of LlamaIndex v0.10.0 and above have been refactored and there are breaking changes.

    You can find the official migration guide here: https://docs.llamaindex.ai/en/stable/getting_started/v0_10_0_migration/

    ServiceContext is now Settings

    It's also important to note that the ServiceContext has been replaced by Settings, and you can also find the migration guide here: https://docs.llamaindex.ai/en/stable/module_guides/supporting_modules/service_context_migration/

    So if you're on v0.10.0 or above, make sure to go over the latest version of the docs to ensure you have the correct imports (https://docs.llamaindex.ai/en/stable/api_reference/).

    To check the version installed on your machine, use: pip show llama-index