diff --git a/docs/examples/retrievers/composable_retrievers.ipynb b/docs/examples/retrievers/composable_retrievers.ipynb index 065170a5a86f22e673d3da6c2c60f547758960af..78d851500130378e97c7f60389727ca9df733979 100644 --- a/docs/examples/retrievers/composable_retrievers.ipynb +++ b/docs/examples/retrievers/composable_retrievers.ipynb @@ -33,11 +33,12 @@ "outputs": [], "source": [ "%pip install llama-index-storage-docstore-mongodb\n", - "%pip install llama-index-readers-file\n", + "%pip install llama-index-vector-stores-qdrant\n", "%pip install llama-index-storage-docstore-firestore\n", - "%pip install llama-index-storage-docstore-dynamodb\n", + "%pip install llama-index-retrievers-bm25\n", "%pip install llama-index-storage-docstore-redis\n", - "%pip install llama-index-vector-stores-qdrant" + "%pip install llama-index-storage-docstore-dynamodb\n", + "%pip install llama-index-readers-file" ] }, { @@ -122,7 +123,7 @@ "outputs": [], "source": [ "from llama_index.core import VectorStoreIndex, StorageContext\n", - "from llama_index.core.retrievers import BM25Retriever\n", + "from llama_index.retrievers.bm25 import BM25Retriever\n", "from llama_index.vector_stores.qdrant import QdrantVectorStore\n", "from qdrant_client import QdrantClient\n", "\n", @@ -422,7 +423,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -439,5 +440,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/llama-index-core/llama_index/core/command_line/mappings.json b/llama-index-core/llama_index/core/command_line/mappings.json index 59855d154b8d34f72369e332c1920cecef1ecc13..2edcdd0c99cb0b7f1d956f9b42b5b4d0240fefb2 100644 --- a/llama-index-core/llama_index/core/command_line/mappings.json +++ b/llama-index-core/llama_index/core/command_line/mappings.json @@ -305,7 +305,6 @@ "RecursiveRetriever": "llama_index.core.retrievers", "AutoMergingRetriever": "llama_index.core.retrievers", "RouterRetriever": "llama_index.core.retrievers", - "BM25Retriever": "llama_index.core.retrievers", "QueryFusionRetriever": "llama_index.core.retrievers", "# SQLSQLRetriever": "llama_index.core.retrievers", "NLSQLRetriever": "llama_index.core.retrievers", @@ -393,6 +392,7 @@ "set_google_config": "llama_index.vector_stores.google", "GoogleVectorStore": "llama_index.vector_stores.google", "MetalVectorStore": "llama_index.vector_stores.metal", + "BM25Retriever": "llama_index.retrievers.bm25", "PathwayRetriever": "llama_index.retrievers.pathway", "YouRetriever": "llama_index.retrievers.you", "ZillizCloudPipelineIndex": "llama_index.indices.managed.zilliz", diff --git a/llama-index-core/llama_index/core/command_line/upgrade.py b/llama-index-core/llama_index/core/command_line/upgrade.py index 20db64956f3aaca298042c3adb5e09e7ea88148e..291a53f72d62d5f82d6c1b88fe68fdc6c9af062a 100644 --- a/llama-index-core/llama_index/core/command_line/upgrade.py +++ b/llama-index-core/llama_index/core/command_line/upgrade.py @@ -48,12 +48,16 @@ def _parse_from_imports( new_imports[new_import_parent].append(module) else: print(f"Module not found: {module}\nSwitching to core") + # get back the llama_index module that's being imported. new_import_parent = ( - imported_modules[0] - .split(" import ")[0] - .split("from ")[-1] - .replace("llama_index", "llama_index.core") + imported_modules[0].split(" import ")[0].split("from ")[-1] ) + # if the parent contains `llama_index.core` already, then skip + if "llama_index.core" not in new_import_parent: + new_import_parent = new_import_parent.replace( + "llama_index", "llama_index.core" + ) + if new_import_parent not in new_imports: new_imports[new_import_parent] = [module] else: