From 7db4088e1c8485a955a322e219c1ee6d65dff5ee Mon Sep 17 00:00:00 2001 From: Philippe Laflamme <484152+plaflamme@users.noreply.github.com> Date: Fri, 14 Feb 2025 22:15:13 +0000 Subject: [PATCH] Add textnode metadata (#17814) --- .../llama_index/indices/managed/vertexai/retriever.py | 11 ++++++++++- .../pyproject.toml | 2 +- .../tests/test_indices_managed_vertexai.py | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/llama-index-integrations/indices/llama-index-indices-managed-vertexai/llama_index/indices/managed/vertexai/retriever.py b/llama-index-integrations/indices/llama-index-indices-managed-vertexai/llama_index/indices/managed/vertexai/retriever.py index 7a43a268a..4225441b4 100644 --- a/llama-index-integrations/indices/llama-index-indices-managed-vertexai/llama_index/indices/managed/vertexai/retriever.py +++ b/llama-index-integrations/indices/llama-index-indices-managed-vertexai/llama_index/indices/managed/vertexai/retriever.py @@ -34,7 +34,16 @@ class VertexAIRetriever(BaseRetriever): if response.contexts: return [ - NodeWithScore(node=TextNode(text=context.text), score=context.distance) + NodeWithScore( + node=TextNode( + text=context.text, + metadata={ + "source_uri": context.source_uri, + "source_display_name": context.source_display_name, + }, + ), + score=context.distance, + ) for context in response.contexts.contexts ] else: diff --git a/llama-index-integrations/indices/llama-index-indices-managed-vertexai/pyproject.toml b/llama-index-integrations/indices/llama-index-indices-managed-vertexai/pyproject.toml index 9aaaf6d7d..5af3ff289 100644 --- a/llama-index-integrations/indices/llama-index-indices-managed-vertexai/pyproject.toml +++ b/llama-index-integrations/indices/llama-index-indices-managed-vertexai/pyproject.toml @@ -30,7 +30,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-indices-managed-vertexai" readme = "README.md" -version = "0.2.0" +version = "0.2.1" [tool.poetry.dependencies] python = ">=3.9,<4.0" diff --git a/llama-index-integrations/indices/llama-index-indices-managed-vertexai/tests/test_indices_managed_vertexai.py b/llama-index-integrations/indices/llama-index-indices-managed-vertexai/tests/test_indices_managed_vertexai.py index d04481dde..c5f093205 100644 --- a/llama-index-integrations/indices/llama-index-indices-managed-vertexai/tests/test_indices_managed_vertexai.py +++ b/llama-index-integrations/indices/llama-index-indices-managed-vertexai/tests/test_indices_managed_vertexai.py @@ -1,7 +1,12 @@ from llama_index.core.indices.managed.base import BaseManagedIndex +from llama_index.core.base.base_retriever import BaseRetriever from llama_index.indices.managed.vertexai import VertexAIIndex +from llama_index.indices.managed.vertexai import VertexAIRetriever def test_class(): names_of_base_classes = [b.__name__ for b in VertexAIIndex.__mro__] assert BaseManagedIndex.__name__ in names_of_base_classes + + names_of_base_classes = [b.__name__ for b in VertexAIRetriever.__mro__] + assert BaseRetriever.__name__ in names_of_base_classes -- GitLab