Skip to content

Commit 97b5b04

Browse files
committed
fix: update benchmark.py to handle multimodal content
1 parent c630f06 commit 97b5b04

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/balatrollm/benchmark.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,22 @@ def extract_request_content(self, requests_file: Path) -> dict[str, str]:
266266
if custom_id and "body" in data and "messages" in data["body"]:
267267
messages = data["body"]["messages"]
268268
if messages and len(messages) > 0:
269-
content_by_id[custom_id] = (
270-
messages[0].get("content", "") or "Content not available"
271-
)
269+
content = messages[0].get("content", "")
270+
if isinstance(content, list):
271+
# Handle multimodal content: extract text from each item
272+
text_parts = [
273+
item.get("text", "")
274+
for item in content
275+
if "text" in item
276+
]
277+
content_by_id[custom_id] = (
278+
"\n".join(text_parts) or "Content not available"
279+
)
280+
else:
281+
# Handle simple string content
282+
content_by_id[custom_id] = (
283+
content or "Content not available"
284+
)
272285
return content_by_id
273286

274287
def extract_response_data(self, responses_file: Path) -> dict[str, dict]:

0 commit comments

Comments
 (0)