Skip to content

Commit 7dd9f05

Browse files
author
Daniel Lorch
committed
chore: return base64 encoded images instead of image_uri
1 parent 1f8eb82 commit 7dd9f05

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

plugins/dynamic-few-shot-lambda/src/IDP-dynamic-few-shot.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,16 @@ def _build_text_and_image_content(
218218
# Add images
219219
if image_content:
220220
for image_uri in image_content:
221-
content.append({"image_uri": image_uri})
221+
# Load image content
222+
if image_uri.startswith("s3://"):
223+
# Direct S3 URI
224+
image_bytes = s3.get_binary_content(image_uri)
225+
else:
226+
raise ValueError(f"Invalid file path {image_path} - expecting S3 path")
227+
228+
# Convert bytes to base64 string
229+
image_base64 = base64.b64encode(image_bytes).decode("utf-8")
230+
content.append({"image_base64": image_base64})
222231

223232
# Add text after image
224233
after_text = _prepare_prompt_from_template(

plugins/dynamic-few-shot-lambda/template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Resources:
148148
- arm64
149149
Timeout: 300
150150
MemorySize: 512
151-
Description: Demo Lambda function for GenAI IDP dynamic few-shot prompting using S3 Vectors
151+
Description: Lambda function for GenAI IDP dynamic few-shot prompting using S3 Vectors
152152
Environment:
153153
Variables:
154154
LOG_LEVEL: !Ref LogLevel

0 commit comments

Comments
 (0)