|
2 | 2 | from chatlas import ChatAnthropic, ChatGoogle, ChatOpenAI, Turn |
3 | 3 | from chatlas._openai import OpenAIAzureProvider, OpenAIProvider |
4 | 4 | from chatlas._tokens import ( |
5 | | - compute_price, |
| 5 | + compute_cost, |
6 | 6 | get_token_pricing, |
7 | 7 | token_usage, |
8 | 8 | tokens_log, |
@@ -59,29 +59,22 @@ def test_token_count_method(): |
59 | 59 | def test_get_token_prices(): |
60 | 60 | chat = ChatOpenAI(model="o1-mini") |
61 | 61 | pricing = get_token_pricing(chat.provider.name, chat.provider.model) |
| 62 | + assert pricing is not None |
62 | 63 | assert pricing["provider"] == "OpenAI" |
63 | 64 | assert pricing["model"] == "o1-mini" |
64 | 65 | assert isinstance(pricing["cached_input"], float) |
65 | 66 | assert isinstance(pricing["input"], float) |
66 | 67 | assert isinstance(pricing["output"], float) |
67 | 68 |
|
68 | | - with pytest.warns( |
69 | | - match="Token pricing for the provider 'OpenAI' and model 'ABCD' you selected is not available. " |
70 | | - "Please check the provider's documentation." |
71 | | - ): |
72 | | - chat = ChatOpenAI(model="ABCD") |
73 | | - pricing = get_token_pricing(chat.provider.name, chat.provider.model) |
74 | | - assert pricing is None |
75 | 69 |
|
76 | | - |
77 | | -def test_compute_price(): |
| 70 | +def test_compute_cost(): |
78 | 71 | chat = ChatOpenAI(model="o1-mini") |
79 | | - price = compute_price(chat.provider.name, chat.provider.model, 10, 50) |
| 72 | + price = compute_cost(chat.provider.name, chat.provider.model, 10, 50) |
80 | 73 | assert isinstance(price, float) |
81 | 74 | assert price > 0 |
82 | 75 |
|
83 | 76 | chat = ChatOpenAI(model="ABCD") |
84 | | - price = compute_price(chat.provider.name, chat.provider.model, 10, 50) |
| 77 | + price = compute_cost(chat.provider.name, chat.provider.model, 10, 50) |
85 | 78 | assert price is None |
86 | 79 |
|
87 | 80 |
|
|
0 commit comments