@@ -10,7 +10,7 @@ const assert = require('node:assert')
1010const {
1111 DESTINATIONS : { TRANS_SCOPE }
1212} = require ( '../../../../lib/config/attribute-filter' )
13- const LlmEmbedding = require ( '../../../../lib/ llm-events/aws-bedrock/embedding' )
13+ const LlmEmbedding = require ( '#agentlib/ llm-events-new /aws-bedrock/embedding.js ' )
1414
1515test . beforeEach ( ( ctx ) => {
1616 ctx . nr = { }
@@ -45,19 +45,10 @@ test.beforeEach((ctx) => {
4545 }
4646 }
4747
48- ctx . nr . bedrockCommand = {
49- }
50-
51- ctx . nr . input = 'who are you'
48+ ctx . nr . requestInput = 'who are you'
49+ ctx . nr . requestId = 'request-1'
50+ ctx . nr . totalTokenCount = 70
5251
53- ctx . nr . bedrockResponse = {
54- headers : {
55- 'x-amzn-requestid' : 'request-1'
56- } ,
57- get inputTokenCount ( ) {
58- return 70
59- }
60- }
6152 ctx . nr . transaction = {
6253 traceId : 'id'
6354 }
@@ -82,17 +73,13 @@ test('should not capture input when `ai_monitoring.record_content.enabled` is fa
8273 assert . equal ( event . input , undefined , 'input should be empty' )
8374} )
8475
85- test ( 'capture total token usage attribute when inputTokenCount is set' , async ( t ) => {
76+ test ( 'capture total token usage attribute when totalTokenCount is set' , async ( t ) => {
8677 const event = new LlmEmbedding ( t . nr )
8778 assert . equal ( event [ 'response.usage.total_tokens' ] , 70 )
8879} )
8980
90- test ( 'does not capture total token usage when inputTokenCount is not set' , async ( t ) => {
91- Object . defineProperty ( t . nr . bedrockResponse , 'inputTokenCount' , {
92- get ( ) {
93- return undefined
94- }
95- } )
81+ test ( 'does not capture total token usage when totalTokenCount is not set' , async ( t ) => {
82+ t . nr . totalTokenCount = undefined
9683 const event = new LlmEmbedding ( t . nr )
9784 assert . equal ( event [ 'response.usage.total_tokens' ] , undefined )
9885} )
@@ -106,14 +93,3 @@ test('should use token callback to set total token usage attribute', async (t) =
10693
10794 assert . equal ( event [ 'response.usage.total_tokens' ] , 65 )
10895} )
109-
110- test ( 'should not call token callback if there is no content' , async ( t ) => {
111- function cb ( model , content ) {
112- return 65
113- }
114- t . nr . agent . llm . tokenCountCallback = cb
115- t . nr . input = undefined
116- const event = new LlmEmbedding ( t . nr )
117-
118- assert . equal ( event [ 'response.usage.total_tokens' ] , undefined )
119- } )
0 commit comments