Skip to content

Commit ef8ac8f

Browse files
committed
Handle multi content tool messages
1 parent e1a9446 commit ef8ac8f

File tree

1 file changed

+16
-5
lines changed
  • js/packages/openinference-vercel/src

1 file changed

+16
-5
lines changed

js/packages/openinference-vercel/src/utils.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,23 @@ const getInputMessageAttributes = (promptMessages?: AttributeValue) => {
247247
...acc,
248248
...message,
249249
[`${MESSAGE_PREFIX}.${SemanticConventions.MESSAGE_ROLE}`]: message.role,
250-
[`${MESSAGE_PREFIX}.${SemanticConventions.TOOL_CALL_ID}`]:
251-
typeof message.toolCallId === "string"
252-
? message.toolCallId
250+
[`${MESSAGE_PREFIX}.${SemanticConventions.MESSAGE_TOOL_CALL_ID}`]:
251+
Array.isArray(message.content)
252+
? typeof message.content[0]?.toolCallId === "string"
253+
? message.content[0].toolCallId
254+
: undefined
255+
: typeof message.toolCallId === "string"
256+
? message.toolCallId
257+
: undefined,
258+
[`${MESSAGE_PREFIX}.${SemanticConventions.TOOL_NAME}`]: Array.isArray(
259+
message.content,
260+
)
261+
? typeof message.content[0]?.toolName === "string"
262+
? message.content[0].toolName
263+
: undefined
264+
: typeof message.toolName === "string"
265+
? message.toolName
253266
: undefined,
254-
[`${MESSAGE_PREFIX}.${SemanticConventions.TOOL_NAME}`]:
255-
typeof message.toolName === "string" ? message.toolName : undefined,
256267
[`${MESSAGE_PREFIX}.${SemanticConventions.MESSAGE_CONTENT}`]:
257268
Array.isArray(message.content)
258269
? typeof message.content[0]?.result === "string"

0 commit comments

Comments
 (0)