Commit
·
eda87ee
1
Parent(s):
73a4307
- src/App.tsx +25 -0
src/App.tsx
CHANGED
@@ -63,6 +63,19 @@ const App: React.FC = () => {
|
|
63 |
return price * tokens;
|
64 |
};
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
const calculateComparison = (
|
67 |
modelPrice: number,
|
68 |
comparisonPrice: number
|
@@ -242,6 +255,9 @@ const App: React.FC = () => {
|
|
242 |
Note: If you use Amazon Bedrock or Azure prices for Anthropic, Cohere
|
243 |
or OpenAI should be the same.
|
244 |
</p>
|
|
|
|
|
|
|
245 |
|
246 |
<Table>
|
247 |
<TableHeader>
|
@@ -270,6 +286,8 @@ const App: React.FC = () => {
|
|
270 |
) : null}
|
271 |
</button>
|
272 |
</TableHead>
|
|
|
|
|
273 |
<TableHead>
|
274 |
<button type="button" onClick={() => requestSort('inputPrice')}>
|
275 |
Input Price (per 1M tokens){' '}
|
@@ -294,6 +312,7 @@ const App: React.FC = () => {
|
|
294 |
) : null}
|
295 |
</button>
|
296 |
</TableHead>
|
|
|
297 |
<TableHead>Total Price</TableHead>
|
298 |
{comparisonModels.map((model) => (
|
299 |
<TableHead key={model} colSpan={2}>
|
@@ -356,8 +375,12 @@ const App: React.FC = () => {
|
|
356 |
</a>
|
357 |
</TableCell>
|
358 |
<TableCell>{item.name}</TableCell>
|
|
|
|
|
|
|
359 |
<TableCell>{item.inputPrice.toFixed(2)}</TableCell>
|
360 |
<TableCell>{item.outputPrice.toFixed(2)}</TableCell>
|
|
|
361 |
<TableCell className="font-bold">
|
362 |
$
|
363 |
{(
|
@@ -365,6 +388,8 @@ const App: React.FC = () => {
|
|
365 |
calculatePrice(item.outputPrice, outputTokens)
|
366 |
).toFixed(2)}
|
367 |
</TableCell>
|
|
|
|
|
368 |
{comparisonModels.flatMap((comparisonModel) => {
|
369 |
const [comparisonProvider, comparisonModelName] =
|
370 |
comparisonModel.split(':');
|
|
|
63 |
return price * tokens;
|
64 |
};
|
65 |
|
66 |
+
const calculateBlendedPrice = (
|
67 |
+
inputPrice: number,
|
68 |
+
outputPrice: number,
|
69 |
+
inputTokens: number,
|
70 |
+
outputTokens: number
|
71 |
+
): number => {
|
72 |
+
const inputRatio = 3; // Fixed input to output ratio
|
73 |
+
const totalInputTokens = inputTokens * inputRatio;
|
74 |
+
const blendedPrice = (inputPrice * totalInputTokens + outputPrice * outputTokens) / (totalInputTokens + outputTokens);
|
75 |
+
return blendedPrice;
|
76 |
+
};
|
77 |
+
|
78 |
+
|
79 |
const calculateComparison = (
|
80 |
modelPrice: number,
|
81 |
comparisonPrice: number
|
|
|
255 |
Note: If you use Amazon Bedrock or Azure prices for Anthropic, Cohere
|
256 |
or OpenAI should be the same.
|
257 |
</p>
|
258 |
+
<p className="italic text-sm text-muted-foreground mb-4">
|
259 |
+
Blended Price reflects the average cost of input and output tokens, calculated using a fixed ratio (e.g., 3:1), to give a unified rate per million tokens.
|
260 |
+
</p>
|
261 |
|
262 |
<Table>
|
263 |
<TableHeader>
|
|
|
286 |
) : null}
|
287 |
</button>
|
288 |
</TableHead>
|
289 |
+
<TableHead>Blended Price</TableHead>
|
290 |
+
|
291 |
<TableHead>
|
292 |
<button type="button" onClick={() => requestSort('inputPrice')}>
|
293 |
Input Price (per 1M tokens){' '}
|
|
|
312 |
) : null}
|
313 |
</button>
|
314 |
</TableHead>
|
315 |
+
|
316 |
<TableHead>Total Price</TableHead>
|
317 |
{comparisonModels.map((model) => (
|
318 |
<TableHead key={model} colSpan={2}>
|
|
|
375 |
</a>
|
376 |
</TableCell>
|
377 |
<TableCell>{item.name}</TableCell>
|
378 |
+
<TableCell className="font-bold">
|
379 |
+
${calculateBlendedPrice(item.inputPrice, item.outputPrice, inputTokens, outputTokens).toFixed(2)}
|
380 |
+
</TableCell>
|
381 |
<TableCell>{item.inputPrice.toFixed(2)}</TableCell>
|
382 |
<TableCell>{item.outputPrice.toFixed(2)}</TableCell>
|
383 |
+
|
384 |
<TableCell className="font-bold">
|
385 |
$
|
386 |
{(
|
|
|
388 |
calculatePrice(item.outputPrice, outputTokens)
|
389 |
).toFixed(2)}
|
390 |
</TableCell>
|
391 |
+
|
392 |
+
|
393 |
{comparisonModels.flatMap((comparisonModel) => {
|
394 |
const [comparisonProvider, comparisonModelName] =
|
395 |
comparisonModel.split(':');
|