Skip to content

Commit

Permalink
Add additional meta llama models
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangcolsman committed Jan 13, 2025
1 parent 34578f8 commit 5353952
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions libs/aws/langchain_aws/callbacks/bedrock_callback.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import threading
from typing import Any, Dict, List, Union

Expand All @@ -19,6 +20,12 @@
"meta.llama3-8b-instruct-v1:0": 0.0003,
"meta.llama2-13b-chat-v1": 0.00075,
"meta.llama2-70b-chat-v1": 0.00195,
"meta.llama3-1-70b-instruct-v1:0": 0.00072,
"meta.llama3-1-8b-instruct-v1:0": 0.00022,
"meta.llama3-2-11b-instruct-v1:0": 0.00016,
"meta.llama3-2-1b-instruct-v1:0": 0.0001,
"meta.llama3-2-3b-instruct-v1:0": 0.00015,
"meta.llama3-2-90b-instruct-v1:0": 0.00072,
"meta.llama3-3-70b-instruct-v1:0": 0.00072,
"amazon.nova-pro-v1:0": 0.0008,
"amazon.nova-lite-v1:0": 0.00006,
Expand All @@ -39,6 +46,12 @@
"meta.llama3-8b-instruct-v1:0": 0.0006,
"meta.llama2-13b-chat-v1": 0.00100,
"meta.llama2-70b-chat-v1": 0.00256,
"meta.llama3-1-70b-instruct-v1:0": 0.00072,
"meta.llama3-1-8b-instruct-v1:0": 0.00022,
"meta.llama3-2-11b-instruct-v1:0": 0.00016,
"meta.llama3-2-1b-instruct-v1:0": 0.0001,
"meta.llama3-2-3b-instruct-v1:0": 0.00015,
"meta.llama3-2-90b-instruct-v1:0": 0.00072,
"meta.llama3-3-70b-instruct-v1:0": 0.00072,
"amazon.nova-pro-v1:0": 0.0032,
"amazon.nova-lite-v1:0": 0.00024,
Expand All @@ -59,6 +72,12 @@
"meta.llama3-8b-instruct-v1:0": 0.0,
"meta.llama2-13b-chat-v1": 0.0,
"meta.llama2-70b-chat-v1": 0.0,
"meta.llama3-1-70b-instruct-v1:0": 0.0,
"meta.llama3-1-8b-instruct-v1:0": 0.0,
"meta.llama3-2-11b-instruct-v1:0": 0.0,
"meta.llama3-2-1b-instruct-v1:0": 0.0,
"meta.llama3-2-3b-instruct-v1:0": 0.0,
"meta.llama3-2-90b-instruct-v1:0": 0.0,
"meta.llama3-3-70b-instruct-v1:0": 0.0,
"amazon.nova-pro-v1:0": 0.0,
"amazon.nova-lite-v1:0": 0.0,
Expand All @@ -79,12 +98,20 @@
"meta.llama3-8b-instruct-v1:0": 0.0,
"meta.llama2-13b-chat-v1": 0.0,
"meta.llama2-70b-chat-v1": 0.0,
"meta.llama3-1-70b-instruct-v1:0": 0.0,
"meta.llama3-1-8b-instruct-v1:0": 0.0,
"meta.llama3-2-11b-instruct-v1:0": 0.0,
"meta.llama3-2-1b-instruct-v1:0": 0.0,
"meta.llama3-2-3b-instruct-v1:0": 0.0,
"meta.llama3-2-90b-instruct-v1:0": 0.0,
"meta.llama3-3-70b-instruct-v1:0": 0.0,
"amazon.nova-pro-v1:0": 0.0002,
"amazon.nova-lite-v1:0": 0.000015,
"amazon.nova-micro-v1:0": 0.00000875,
}

logger = logging.getLogger(__name__)


def _get_token_cost(
prompt_tokens: int,
Expand All @@ -105,10 +132,14 @@ def _get_token_cost(
base_model_id = model_id
"""Get the cost of tokens for the model."""
if base_model_id not in MODEL_COST_PER_1K_INPUT_TOKENS:
raise ValueError(
f"Unknown model: {model_id}. Please provide a valid model name."
"Known models are: " + ", ".join(MODEL_COST_PER_1K_INPUT_TOKENS.keys())
logger.error(
"Failed to calculate token cost. "
"Unknown model: %s. Please provide a valid model name. "
"Known models are: %s",
model_id,
", ".join(MODEL_COST_PER_1K_INPUT_TOKENS.keys()),
)
return 0.0
return round(
((prompt_tokens - prompt_tokens_cache_read) / 1000)
* MODEL_COST_PER_1K_INPUT_TOKENS[base_model_id]
Expand Down

0 comments on commit 5353952

Please sign in to comment.