33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6+ 'use strict'
7+
68const LlmEmbedding = require ( '../embedding' )
79
810/**
@@ -15,31 +17,27 @@ module.exports = class AwsBedrockLlmEmbedding extends LlmEmbedding {
1517 * @param {Agent } params.agent New Relic agent instance
1618 * @param {object } params.segment Current segment
1719 * @param {object } params.transaction Current and active transaction
18- * @param {string } params.requestId ID associated with the request - typically available in response headers
1920 * @param {string } params.requestInput Input to the embedding creation call
20- * @param {string } params.requestModel Model name specified in the request (e.g. 'gpt-4')
21- * @param {number } params.totalTokenCount Retrieved from the Bedrock response object, fallback for token calculation
22- * @param {boolean } [params.error] Set to `true` if an error occurred during creation call - omitted if no error occurred
21+ * @param {object } params.bedrockCommand AWS Bedrock Command object, represents the request
22+ * @param {object } params.bedrockResponse AWS Bedrock Response object
23+ * @param {boolean } [params.error] Set to `true` if an error occurred during creation call
24+ * - omitted if no error occurred
2325 */
24- constructor ( { agent, segment, transaction, requestInput, requestModel , requestId , totalTokenCount = 0 , error } ) {
26+ constructor ( { agent, segment, transaction, requestInput, bedrockCommand , bedrockResponse , error } ) {
2527 super ( { agent,
2628 segment,
2729 transaction,
2830 vendor : 'bedrock' ,
31+ requestId : bedrockResponse ?. requestId ,
2932 requestInput,
30- requestModel,
31- requestId,
32- responseModel : requestModel , // we can assume this in bedrock
33+ requestModel : bedrockCommand ?. modelId ,
34+ responseModel : bedrockCommand ?. modelId , // we can assume requestModel==responseModel in bedrock
3335 error } )
3436
35- this . appName = agent . config . applications ( ) [ 0 ] // TODO: still required?
36- this . setTotalTokens ( agent , requestInput , totalTokenCount )
37- // TODO: bedrockResponse has headers, but they are not
38- // in the list of `response.headers.<vendor_specific_headers>`,
39- // still include them?
37+ this . setTotalTokens ( { agent, input : requestInput , totalTokenCount : bedrockResponse ?. totalTokenCount } )
4038 }
4139
42- setTotalTokens ( agent , input , totalTokenCount ) {
40+ setTotalTokens ( { agent, input, totalTokenCount } ) {
4341 const tokenCB = agent ?. llm ?. tokenCountCallback
4442
4543 // For embedding events, only total token count is relevant.
0 commit comments