Skip to content

Commit 7932dba

Browse files
committed
update
1 parent dcbc924 commit 7932dba

File tree

1 file changed

+5
-6
lines changed
  • packages/core/src/utils/anthropic-ai

1 file changed

+5
-6
lines changed

packages/core/src/utils/anthropic-ai/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,
2424
GEN_AI_SYSTEM_ATTRIBUTE,
2525
} from '../ai/gen-ai-attributes';
26+
import { filterMediaFromMessages } from '../ai/mediaFiltering';
2627
import { buildMethodPath, getFinalOperationName, getSpanOperation, setTokenUsageAttributes } from '../ai/utils';
2728
import { handleCallbackErrors } from '../handleCallbackErrors';
2829
import { instrumentAsyncIterableStream, instrumentMessageStream } from './streaming';
@@ -71,16 +72,14 @@ function extractRequestAttributes(args: unknown[], methodPath: string): Record<s
7172
return attributes;
7273
}
7374

74-
/**
75-
* Add private request attributes to spans.
76-
* This is only recorded if recordInputs is true.
77-
*/
7875
function addPrivateRequestAttributes(span: Span, params: Record<string, unknown>): void {
7976
if ('messages' in params) {
80-
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.messages) });
77+
const filtered = filterMediaFromMessages(params.messages);
78+
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(filtered) });
8179
}
8280
if ('input' in params) {
83-
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.input) });
81+
const filtered = filterMediaFromMessages(params.input);
82+
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(filtered) });
8483
}
8584
if ('prompt' in params) {
8685
span.setAttributes({ [GEN_AI_PROMPT_ATTRIBUTE]: JSON.stringify(params.prompt) });

0 commit comments

Comments
 (0)