Skip to content

Commit ef552fd

Browse files
author
EC2 Default User
committed
changed the metering data to take model_id
1 parent d8b8693 commit ef552fd

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

  • lib/idp_common_pkg/idp_common/bedrock

lib/idp_common_pkg/idp_common/bedrock/client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,7 @@ def invoke_model(
296296
inference_config["maxTokens"] = max_tokens
297297

298298
# Add additional model fields if needed
299-
additional_model_fields = {}
300-
301-
# Initialize use_model_id early to avoid UnboundLocalError
302-
use_model_id = model_id
299+
additional_model_fields = {}
303300

304301
# Handle top_k parameter
305302
if top_k is not None:
@@ -331,6 +328,7 @@ def invoke_model(
331328
additional_model_fields["inferenceConfig"]["topK"] = int(top_k)
332329

333330
# Add 1M context headers if needed
331+
use_model_id = model_id
334332
if model_id and model_id.endswith(':1m'):
335333
use_model_id = model_id[:-3] # Remove ':1m'
336334
if additional_model_fields is None:
@@ -458,7 +456,7 @@ def _invoke_with_retry(
458456
response_with_metering = {
459457
"response": response,
460458
"metering": {
461-
f"{context}/bedrock/{'modelId'}": {
459+
f"{context}/bedrock/{model_id}": {
462460
**usage
463461
}
464462
}

0 commit comments

Comments
 (0)