Commit
·
2798716
1
Parent(s):
119cb29
- src/App.tsx +44 -7
src/App.tsx
CHANGED
|
@@ -50,6 +50,8 @@ const App: React.FC = () => {
|
|
| 50 |
const [selectedProviders, setSelectedProviders] = useState<string[]>([]);
|
| 51 |
const [selectedModels, setSelectedModels] = useState<string[]>([]);
|
| 52 |
const [expandedProviders, setExpandedProviders] = useState<string[]>([]);
|
|
|
|
|
|
|
| 53 |
const [sortConfig, setSortConfig] = useState<{
|
| 54 |
key: keyof FlattenedModel;
|
| 55 |
direction: string;
|
|
@@ -60,9 +62,18 @@ const App: React.FC = () => {
|
|
| 60 |
}, []);
|
| 61 |
|
| 62 |
const calculatePrice = (price: number, tokens: number): number => {
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
};
|
| 65 |
|
|
|
|
| 66 |
const calculateBlendedPrice = (
|
| 67 |
inputPrice: number,
|
| 68 |
outputPrice: number,
|
|
@@ -76,6 +87,8 @@ const App: React.FC = () => {
|
|
| 76 |
};
|
| 77 |
|
| 78 |
|
|
|
|
|
|
|
| 79 |
const calculateComparison = (
|
| 80 |
modelPrice: number,
|
| 81 |
comparisonPrice: number
|
|
@@ -225,7 +238,8 @@ const App: React.FC = () => {
|
|
| 225 |
htmlFor="inputTokens"
|
| 226 |
className="block text-sm font-medium text-gray-700"
|
| 227 |
>
|
| 228 |
-
|
|
|
|
| 229 |
</label>
|
| 230 |
<Input
|
| 231 |
id="inputTokens"
|
|
@@ -241,7 +255,7 @@ const App: React.FC = () => {
|
|
| 241 |
htmlFor="outputTokens"
|
| 242 |
className="block text-sm font-medium text-gray-700"
|
| 243 |
>
|
| 244 |
-
Output Tokens (
|
| 245 |
</label>
|
| 246 |
<Input
|
| 247 |
id="outputTokens"
|
|
@@ -252,14 +266,36 @@ const App: React.FC = () => {
|
|
| 252 |
className="mt-1"
|
| 253 |
/>
|
| 254 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
</div>
|
| 256 |
|
|
|
|
| 257 |
<p className="italic text-sm text-muted-foreground mb-4">
|
| 258 |
Note: If you use Amazon Bedrock or Azure prices for Anthropic, Cohere
|
| 259 |
or OpenAI should be the same.
|
| 260 |
</p>
|
| 261 |
<p className="italic text-sm text-muted-foreground mb-4">
|
| 262 |
-
Blended Price reflects the average cost of input and output tokens, calculated using a fixed ratio (3:1), to give a unified rate per
|
| 263 |
</p>
|
| 264 |
|
| 265 |
<Table>
|
|
@@ -293,7 +329,7 @@ const App: React.FC = () => {
|
|
| 293 |
|
| 294 |
<TableHead>
|
| 295 |
<button type="button" onClick={() => requestSort('inputPrice')}>
|
| 296 |
-
Input Price (
|
| 297 |
{sortConfig?.key === 'inputPrice' ? (
|
| 298 |
sortConfig.direction === 'ascending' ? (
|
| 299 |
'▲'
|
|
@@ -305,7 +341,7 @@ const App: React.FC = () => {
|
|
| 305 |
</TableHead>
|
| 306 |
<TableHead>
|
| 307 |
<button type="button" onClick={() => requestSort('outputPrice')}>
|
| 308 |
-
Output Price (
|
| 309 |
{sortConfig?.key === 'outputPrice' ? (
|
| 310 |
sortConfig.direction === 'ascending' ? (
|
| 311 |
'▲'
|
|
@@ -316,7 +352,8 @@ const App: React.FC = () => {
|
|
| 316 |
</button>
|
| 317 |
</TableHead>
|
| 318 |
|
| 319 |
-
|
|
|
|
| 320 |
{comparisonModels.map((model) => (
|
| 321 |
<TableHead key={model} colSpan={2}>
|
| 322 |
Compared to {model}
|
|
|
|
| 50 |
const [selectedProviders, setSelectedProviders] = useState<string[]>([]);
|
| 51 |
const [selectedModels, setSelectedModels] = useState<string[]>([]);
|
| 52 |
const [expandedProviders, setExpandedProviders] = useState<string[]>([]);
|
| 53 |
+
const [tokenCalculation, setTokenCalculation] = useState<string>('million');
|
| 54 |
+
|
| 55 |
const [sortConfig, setSortConfig] = useState<{
|
| 56 |
key: keyof FlattenedModel;
|
| 57 |
direction: string;
|
|
|
|
| 62 |
}, []);
|
| 63 |
|
| 64 |
const calculatePrice = (price: number, tokens: number): number => {
|
| 65 |
+
let multiplier = 1;
|
| 66 |
+
if (tokenCalculation === 'thousand') {
|
| 67 |
+
multiplier = 1e-3;
|
| 68 |
+
} else if (tokenCalculation === 'unit') {
|
| 69 |
+
multiplier = 1e-6;
|
| 70 |
+
} else if (tokenCalculation === 'billion') {
|
| 71 |
+
multiplier = 1e3;
|
| 72 |
+
}
|
| 73 |
+
return price * tokens * multiplier;
|
| 74 |
};
|
| 75 |
|
| 76 |
+
|
| 77 |
const calculateBlendedPrice = (
|
| 78 |
inputPrice: number,
|
| 79 |
outputPrice: number,
|
|
|
|
| 87 |
};
|
| 88 |
|
| 89 |
|
| 90 |
+
|
| 91 |
+
|
| 92 |
const calculateComparison = (
|
| 93 |
modelPrice: number,
|
| 94 |
comparisonPrice: number
|
|
|
|
| 238 |
htmlFor="inputTokens"
|
| 239 |
className="block text-sm font-medium text-gray-700"
|
| 240 |
>
|
| 241 |
+
|
| 242 |
+
Input Tokens ({tokenCalculation})
|
| 243 |
</label>
|
| 244 |
<Input
|
| 245 |
id="inputTokens"
|
|
|
|
| 255 |
htmlFor="outputTokens"
|
| 256 |
className="block text-sm font-medium text-gray-700"
|
| 257 |
>
|
| 258 |
+
Output Tokens ({tokenCalculation})
|
| 259 |
</label>
|
| 260 |
<Input
|
| 261 |
id="outputTokens"
|
|
|
|
| 266 |
className="mt-1"
|
| 267 |
/>
|
| 268 |
</div>
|
| 269 |
+
<div className="flex-1">
|
| 270 |
+
<label
|
| 271 |
+
htmlFor="tokenCalculation"
|
| 272 |
+
className="block text-sm font-medium text-gray-700"
|
| 273 |
+
>
|
| 274 |
+
Token Calculation
|
| 275 |
+
</label>
|
| 276 |
+
<select
|
| 277 |
+
id="tokenCalculation"
|
| 278 |
+
value={tokenCalculation}
|
| 279 |
+
onChange={(e) => setTokenCalculation(e.target.value)}
|
| 280 |
+
className="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md"
|
| 281 |
+
>
|
| 282 |
+
<option value="billion">Billion Tokens</option>
|
| 283 |
+
<option value="million">Million Tokens</option>
|
| 284 |
+
<option value="thousand">Thousand Tokens</option>
|
| 285 |
+
<option value="unit">Unit Tokens</option>
|
| 286 |
+
</select>
|
| 287 |
+
|
| 288 |
+
</div>
|
| 289 |
+
|
| 290 |
</div>
|
| 291 |
|
| 292 |
+
|
| 293 |
<p className="italic text-sm text-muted-foreground mb-4">
|
| 294 |
Note: If you use Amazon Bedrock or Azure prices for Anthropic, Cohere
|
| 295 |
or OpenAI should be the same.
|
| 296 |
</p>
|
| 297 |
<p className="italic text-sm text-muted-foreground mb-4">
|
| 298 |
+
Blended Price reflects the average cost of input and output tokens, calculated using a fixed ratio (3:1), to give a unified rate per {tokenCalculation} tokens.
|
| 299 |
</p>
|
| 300 |
|
| 301 |
<Table>
|
|
|
|
| 329 |
|
| 330 |
<TableHead>
|
| 331 |
<button type="button" onClick={() => requestSort('inputPrice')}>
|
| 332 |
+
Input Price (million tokens)
|
| 333 |
{sortConfig?.key === 'inputPrice' ? (
|
| 334 |
sortConfig.direction === 'ascending' ? (
|
| 335 |
'▲'
|
|
|
|
| 341 |
</TableHead>
|
| 342 |
<TableHead>
|
| 343 |
<button type="button" onClick={() => requestSort('outputPrice')}>
|
| 344 |
+
Output Price (million tokens)
|
| 345 |
{sortConfig?.key === 'outputPrice' ? (
|
| 346 |
sortConfig.direction === 'ascending' ? (
|
| 347 |
'▲'
|
|
|
|
| 352 |
</button>
|
| 353 |
</TableHead>
|
| 354 |
|
| 355 |
+
|
| 356 |
+
<TableHead>Total Price (per {tokenCalculation} tokens){' '}</TableHead>
|
| 357 |
{comparisonModels.map((model) => (
|
| 358 |
<TableHead key={model} colSpan={2}>
|
| 359 |
Compared to {model}
|