metergraph-core 0.2.19__tar.gz → 0.2.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {metergraph_core-0.2.19/src/metergraph_core.egg-info → metergraph_core-0.2.20}/PKG-INFO +1 -1
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/pyproject.toml +1 -1
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core/catalog.py +28 -4
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core/loader.py +4 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20/src/metergraph_core.egg-info}/PKG-INFO +1 -1
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/MANIFEST.in +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/README.md +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/setup.cfg +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core/__init__.py +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core/billing.py +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core/data/prices.yaml +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core/retrieval.py +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core.egg-info/SOURCES.txt +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core.egg-info/dependency_links.txt +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core.egg-info/requires.txt +0 -0
- {metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core.egg-info/top_level.txt +0 -0
|
@@ -142,6 +142,8 @@ def _price_tokens(
|
|
|
142
142
|
output_tokens: Any,
|
|
143
143
|
cache_read_tokens: Any,
|
|
144
144
|
cache_write_tokens: Any,
|
|
145
|
+
cache_write_5m_tokens: Any,
|
|
146
|
+
cache_write_1h_tokens: Any,
|
|
145
147
|
batch: bool,
|
|
146
148
|
) -> tuple[Decimal, list[str]]:
|
|
147
149
|
"""Cost a token usage against one already-selected price and its merged
|
|
@@ -151,7 +153,11 @@ def _price_tokens(
|
|
|
151
153
|
input_count = _tokens(input_tokens)
|
|
152
154
|
output_count = _tokens(output_tokens)
|
|
153
155
|
cache_read_count = _tokens(cache_read_tokens) or 0
|
|
154
|
-
|
|
156
|
+
cache_write_5m_count = _tokens(cache_write_5m_tokens)
|
|
157
|
+
if cache_write_5m_count is None:
|
|
158
|
+
cache_write_5m_count = _tokens(cache_write_tokens) or 0
|
|
159
|
+
cache_write_1h_count = _tokens(cache_write_1h_tokens) or 0
|
|
160
|
+
cache_write_count = cache_write_5m_count + cache_write_1h_count
|
|
155
161
|
if input_count is None:
|
|
156
162
|
reasons.append("missing_input_tokens")
|
|
157
163
|
input_count = 0
|
|
@@ -215,16 +221,26 @@ def _price_tokens(
|
|
|
215
221
|
* input_multiplier
|
|
216
222
|
/ _MILLION
|
|
217
223
|
)
|
|
218
|
-
if
|
|
224
|
+
if cache_write_5m_count:
|
|
219
225
|
if price.cache_write_5m_per_mtok is None:
|
|
220
|
-
reasons.append("
|
|
226
|
+
reasons.append("cache_write_5m_rate_unavailable")
|
|
221
227
|
else:
|
|
222
228
|
cost += (
|
|
223
|
-
Decimal(
|
|
229
|
+
Decimal(cache_write_5m_count)
|
|
224
230
|
* price.cache_write_5m_per_mtok
|
|
225
231
|
* input_multiplier
|
|
226
232
|
/ _MILLION
|
|
227
233
|
)
|
|
234
|
+
if cache_write_1h_count:
|
|
235
|
+
if price.cache_write_1h_per_mtok is None:
|
|
236
|
+
reasons.append("cache_write_1h_rate_unavailable")
|
|
237
|
+
else:
|
|
238
|
+
cost += (
|
|
239
|
+
Decimal(cache_write_1h_count)
|
|
240
|
+
* price.cache_write_1h_per_mtok
|
|
241
|
+
* input_multiplier
|
|
242
|
+
/ _MILLION
|
|
243
|
+
)
|
|
228
244
|
if rules.get("uncaptured_fees"):
|
|
229
245
|
reasons.append("uncaptured_fees")
|
|
230
246
|
|
|
@@ -338,6 +354,8 @@ class CatalogSnapshot:
|
|
|
338
354
|
output_tokens: Any,
|
|
339
355
|
cache_read_tokens: Any = None,
|
|
340
356
|
cache_write_tokens: Any = None,
|
|
357
|
+
cache_write_5m_tokens: Any = None,
|
|
358
|
+
cache_write_1h_tokens: Any = None,
|
|
341
359
|
batch: bool = False,
|
|
342
360
|
) -> CostResult:
|
|
343
361
|
provider_key = str(provider or "").strip().lower()
|
|
@@ -363,6 +381,8 @@ class CatalogSnapshot:
|
|
|
363
381
|
output_tokens=output_tokens,
|
|
364
382
|
cache_read_tokens=cache_read_tokens,
|
|
365
383
|
cache_write_tokens=cache_write_tokens,
|
|
384
|
+
cache_write_5m_tokens=cache_write_5m_tokens,
|
|
385
|
+
cache_write_1h_tokens=cache_write_1h_tokens,
|
|
366
386
|
batch=batch,
|
|
367
387
|
)
|
|
368
388
|
return CostResult(
|
|
@@ -383,6 +403,8 @@ class CatalogSnapshot:
|
|
|
383
403
|
output_tokens: Any,
|
|
384
404
|
cache_read_tokens: Any = None,
|
|
385
405
|
cache_write_tokens: Any = None,
|
|
406
|
+
cache_write_5m_tokens: Any = None,
|
|
407
|
+
cache_write_1h_tokens: Any = None,
|
|
386
408
|
batch: bool = False,
|
|
387
409
|
) -> CostResult:
|
|
388
410
|
"""Price an observed deployment from the identity a caller already has:
|
|
@@ -406,6 +428,8 @@ class CatalogSnapshot:
|
|
|
406
428
|
output_tokens=output_tokens,
|
|
407
429
|
cache_read_tokens=cache_read_tokens,
|
|
408
430
|
cache_write_tokens=cache_write_tokens,
|
|
431
|
+
cache_write_5m_tokens=cache_write_5m_tokens,
|
|
432
|
+
cache_write_1h_tokens=cache_write_1h_tokens,
|
|
409
433
|
batch=batch,
|
|
410
434
|
)
|
|
411
435
|
return CostResult(
|
|
@@ -100,6 +100,8 @@ class LoadedCatalog:
|
|
|
100
100
|
output_tokens: Any,
|
|
101
101
|
cache_read_tokens: Any = None,
|
|
102
102
|
cache_write_tokens: Any = None,
|
|
103
|
+
cache_write_5m_tokens: Any = None,
|
|
104
|
+
cache_write_1h_tokens: Any = None,
|
|
103
105
|
batch: bool = False,
|
|
104
106
|
) -> CostResult:
|
|
105
107
|
"""Price an observed deployment channel-exactly. See
|
|
@@ -112,6 +114,8 @@ class LoadedCatalog:
|
|
|
112
114
|
output_tokens=output_tokens,
|
|
113
115
|
cache_read_tokens=cache_read_tokens,
|
|
114
116
|
cache_write_tokens=cache_write_tokens,
|
|
117
|
+
cache_write_5m_tokens=cache_write_5m_tokens,
|
|
118
|
+
cache_write_1h_tokens=cache_write_1h_tokens,
|
|
115
119
|
batch=batch,
|
|
116
120
|
)
|
|
117
121
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{metergraph_core-0.2.19 → metergraph_core-0.2.20}/src/metergraph_core.egg-info/top_level.txt
RENAMED
|
File without changes
|