From 77289be4bd298d5efce414a6be4051410a44dfdd Mon Sep 17 00:00:00 2001 From: Sourabh Desai <sourabhdesai@gmail.com> Date: Sun, 16 Feb 2025 13:13:49 -0800 Subject: [PATCH] include file & page metadata when returning image node from llamacloud retriever (#17823) --- .../llama_index/indices/managed/llama_cloud/api_utils.py | 9 +++++++-- .../pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/llama_index/indices/managed/llama_cloud/api_utils.py b/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/llama_index/indices/managed/llama_cloud/api_utils.py index 63fdf79a04..e90b68b9a5 100644 --- a/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/llama_index/indices/managed/llama_cloud/api_utils.py +++ b/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/llama_index/indices/managed/llama_cloud/api_utils.py @@ -1,4 +1,4 @@ -from typing import Optional, Tuple, Union +from typing import Any, Optional, Tuple, Union, Dict import urllib.parse from httpx import Request @@ -197,8 +197,13 @@ async def aimage_nodes_to_node_with_score( image_bytes_list = await run_jobs(tasks) for image_bytes, raw_image_node in zip(image_bytes_list, raw_image_nodes): image_base64 = base64.b64encode(image_bytes).decode("utf-8") + image_node_metadata: Dict[str, Any] = { + "file_id": raw_image_node.node.file_id, + "page_index": raw_image_node.node.page_index, + } image_node_with_score = NodeWithScore( - node=ImageNode(image=image_base64), score=raw_image_node.score + node=ImageNode(image=image_base64, metadata=image_node_metadata), + score=raw_image_node.score, ) image_nodes.append(image_node_with_score) return image_nodes diff --git a/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/pyproject.toml b/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/pyproject.toml index f967eca322..298588c94c 100644 --- a/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/pyproject.toml +++ b/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/pyproject.toml @@ -34,7 +34,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-indices-managed-llama-cloud" readme = "README.md" -version = "0.6.5" +version = "0.6.6" [tool.poetry.dependencies] python = ">=3.9,<4.0" -- GitLab