Skip to content

Commit

Permalink
Merge branch 'kharvd:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenwalton authored Sep 6, 2024
2 parents df3f02d + d90b1b9 commit e459831
Show file tree
Hide file tree
Showing 4 changed files with 1,560 additions and 12 deletions.
1 change: 1 addition & 0 deletions gptcli/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def get_completion_provider(model: str) -> CompletionProvider:
model.startswith("gpt")
or model.startswith("ft:gpt")
or model.startswith("oai-compat:")
or model.startswith("chatgpt")
):
return OpenAICompletionProvider()
elif model.startswith("claude"):
Expand Down
18 changes: 16 additions & 2 deletions gptcli/providers/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,21 @@ def complete(
"response": 120.0 / 1_000_000,
}

GPT_4_O_PRICE_PER_TOKEN: Pricing = {
GPT_4_O_2024_05_13_PRICE_PER_TOKEN: Pricing = {
"prompt": 5.0 / 1_000_000,
"response": 15.0 / 1_000_000,
}

GPT_4_O_2024_08_06_PRICE_PER_TOKEN: Pricing = {
"prompt": 2.50 / 1_000_000,
"response": 10.0 / 1_000_000,
}

GPT_4_O_MINI_PRICE_PER_TOKEN: Pricing = {
"prompt": 0.150 / 1_000_000,
"response": 0.600 / 1_000_000,
}


def gpt_pricing(model: str) -> Optional[Pricing]:
if model.startswith("gpt-3.5-turbo-16k"):
Expand All @@ -120,8 +130,12 @@ def gpt_pricing(model: str) -> Optional[Pricing]:
return GPT_3_5_TURBO_PRICE_PER_TOKEN
elif model.startswith("gpt-4-32k"):
return GPT_4_32K_PRICE_PER_TOKEN
elif model.startswith("gpt-4o-mini"):
return GPT_4_O_MINI_PRICE_PER_TOKEN
elif model.startswith("gpt-4o-2024-05-13") or model.startswith("chatgpt-4o-latest"):
return GPT_4_O_2024_05_13_PRICE_PER_TOKEN
elif model.startswith("gpt-4o"):
return GPT_4_O_PRICE_PER_TOKEN
return GPT_4_O_2024_08_06_PRICE_PER_TOKEN
elif model.startswith("gpt-4-turbo") or re.match(r"gpt-4-\d\d\d\d-preview", model):
return GPT_4_TURBO_PRICE_PER_TOKEN
elif model.startswith("gpt-4"):
Expand Down
20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ classifiers = [
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
"anthropic==0.25.9",
"attrs==23.2.0",
"anthropic==0.34.1",
"attrs==24.2.0",
"black==24.4.2",
"cohere==5.5.3",
"google-generativeai==0.5.4",
"mistralai==0.1.8",
"openai==1.30.1",
"prompt-toolkit==3.0.43",
"pytest==7.3.1",
"PyYAML==6.0.1",
"cohere==5.8.1",
"google-generativeai==0.7.2",
"openai==1.42.0",
"prompt-toolkit==3.0.47",
"pytest==8.3.2",
"PyYAML==6.0.2",
"rich==13.7.1",
"typing_extensions==4.11.0",
"typing_extensions==4.12.2",
"pydantic<2",
]

[project.optional-dependencies]
Expand Down
Loading

0 comments on commit e459831

Please sign in to comment.