From 890f5a7bc6e0bbddc63db7a56934aed529380fdc Mon Sep 17 00:00:00 2001 From: Logan <logan.markewich@live.com> Date: Sat, 17 Feb 2024 22:39:26 -0600 Subject: [PATCH] small recursive retrieval fixes (#10932) --- .../llama_index/core/base/base_retriever.py | 4 ++-- llama-index-core/llama_index/core/schema.py | 1 + .../llama_index/core/storage/docstore/utils.py | 10 +++++----- pyproject.toml | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/llama-index-core/llama_index/core/base/base_retriever.py b/llama-index-core/llama_index/core/base/base_retriever.py index c0fb721d3..f47f7a9ab 100644 --- a/llama-index-core/llama_index/core/base/base_retriever.py +++ b/llama-index-core/llama_index/core/base/base_retriever.py @@ -149,7 +149,7 @@ class BaseRetriever(ChainableMixin, PromptMixin): node = n.node score = n.score or 1.0 if isinstance(node, IndexNode): - obj = self.object_map.get(node.index_id, None) + obj = node.obj or self.object_map.get(node.index_id, None) if obj is not None: if self._verbose: print_text( @@ -181,7 +181,7 @@ class BaseRetriever(ChainableMixin, PromptMixin): node = n.node score = n.score or 1.0 if isinstance(node, IndexNode): - obj = self.object_map.get(node.index_id, None) + obj = node.obj or self.object_map.get(node.index_id, None) if obj is not None: if self._verbose: print_text( diff --git a/llama-index-core/llama_index/core/schema.py b/llama-index-core/llama_index/core/schema.py index 4ecda5b94..3c49022d1 100644 --- a/llama-index-core/llama_index/core/schema.py +++ b/llama-index-core/llama_index/core/schema.py @@ -541,6 +541,7 @@ class IndexNode(TextNode): obj = data.get("obj", None) parsed_obj = None + if isinstance(obj, str): parsed_obj = TextNode(text=obj) elif isinstance(obj, dict): diff --git a/llama-index-core/llama_index/core/storage/docstore/utils.py b/llama-index-core/llama_index/core/storage/docstore/utils.py index f53c8735d..a95e9d44c 100644 --- a/llama-index-core/llama_index/core/storage/docstore/utils.py +++ b/llama-index-core/llama_index/core/storage/docstore/utils.py @@ -27,15 +27,15 @@ def json_to_doc(doc_dict: dict) -> BaseNode: return legacy_json_to_doc(doc_dict) else: if doc_type == Document.get_type(): - doc = Document.parse_obj(data_dict) + doc = Document.from_dict(data_dict) elif doc_type == ImageDocument.get_type(): - doc = ImageDocument.parse_obj(data_dict) + doc = ImageDocument.from_dict(data_dict) elif doc_type == TextNode.get_type(): - doc = TextNode.parse_obj(data_dict) + doc = TextNode.from_dict(data_dict) elif doc_type == ImageNode.get_type(): - doc = ImageNode.parse_obj(data_dict) + doc = ImageNode.from_dict(data_dict) elif doc_type == IndexNode.get_type(): - doc = IndexNode.parse_obj(data_dict) + doc = IndexNode.from_dict(data_dict) else: raise ValueError(f"Unknown doc type: {doc_type}") diff --git a/pyproject.toml b/pyproject.toml index cbbd67b04..ffdce47d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ name = "llama-index" packages = [{from = "_llama-index", include = "llama_index"}] readme = "README.md" repository = "https://github.com/run-llama/llama_index" -version = "0.10.6" +version = "0.10.6.post1" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" -- GitLab