Skip to content

Commit e2d372f

Browse files
committed
fix tool
1 parent 53d9e36 commit e2d372f

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/idp_common_pkg/idp_common/assessment/strands_tools.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pydantic import BaseModel, Field
1313
from strands import Agent, tool
1414
from strands.types.content import ContentBlock, ImageContent
15+
from strands.types.tools import ToolResult, ToolResultContent, ToolResultStatus
1516

1617
from idp_common.assessment.strands_models import BoundingBox
1718
from idp_common.utils.grid_overlay import draw_bounding_boxes
@@ -49,7 +50,7 @@ def create_view_image_tool(page_images: list[bytes], sorted_page_ids: list[str])
4950
"""
5051

5152
@tool
52-
def view_image(input_data: dict[str, Any], agent: Agent) -> ImageContent:
53+
def view_image(input_data: dict[str, Any], agent: Agent) -> dict:
5354
"""
5455
View a specific page image, optionally highlighting a bounding box area.
5556
@@ -127,19 +128,19 @@ def view_image(input_data: dict[str, Any], agent: Agent) -> ImageContent:
127128
},
128129
)
129130

130-
# Return the image as ImageContent so the LLM can actually see it
131-
import base64
132-
133-
image_b64 = base64.b64encode(img_bytes).decode("utf-8")
134-
135-
return ImageContent(
136-
type="image",
137-
source={
138-
"type": "base64",
139-
"media_type": "image/png",
140-
"data": image_b64,
141-
},
142-
)
131+
return {
132+
"status": "success",
133+
"content": [
134+
{
135+
"image": {
136+
"format": "png",
137+
"source": {
138+
"bytes": img_bytes,
139+
},
140+
}
141+
}
142+
],
143+
}
143144

144145
return view_image
145146

0 commit comments

Comments
 (0)