Skip to content

Commit

Permalink
auto model pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
slava-vishnyakov committed Aug 6, 2024
1 parent 27eda25 commit 08fc5d8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
50 changes: 50 additions & 0 deletions src/chatlet/model_pricing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
MODEL_PRICING = {}

MODEL_PRICING["meta-llama/llama-3.1-405b"] = {
"input_price_per_token": 0.000002,
"output_price_per_token": 0.000002,
"image_price_per_thousand": 0,
}

MODEL_PRICING["01-ai/yi-vision"] = {
"input_price_per_token": 0.00000019,
"output_price_per_token": 0.00000019,
"image_price_per_thousand": 0,
}

MODEL_PRICING["01-ai/yi-large-fc"] = {
"input_price_per_token": 0.000003,
"output_price_per_token": 0.000003,
"image_price_per_thousand": 0,
}

MODEL_PRICING["01-ai/yi-large-turbo"] = {
"input_price_per_token": 0.00000019,
"output_price_per_token": 0.00000019,
"image_price_per_thousand": 0,
}

MODEL_PRICING["nothingiisreal/mn-celeste-12b"] = {
"input_price_per_token": 0.0000015,
"output_price_per_token": 0.0000015,
"image_price_per_thousand": 0,
}

MODEL_PRICING["google/gemini-pro-1.5-exp"] = {
"input_price_per_token": 0.0000025,
"output_price_per_token": 0.0000075,
"image_price_per_thousand": 0.00265,
}

MODEL_PRICING["perplexity/llama-3.1-sonar-large-128k-online"] = {
"input_price_per_token": 0.000001,
"output_price_per_token": 0.000001,
Expand Down Expand Up @@ -132,6 +168,12 @@
"image_price_per_thousand": 0,
}

MODEL_PRICING["01-ai/yi-large"] = {
"input_price_per_token": 0.000003,
"output_price_per_token": 0.000003,
"image_price_per_thousand": 0,
}

MODEL_PRICING["anthropic/claude-3.5-sonnet:beta"] = {
"input_price_per_token": 0.000003,
"output_price_per_token": 0.000015,
Expand Down Expand Up @@ -1068,3 +1110,11 @@
"image_price_per_thousand": 0,
}

# ADD PRICING ABOVE THIS LINE, KEEP THIS LINE

def get_model_pricing(model: str):
return MODEL_PRICING.get(model, {
"input_price_per_token": 0,
"output_price_per_token": 0,
"image_price_per_thousand": 0,
})
2 changes: 1 addition & 1 deletion src/chatlet/test_chatlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_url_context():

rsps.add_passthru('https://')

response = chat("Write the title and exact content I provided above", urls=[url], temperature=0.0)
response = chat("Write the title and exact content I provided from text above", urls=[url], temperature=0.0)

assert "Test Article" in response.lower() or "test article" in response.lower()
assert "content" in response.lower()
Expand Down
9 changes: 9 additions & 0 deletions src/chatlet/update_model_pricing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ def main():
file.write(f' "image_price_per_thousand": {pricing["image"]},\n')
file.write('}\n\n')

file.write("# ADD PRICING ABOVE THIS LINE, KEEP THIS LINE\n\n")
file.write("")
file.write("def get_model_pricing(model: str):\n")
file.write(" return MODEL_PRICING.get(model, {\n")
file.write(" \"input_price_per_token\": 0,\n")
file.write(" \"output_price_per_token\": 0,\n")
file.write(" \"image_price_per_thousand\": 0,\n")
file.write(" })\n")

print("Model pricing information has been written to model_pricing.py")
else:
print(f"Failed to retrieve data. Status code: {response.status_code}")
Expand Down

0 comments on commit 08fc5d8

Please sign in to comment.