Skip to content
Snippets Groups Projects
Unverified Commit 77289be4 authored by Sourabh Desai's avatar Sourabh Desai Committed by GitHub
Browse files

include file & page metadata when returning image node from llamacloud retriever (#17823)

parent f544b78c
No related branches found
No related tags found
No related merge requests found
from typing import Optional, Tuple, Union from typing import Any, Optional, Tuple, Union, Dict
import urllib.parse import urllib.parse
from httpx import Request from httpx import Request
...@@ -197,8 +197,13 @@ async def aimage_nodes_to_node_with_score( ...@@ -197,8 +197,13 @@ async def aimage_nodes_to_node_with_score(
image_bytes_list = await run_jobs(tasks) image_bytes_list = await run_jobs(tasks)
for image_bytes, raw_image_node in zip(image_bytes_list, raw_image_nodes): for image_bytes, raw_image_node in zip(image_bytes_list, raw_image_nodes):
image_base64 = base64.b64encode(image_bytes).decode("utf-8") 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( 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) image_nodes.append(image_node_with_score)
return image_nodes return image_nodes
...@@ -34,7 +34,7 @@ exclude = ["**/BUILD"] ...@@ -34,7 +34,7 @@ exclude = ["**/BUILD"]
license = "MIT" license = "MIT"
name = "llama-index-indices-managed-llama-cloud" name = "llama-index-indices-managed-llama-cloud"
readme = "README.md" readme = "README.md"
version = "0.6.5" version = "0.6.6"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.9,<4.0" python = ">=3.9,<4.0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment