Skip to content

Commit 990bbab

Browse files
committed
more discriminated unions
1 parent b9d3d73 commit 990bbab

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

js/packages/openinference-instrumentation-openai/src/instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ function getChatCompletionInputMessageAttributes(
755755
] = toolCall.function.arguments;
756756
} else {
757757
// TODO: add exhaustive checks
758-
diag.debug(`Unsupported tool type: ${toolCall.type}`);
758+
diag.warn(`Unsupported tool type: ${toolCall.type}`);
759759
}
760760
});
761761
}
@@ -886,7 +886,7 @@ function getChatCompletionOutputMessageAttributes(
886886
] = toolCall.function.arguments;
887887
} else {
888888
// TODO: switch to exhaustive checks
889-
diag.debug(`Unsupported tool type: ${toolCall.type}`);
889+
diag.warn(`Unsupported tool type: ${toolCall.type}`);
890890
}
891891
});
892892
}

js/packages/openinference-instrumentation-openai/src/responsesAttributes.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SemanticConventions } from "@arizeai/openinference-semantic-conventions";
2-
import { Attributes } from "@opentelemetry/api";
2+
import { Attributes, diag } from "@opentelemetry/api";
33
import {
44
ResponseCreateParamsBase,
55
ResponseInputItem,
@@ -42,8 +42,12 @@ function getResponseItemAttributes(
4242
attributes[`${prefix}${SemanticConventions.MESSAGE_ROLE}`] = "tool";
4343
attributes[`${prefix}${SemanticConventions.MESSAGE_TOOL_CALL_ID}`] =
4444
item.call_id;
45-
attributes[`${prefix}${SemanticConventions.MESSAGE_CONTENT}`] =
46-
item.output;
45+
if (typeof item.output === "string") {
46+
attributes[`${prefix}${SemanticConventions.MESSAGE_CONTENT}`] =
47+
item.output;
48+
} else {
49+
diag.warn("Failed to serialize non-string typed tool output");
50+
}
4751
break;
4852
}
4953
case "reasoning": {

0 commit comments

Comments
 (0)