Skip to content

Commit ef89a3b

Browse files
committed
add nested "data"
Signed-off-by: ixlmar <[email protected]>
1 parent 703df33 commit ef89a3b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

tensorrt_llm/serve/chat_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,16 @@ class ChatCompletionContentPartVideoParam(TypedDict, total=False):
3434
type: Required[Literal["video_url"]]
3535

3636

37+
class ImageEmbedsData(TypedDict):
38+
"""Type definition for serialized image embeddings structure."""
39+
data: Required[str]
40+
41+
3742
class ChatCompletionContentPartImageEmbedsParam(TypedDict, total=False):
3843
"""Type definition for image embeddings passed in base64-encoded PyTorch tensor format."""
39-
image_embeds: Required[str]
44+
image_embeds: Required[
45+
# NB: Besides "data", could support "url" and "ipc_handle" in the future.
46+
ImageEmbedsData]
4047
type: Required[Literal["image_embeds"]]
4148

4249

@@ -75,7 +82,8 @@ class ChatCompletionContentPartImageEmbedsParam(TypedDict, total=False):
7582
"audio_url":
7683
lambda part: _AudioParser(part).get("audio_url", {}).get("url", None),
7784
"image_embeds":
78-
lambda part: _ImageEmbedsParser(part).get("image_embeds", None),
85+
lambda part: _ImageEmbedsParser(part).get("image_embeds", {}).get(
86+
"data", None),
7987
}
8088

8189
# Map from content part tags used to directly provide embeddings

tests/unittest/llmapi/apps/_test_openai_chat_multimodal.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ def test_single_chat_session_image_embeds(
197197
assert image_content["type"] == "image_url"
198198
image_content.clear()
199199
image_content["type"] = "image_embeds"
200-
image_content["image_embeds"] = b64encode(mm_embed_bytes).decode("ascii")
200+
image_content["image_embeds"] = {
201+
"data": b64encode(mm_embed_bytes).decode("ascii")
202+
}
201203

202204
# test single completion
203205
#

0 commit comments

Comments
 (0)