Skip to content

Commit dcbc924

Browse files
committed
update
1 parent cccf345 commit dcbc924

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/core/src/utils/openai/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,
2020
GEN_AI_SYSTEM_ATTRIBUTE,
2121
} from '../ai/gen-ai-attributes';
22+
import { filterMediaFromMessages } from '../ai/mediaFiltering';
2223
import { OPENAI_INTEGRATION_NAME } from './constants';
2324
import { instrumentStream } from './streaming';
2425
import type {
@@ -188,13 +189,14 @@ function addResponseAttributes(span: Span, result: unknown, recordOutputs?: bool
188189
}
189190
}
190191

191-
// Extract and record AI request inputs, if present. This is intentionally separate from response attributes.
192192
function addRequestAttributes(span: Span, params: Record<string, unknown>): void {
193193
if ('messages' in params) {
194-
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.messages) });
194+
const filtered = filterMediaFromMessages(params.messages);
195+
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(filtered) });
195196
}
196197
if ('input' in params) {
197-
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.input) });
198+
const filtered = filterMediaFromMessages(params.input);
199+
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(filtered) });
198200
}
199201
}
200202

0 commit comments

Comments
 (0)