From 70334887d6e5baec690da8a6ab06ceab677bd1b2 Mon Sep 17 00:00:00 2001 From: Francis Beeson Date: Sat, 17 Feb 2024 14:28:19 +0000 Subject: [PATCH] feat: update pricing of models, and include 1106 and 0125 models. (#425) --- instructor/cli/usage.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/instructor/cli/usage.py b/instructor/cli/usage.py index 3e1dc74..87d2e63 100644 --- a/instructor/cli/usage.py +++ b/instructor/cli/usage.py @@ -53,12 +53,27 @@ MODEL_COSTS: Dict[ ModelNames, Union[Dict[str, float], float], ] = { - "gpt-3.5-turbo": {"prompt": 0.0015 / 1000, "completion": 0.002 / 1000}, - "gpt-3.5-turbo-16k": {"prompt": 0.003 / 1000, "completion": 0.004 / 1000}, - "gpt-4": {"prompt": 0.03 / 1000, "completion": 0.03 / 1000}, - "gpt-4-32k": {"prompt": 0.06 / 1000, "completion": 0.12 / 1000}, - "text-embedding-ada-002": 0.0001 / 1000, - "text-embedding-ada-002-v2": 0.0001 / 1000, + "gpt-4-0125-preview": {"prompt": 0.01 / 1000, "completion": 0.03 / 1000}, + "gpt-4-turbo-preview": {"prompt": 0.01 / 1000, "completion": 0.03 / 1000}, + "gpt-4-1106-preview": {"prompt": 0.01 / 1000, "completion": 0.03 / 1000}, + "gpt-4-vision-preview": {"prompt": 0.01 / 1000, "completion": 0.03 / 1000}, + "gpt-4": {"prompt": 0.03 / 1000, "completion": 0.06 / 1000}, + "gpt-4-0314": {"prompt": 0.03 / 1000, "completion": 0.06 / 1000}, + "gpt-4-0613": {"prompt": 0.03 / 1000, "completion": 0.06 / 1000}, + "gpt-4-32k": {"prompt": 0.06 / 1000, "completion": 0.12 / 1000}, + "gpt-4-32k-0314": {"prompt": 0.06 / 1000, "completion": 0.12 / 1000}, + "gpt-4-32k-0613": {"prompt": 0.06 / 1000, "completion": 0.12 / 1000}, + "gpt-3.5-turbo": {"prompt": 0.0005 / 1000, "completion": 0.0015 / 1000}, + "gpt-3.5-turbo-16k": {"prompt": 0.0030 / 1000, "completion": 0.0040 / 1000}, + "gpt-3.5-turbo-0301": {"prompt": 0.0015 / 1000, "completion": 0.0020 / 1000}, + "gpt-3.5-turbo-0613": {"prompt": 0.0015 / 1000, "completion": 0.0020 / 1000}, + "gpt-3.5-turbo-1106": {"prompt": 0.0010 / 1000, "completion": 0.0020 / 1000}, + "gpt-3.5-turbo-0125": {"prompt": 0.0005 / 1000, "completion": 0.0015 / 1000}, + "gpt-3.5-turbo-16k-0613": {"prompt": 0.0030 / 1000, "completion": 0.0040 / 1000}, + "gpt-3.5-turbo-instruct": {"prompt": 0.0015 / 1000, "completion": 0.0020 / 1000}, + "text-embedding-3-small": 0.00002 / 1000, + "text-embedding-3-large": 0.00013 / 1000, + "text-embedding-ada-002": 0.00010 / 1000, } @@ -68,8 +83,7 @@ def get_model_cost( """Get the cost details for a given model.""" if model in MODEL_COSTS: return MODEL_COSTS[model] - - # Handle prefix-based matching + if model.startswith("gpt-3.5-turbo-16k"): return MODEL_COSTS["gpt-3.5-turbo-16k"] elif model.startswith("gpt-3.5-turbo"):