Skip to content

Commit

Permalink
fix: add haiku price table
Browse files Browse the repository at this point in the history
  • Loading branch information
statefb committed Mar 18, 2024
1 parent 643fee3 commit 63f8bdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 10 additions & 8 deletions backend/app/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ def compose_args_for_anthropic_client(
def calculate_price(
model: str, input_tokens: int, output_tokens: int, region: str = BEDROCK_REGION
) -> float:
if region in ("us-east-1", "us-west-2", "ap-northeast-1"):
input_price = ANTHROPIC_PRICING[region][model]["input"]
output_price = ANTHROPIC_PRICING[region][model]["output"]

else:
logger.warning(f"Unsupported region: {region}. Using default pricing.")
input_price = ANTHROPIC_PRICING["default"][model]["input"]
output_price = ANTHROPIC_PRICING["default"][model]["output"]
input_price = (
ANTHROPIC_PRICING.get(region, {})
.get(model, {})
.get("input", ANTHROPIC_PRICING["default"][model]["input"])
)
output_price = (
ANTHROPIC_PRICING.get(region, {})
.get(model, {})
.get("output", ANTHROPIC_PRICING["default"][model]["output"])
)

return input_price * input_tokens / 1000.0 + output_price * output_tokens / 1000.0

Expand Down
2 changes: 2 additions & 0 deletions backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"input": 0.00080,
"output": 0.00240,
},
"claude-v3-haiku": {"input": 0.00025, "output": 0.00125},
"claude-v3-sonnet": {"input": 0.00300, "output": 0.01500},
},
"us-west-2": {
Expand Down Expand Up @@ -68,6 +69,7 @@
"input": 0.00080,
"output": 0.00240,
},
"claude-v3-haiku": {"input": 0.00025, "output": 0.00125},
"claude-v3-sonnet": {"input": 0.00300, "output": 0.01500},
},
}

0 comments on commit 63f8bdb

Please sign in to comment.