Commit
·
83de502
1
Parent(s):
fd6e72e
- src/App.tsx +244 -140
- src/lib/data.ts +17 -17
src/App.tsx
CHANGED
|
@@ -1,13 +1,29 @@
|
|
| 1 |
-
import React, { useState, useEffect } from 'react'
|
| 2 |
-
import {
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
import {
|
| 9 |
-
import {
|
| 10 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
interface FlattenedModel extends Model {
|
| 13 |
provider: string;
|
|
@@ -15,105 +31,111 @@ interface FlattenedModel extends Model {
|
|
| 15 |
}
|
| 16 |
|
| 17 |
export interface Model {
|
| 18 |
-
name: string
|
| 19 |
-
inputPrice: number
|
| 20 |
-
outputPrice: number
|
| 21 |
}
|
| 22 |
|
| 23 |
export interface Provider {
|
| 24 |
-
provider: string
|
| 25 |
-
uri: string
|
| 26 |
-
models: Model[]
|
| 27 |
}
|
| 28 |
|
| 29 |
const App: React.FC = () => {
|
| 30 |
-
const [data, setData] = useState<Provider[]>([])
|
| 31 |
-
const [comparisonModels, setComparisonModels] = useState<string[]>([])
|
| 32 |
-
const [inputTokens, setInputTokens] = useState<number>(1)
|
| 33 |
-
const [outputTokens, setOutputTokens] = useState<number>(1)
|
| 34 |
-
const [selectedProviders, setSelectedProviders] = useState<string[]>([])
|
| 35 |
-
const [selectedModels, setSelectedModels] = useState<string[]>([])
|
| 36 |
-
const [expandedProviders, setExpandedProviders] = useState<string[]>([])
|
| 37 |
-
const [sortConfig, setSortConfig] = useState<{
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
useEffect(() => {
|
| 40 |
-
setData(mockData)
|
| 41 |
-
|
| 42 |
-
}, [])
|
| 43 |
|
| 44 |
const calculatePrice = (price: number, tokens: number): number => {
|
| 45 |
-
return price * tokens
|
| 46 |
-
}
|
| 47 |
|
| 48 |
-
const calculateComparison = (
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
const flattenData = (data: Provider[]) => {
|
| 53 |
-
return data.flatMap(provider =>
|
| 54 |
-
provider.models.map(model => ({
|
| 55 |
provider: provider.provider,
|
| 56 |
uri: provider.uri,
|
| 57 |
-
...model
|
| 58 |
}))
|
| 59 |
);
|
| 60 |
-
}
|
| 61 |
|
| 62 |
const filteredData = data
|
| 63 |
-
.filter(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
.map((provider) => ({
|
| 65 |
...provider,
|
| 66 |
-
models: provider.models.filter(
|
|
|
|
|
|
|
|
|
|
| 67 |
}))
|
| 68 |
-
.filter((provider) => provider.models.length > 0)
|
| 69 |
|
| 70 |
const sortedFlattenedData = React.useMemo(() => {
|
| 71 |
let sortableData: FlattenedModel[] = flattenData(filteredData);
|
| 72 |
if (sortConfig !== null) {
|
| 73 |
sortableData.sort((a, b) => {
|
| 74 |
-
const
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
}
|
| 81 |
-
return 0;
|
| 82 |
});
|
| 83 |
}
|
| 84 |
return sortableData;
|
| 85 |
}, [filteredData, sortConfig]);
|
| 86 |
|
| 87 |
-
|
| 88 |
-
const reassembleData = (sortedFlattenedData: FlattenedModel[]): Provider[] => {
|
| 89 |
-
const reassembledData = sortedFlattenedData.reduce((acc, item) => {
|
| 90 |
-
const providerIndex = acc.findIndex(provider => provider.provider === item.provider);
|
| 91 |
-
if (providerIndex === -1) {
|
| 92 |
-
acc.push({
|
| 93 |
-
provider: item.provider,
|
| 94 |
-
uri: item.uri,
|
| 95 |
-
models: [{ name: item.name, inputPrice: item.inputPrice, outputPrice: item.outputPrice }]
|
| 96 |
-
});
|
| 97 |
-
} else {
|
| 98 |
-
acc[providerIndex].models.push({ name: item.name, inputPrice: item.inputPrice, outputPrice: item.outputPrice });
|
| 99 |
-
}
|
| 100 |
-
return acc;
|
| 101 |
-
}, [] as Provider[]);
|
| 102 |
-
return reassembledData;
|
| 103 |
-
};
|
| 104 |
-
|
| 105 |
-
const sortedData = reassembleData(sortedFlattenedData);
|
| 106 |
-
|
| 107 |
-
const requestSort = (key: string) => {
|
| 108 |
let direction = 'ascending';
|
| 109 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
direction = 'descending';
|
| 111 |
}
|
| 112 |
setSortConfig({ key, direction });
|
| 113 |
};
|
| 114 |
|
| 115 |
const toggleProviderExpansion = (provider: string) => {
|
| 116 |
-
setExpandedProviders(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
};
|
| 118 |
|
| 119 |
return (
|
|
@@ -143,17 +165,27 @@ const App: React.FC = () => {
|
|
| 143 |
</CollapsibleTrigger>
|
| 144 |
<CollapsibleContent className="mt-2">
|
| 145 |
{provider.models.map((model) => (
|
| 146 |
-
<div
|
|
|
|
|
|
|
|
|
|
| 147 |
<Checkbox
|
| 148 |
id={`${provider.provider}:${model.name}`}
|
| 149 |
-
checked={comparisonModels.includes(
|
|
|
|
|
|
|
| 150 |
onCheckedChange={(checked) => {
|
| 151 |
if (checked) {
|
| 152 |
-
setComparisonModels((prev) => [
|
|
|
|
|
|
|
|
|
|
| 153 |
} else {
|
| 154 |
setComparisonModels((prev) =>
|
| 155 |
-
prev.filter(
|
| 156 |
-
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
}}
|
| 159 |
/>
|
|
@@ -173,7 +205,10 @@ const App: React.FC = () => {
|
|
| 173 |
|
| 174 |
<div className="flex gap-4 mb-4">
|
| 175 |
<div className="flex-1">
|
| 176 |
-
<label
|
|
|
|
|
|
|
|
|
|
| 177 |
Input Tokens (millions)
|
| 178 |
</label>
|
| 179 |
<Input
|
|
@@ -186,7 +221,10 @@ const App: React.FC = () => {
|
|
| 186 |
/>
|
| 187 |
</div>
|
| 188 |
<div className="flex-1">
|
| 189 |
-
<label
|
|
|
|
|
|
|
|
|
|
| 190 |
Output Tokens (millions)
|
| 191 |
</label>
|
| 192 |
<Input
|
|
@@ -201,7 +239,8 @@ const App: React.FC = () => {
|
|
| 201 |
</div>
|
| 202 |
|
| 203 |
<p className="italic text-sm text-muted-foreground mb-4">
|
| 204 |
-
Note: If you use Amazon Bedrock or Azure prices for Anthropic, Cohere
|
|
|
|
| 205 |
</p>
|
| 206 |
|
| 207 |
<Table>
|
|
@@ -209,22 +248,50 @@ const App: React.FC = () => {
|
|
| 209 |
<TableRow>
|
| 210 |
<TableHead>
|
| 211 |
<button type="button" onClick={() => requestSort('provider')}>
|
| 212 |
-
Provider
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
</button>
|
| 214 |
</TableHead>
|
| 215 |
<TableHead>
|
| 216 |
<button type="button" onClick={() => requestSort('name')}>
|
| 217 |
-
Model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
</button>
|
| 219 |
</TableHead>
|
| 220 |
<TableHead>
|
| 221 |
<button type="button" onClick={() => requestSort('inputPrice')}>
|
| 222 |
-
Input Price (per 1M tokens)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
</button>
|
| 224 |
</TableHead>
|
| 225 |
<TableHead>
|
| 226 |
<button type="button" onClick={() => requestSort('outputPrice')}>
|
| 227 |
-
Output Price (per 1M tokens)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
</button>
|
| 229 |
</TableHead>
|
| 230 |
<TableHead>Total Price</TableHead>
|
|
@@ -237,7 +304,12 @@ const App: React.FC = () => {
|
|
| 237 |
<TableRow>
|
| 238 |
<TableHead>
|
| 239 |
<MultiSelect
|
| 240 |
-
options={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
onValueChange={setSelectedProviders}
|
| 242 |
defaultValue={selectedProviders}
|
| 243 |
/>
|
|
@@ -248,12 +320,18 @@ const App: React.FC = () => {
|
|
| 248 |
data
|
| 249 |
.flatMap((provider) => provider.models)
|
| 250 |
.map((model) => ({ label: model.name, value: model.name }))
|
| 251 |
-
.reduce(
|
| 252 |
-
|
| 253 |
-
acc
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
}
|
| 258 |
defaultValue={selectedModels}
|
| 259 |
onValueChange={setSelectedModels}
|
|
@@ -269,66 +347,92 @@ const App: React.FC = () => {
|
|
| 269 |
</TableRow>
|
| 270 |
</TableHeader>
|
| 271 |
<TableBody>
|
| 272 |
-
{
|
| 273 |
-
provider.
|
| 274 |
-
<
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
? 'bg-green-100'
|
| 300 |
-
: parseFloat(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
? 'bg-red-100'
|
| 302 |
: ''
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
? 'bg-green-100'
|
| 313 |
-
: parseFloat(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
? 'bg-red-100'
|
| 315 |
: ''
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
|
|
|
|
|
|
| 327 |
</TableBody>
|
| 328 |
</Table>
|
| 329 |
</CardContent>
|
| 330 |
</Card>
|
| 331 |
-
)
|
| 332 |
-
}
|
| 333 |
|
| 334 |
-
export default App
|
|
|
|
| 1 |
+
import React, { useState, useEffect } from 'react';
|
| 2 |
+
import {
|
| 3 |
+
Card,
|
| 4 |
+
CardContent,
|
| 5 |
+
CardHeader,
|
| 6 |
+
CardTitle,
|
| 7 |
+
} from '@/components/ui/card';
|
| 8 |
+
import { Checkbox } from '@/components/ui/checkbox';
|
| 9 |
+
import { Input } from '@/components/ui/input';
|
| 10 |
+
import {
|
| 11 |
+
Table,
|
| 12 |
+
TableBody,
|
| 13 |
+
TableCell,
|
| 14 |
+
TableHead,
|
| 15 |
+
TableHeader,
|
| 16 |
+
TableRow,
|
| 17 |
+
} from '@/components/ui/table';
|
| 18 |
+
import { MultiSelect } from '@/components/ui/multi-select';
|
| 19 |
+
import {
|
| 20 |
+
Collapsible,
|
| 21 |
+
CollapsibleContent,
|
| 22 |
+
CollapsibleTrigger,
|
| 23 |
+
} from '@/components/ui/collapsible';
|
| 24 |
+
import { Button } from '@/components/ui/button';
|
| 25 |
+
import { ChevronDown, ChevronRight } from 'lucide-react';
|
| 26 |
+
import { mockData } from './lib/data'; // Assuming you have this file for mock data
|
| 27 |
|
| 28 |
interface FlattenedModel extends Model {
|
| 29 |
provider: string;
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
export interface Model {
|
| 34 |
+
name: string;
|
| 35 |
+
inputPrice: number;
|
| 36 |
+
outputPrice: number;
|
| 37 |
}
|
| 38 |
|
| 39 |
export interface Provider {
|
| 40 |
+
provider: string;
|
| 41 |
+
uri: string;
|
| 42 |
+
models: Model[];
|
| 43 |
}
|
| 44 |
|
| 45 |
const App: React.FC = () => {
|
| 46 |
+
const [data, setData] = useState<Provider[]>([]);
|
| 47 |
+
const [comparisonModels, setComparisonModels] = useState<string[]>([]);
|
| 48 |
+
const [inputTokens, setInputTokens] = useState<number>(1);
|
| 49 |
+
const [outputTokens, setOutputTokens] = useState<number>(1);
|
| 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;
|
| 56 |
+
} | null>(null);
|
| 57 |
|
| 58 |
useEffect(() => {
|
| 59 |
+
setData(mockData);
|
| 60 |
+
}, []);
|
|
|
|
| 61 |
|
| 62 |
const calculatePrice = (price: number, tokens: number): number => {
|
| 63 |
+
return price * tokens;
|
| 64 |
+
};
|
| 65 |
|
| 66 |
+
const calculateComparison = (
|
| 67 |
+
modelPrice: number,
|
| 68 |
+
comparisonPrice: number
|
| 69 |
+
): string => {
|
| 70 |
+
return (((modelPrice - comparisonPrice) / comparisonPrice) * 100).toFixed(2);
|
| 71 |
+
};
|
| 72 |
|
| 73 |
const flattenData = (data: Provider[]) => {
|
| 74 |
+
return data.flatMap((provider) =>
|
| 75 |
+
provider.models.map((model) => ({
|
| 76 |
provider: provider.provider,
|
| 77 |
uri: provider.uri,
|
| 78 |
+
...model,
|
| 79 |
}))
|
| 80 |
);
|
| 81 |
+
};
|
| 82 |
|
| 83 |
const filteredData = data
|
| 84 |
+
.filter(
|
| 85 |
+
(provider) =>
|
| 86 |
+
selectedProviders.length === 0 ||
|
| 87 |
+
selectedProviders.includes(provider.provider)
|
| 88 |
+
)
|
| 89 |
.map((provider) => ({
|
| 90 |
...provider,
|
| 91 |
+
models: provider.models.filter(
|
| 92 |
+
(model) =>
|
| 93 |
+
selectedModels.length === 0 || selectedModels.includes(model.name)
|
| 94 |
+
),
|
| 95 |
}))
|
| 96 |
+
.filter((provider) => provider.models.length > 0);
|
| 97 |
|
| 98 |
const sortedFlattenedData = React.useMemo(() => {
|
| 99 |
let sortableData: FlattenedModel[] = flattenData(filteredData);
|
| 100 |
if (sortConfig !== null) {
|
| 101 |
sortableData.sort((a, b) => {
|
| 102 |
+
const aValue = a[sortConfig.key];
|
| 103 |
+
const bValue = b[sortConfig.key];
|
| 104 |
+
|
| 105 |
+
if (typeof aValue === 'string' && typeof bValue === 'string') {
|
| 106 |
+
return sortConfig.direction === 'ascending'
|
| 107 |
+
? aValue.localeCompare(bValue)
|
| 108 |
+
: bValue.localeCompare(aValue);
|
| 109 |
+
} else if (typeof aValue === 'number' && typeof bValue === 'number') {
|
| 110 |
+
return sortConfig.direction === 'ascending'
|
| 111 |
+
? aValue - bValue
|
| 112 |
+
: bValue - aValue;
|
| 113 |
+
} else {
|
| 114 |
+
return 0;
|
| 115 |
}
|
|
|
|
| 116 |
});
|
| 117 |
}
|
| 118 |
return sortableData;
|
| 119 |
}, [filteredData, sortConfig]);
|
| 120 |
|
| 121 |
+
const requestSort = (key: keyof FlattenedModel) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
let direction = 'ascending';
|
| 123 |
+
if (
|
| 124 |
+
sortConfig &&
|
| 125 |
+
sortConfig.key === key &&
|
| 126 |
+
sortConfig.direction === 'ascending'
|
| 127 |
+
) {
|
| 128 |
direction = 'descending';
|
| 129 |
}
|
| 130 |
setSortConfig({ key, direction });
|
| 131 |
};
|
| 132 |
|
| 133 |
const toggleProviderExpansion = (provider: string) => {
|
| 134 |
+
setExpandedProviders((prev) =>
|
| 135 |
+
prev.includes(provider)
|
| 136 |
+
? prev.filter((p) => p !== provider)
|
| 137 |
+
: [...prev, provider]
|
| 138 |
+
);
|
| 139 |
};
|
| 140 |
|
| 141 |
return (
|
|
|
|
| 165 |
</CollapsibleTrigger>
|
| 166 |
<CollapsibleContent className="mt-2">
|
| 167 |
{provider.models.map((model) => (
|
| 168 |
+
<div
|
| 169 |
+
key={`${provider.provider}:${model.name}`}
|
| 170 |
+
className="flex items-center space-x-2 mb-1"
|
| 171 |
+
>
|
| 172 |
<Checkbox
|
| 173 |
id={`${provider.provider}:${model.name}`}
|
| 174 |
+
checked={comparisonModels.includes(
|
| 175 |
+
`${provider.provider}:${model.name}`
|
| 176 |
+
)}
|
| 177 |
onCheckedChange={(checked) => {
|
| 178 |
if (checked) {
|
| 179 |
+
setComparisonModels((prev) => [
|
| 180 |
+
...prev,
|
| 181 |
+
`${provider.provider}:${model.name}`,
|
| 182 |
+
]);
|
| 183 |
} else {
|
| 184 |
setComparisonModels((prev) =>
|
| 185 |
+
prev.filter(
|
| 186 |
+
(m) => m !== `${provider.provider}:${model.name}`
|
| 187 |
+
)
|
| 188 |
+
);
|
| 189 |
}
|
| 190 |
}}
|
| 191 |
/>
|
|
|
|
| 205 |
|
| 206 |
<div className="flex gap-4 mb-4">
|
| 207 |
<div className="flex-1">
|
| 208 |
+
<label
|
| 209 |
+
htmlFor="inputTokens"
|
| 210 |
+
className="block text-sm font-medium text-gray-700"
|
| 211 |
+
>
|
| 212 |
Input Tokens (millions)
|
| 213 |
</label>
|
| 214 |
<Input
|
|
|
|
| 221 |
/>
|
| 222 |
</div>
|
| 223 |
<div className="flex-1">
|
| 224 |
+
<label
|
| 225 |
+
htmlFor="outputTokens"
|
| 226 |
+
className="block text-sm font-medium text-gray-700"
|
| 227 |
+
>
|
| 228 |
Output Tokens (millions)
|
| 229 |
</label>
|
| 230 |
<Input
|
|
|
|
| 239 |
</div>
|
| 240 |
|
| 241 |
<p className="italic text-sm text-muted-foreground mb-4">
|
| 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>
|
|
|
|
| 248 |
<TableRow>
|
| 249 |
<TableHead>
|
| 250 |
<button type="button" onClick={() => requestSort('provider')}>
|
| 251 |
+
Provider{' '}
|
| 252 |
+
{sortConfig?.key === 'provider' ? (
|
| 253 |
+
sortConfig.direction === 'ascending' ? (
|
| 254 |
+
'▲'
|
| 255 |
+
) : (
|
| 256 |
+
'▼'
|
| 257 |
+
)
|
| 258 |
+
) : null}
|
| 259 |
</button>
|
| 260 |
</TableHead>
|
| 261 |
<TableHead>
|
| 262 |
<button type="button" onClick={() => requestSort('name')}>
|
| 263 |
+
Model{' '}
|
| 264 |
+
{sortConfig?.key === 'name' ? (
|
| 265 |
+
sortConfig.direction === 'ascending' ? (
|
| 266 |
+
'▲'
|
| 267 |
+
) : (
|
| 268 |
+
'▼'
|
| 269 |
+
)
|
| 270 |
+
) : null}
|
| 271 |
</button>
|
| 272 |
</TableHead>
|
| 273 |
<TableHead>
|
| 274 |
<button type="button" onClick={() => requestSort('inputPrice')}>
|
| 275 |
+
Input Price (per 1M tokens){' '}
|
| 276 |
+
{sortConfig?.key === 'inputPrice' ? (
|
| 277 |
+
sortConfig.direction === 'ascending' ? (
|
| 278 |
+
'▲'
|
| 279 |
+
) : (
|
| 280 |
+
'▼'
|
| 281 |
+
)
|
| 282 |
+
) : null}
|
| 283 |
</button>
|
| 284 |
</TableHead>
|
| 285 |
<TableHead>
|
| 286 |
<button type="button" onClick={() => requestSort('outputPrice')}>
|
| 287 |
+
Output Price (per 1M tokens){' '}
|
| 288 |
+
{sortConfig?.key === 'outputPrice' ? (
|
| 289 |
+
sortConfig.direction === 'ascending' ? (
|
| 290 |
+
'▲'
|
| 291 |
+
) : (
|
| 292 |
+
'▼'
|
| 293 |
+
)
|
| 294 |
+
) : null}
|
| 295 |
</button>
|
| 296 |
</TableHead>
|
| 297 |
<TableHead>Total Price</TableHead>
|
|
|
|
| 304 |
<TableRow>
|
| 305 |
<TableHead>
|
| 306 |
<MultiSelect
|
| 307 |
+
options={
|
| 308 |
+
data.map((provider) => ({
|
| 309 |
+
label: provider.provider,
|
| 310 |
+
value: provider.provider,
|
| 311 |
+
})) || []
|
| 312 |
+
}
|
| 313 |
onValueChange={setSelectedProviders}
|
| 314 |
defaultValue={selectedProviders}
|
| 315 |
/>
|
|
|
|
| 320 |
data
|
| 321 |
.flatMap((provider) => provider.models)
|
| 322 |
.map((model) => ({ label: model.name, value: model.name }))
|
| 323 |
+
.reduce(
|
| 324 |
+
(
|
| 325 |
+
acc: { label: string; value: string }[],
|
| 326 |
+
curr: { label: string; value: string }
|
| 327 |
+
) => {
|
| 328 |
+
if (!acc.find((m) => m.value === curr.value)) {
|
| 329 |
+
acc.push(curr);
|
| 330 |
+
}
|
| 331 |
+
return acc;
|
| 332 |
+
},
|
| 333 |
+
[]
|
| 334 |
+
) || []
|
| 335 |
}
|
| 336 |
defaultValue={selectedModels}
|
| 337 |
onValueChange={setSelectedModels}
|
|
|
|
| 347 |
</TableRow>
|
| 348 |
</TableHeader>
|
| 349 |
<TableBody>
|
| 350 |
+
{sortedFlattenedData.map((item) => (
|
| 351 |
+
<TableRow key={`${item.provider}-${item.name}`}>
|
| 352 |
+
<TableCell>
|
| 353 |
+
{' '}
|
| 354 |
+
<a href={item.uri} className="underline">
|
| 355 |
+
{item.provider}
|
| 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 |
+
{(
|
| 364 |
+
calculatePrice(item.inputPrice, inputTokens) +
|
| 365 |
+
calculatePrice(item.outputPrice, outputTokens)
|
| 366 |
+
).toFixed(2)}
|
| 367 |
+
</TableCell>
|
| 368 |
+
{comparisonModels.flatMap((comparisonModel) => {
|
| 369 |
+
const [comparisonProvider, comparisonModelName] =
|
| 370 |
+
comparisonModel.split(':');
|
| 371 |
+
const comparisonModelData = data
|
| 372 |
+
.find((p) => p.provider === comparisonProvider)
|
| 373 |
+
?.models.find((m) => m.name === comparisonModelName)!;
|
| 374 |
+
return [
|
| 375 |
+
<TableCell
|
| 376 |
+
key={`${comparisonModel}-input`}
|
| 377 |
+
className={`${parseFloat(
|
| 378 |
+
calculateComparison(
|
| 379 |
+
item.inputPrice,
|
| 380 |
+
comparisonModelData.inputPrice
|
| 381 |
+
)
|
| 382 |
+
) < 0
|
| 383 |
? 'bg-green-100'
|
| 384 |
+
: parseFloat(
|
| 385 |
+
calculateComparison(
|
| 386 |
+
item.inputPrice,
|
| 387 |
+
comparisonModelData.inputPrice
|
| 388 |
+
)
|
| 389 |
+
) > 0
|
| 390 |
? 'bg-red-100'
|
| 391 |
: ''
|
| 392 |
+
}`}
|
| 393 |
+
>
|
| 394 |
+
{`${item.provider}:${item.name}` === comparisonModel
|
| 395 |
+
? '0.00%'
|
| 396 |
+
: `${calculateComparison(
|
| 397 |
+
item.inputPrice,
|
| 398 |
+
comparisonModelData.inputPrice
|
| 399 |
+
)}%`}
|
| 400 |
+
</TableCell>,
|
| 401 |
+
<TableCell
|
| 402 |
+
key={`${comparisonModel}-output`}
|
| 403 |
+
className={`${parseFloat(
|
| 404 |
+
calculateComparison(
|
| 405 |
+
item.outputPrice,
|
| 406 |
+
comparisonModelData.outputPrice
|
| 407 |
+
)
|
| 408 |
+
) < 0
|
| 409 |
? 'bg-green-100'
|
| 410 |
+
: parseFloat(
|
| 411 |
+
calculateComparison(
|
| 412 |
+
item.outputPrice,
|
| 413 |
+
comparisonModelData.outputPrice
|
| 414 |
+
)
|
| 415 |
+
) > 0
|
| 416 |
? 'bg-red-100'
|
| 417 |
: ''
|
| 418 |
+
}`}
|
| 419 |
+
>
|
| 420 |
+
{`${item.provider}:${item.name}` === comparisonModel
|
| 421 |
+
? '0.00%'
|
| 422 |
+
: `${calculateComparison(
|
| 423 |
+
item.outputPrice,
|
| 424 |
+
comparisonModelData.outputPrice
|
| 425 |
+
)}%`}
|
| 426 |
+
</TableCell>,
|
| 427 |
+
];
|
| 428 |
+
})}
|
| 429 |
+
</TableRow>
|
| 430 |
+
))}
|
| 431 |
</TableBody>
|
| 432 |
</Table>
|
| 433 |
</CardContent>
|
| 434 |
</Card>
|
| 435 |
+
);
|
| 436 |
+
};
|
| 437 |
|
| 438 |
+
export default App;
|
src/lib/data.ts
CHANGED
|
@@ -43,12 +43,12 @@ export const mockData: Provider[] = [
|
|
| 43 |
provider: 'Mistral',
|
| 44 |
uri: 'https://docs.mistral.ai/platform/pricing',
|
| 45 |
models: [
|
| 46 |
-
{ name:
|
| 47 |
-
{ name:
|
| 48 |
-
{ name:
|
| 49 |
-
{ name:
|
| 50 |
-
{ name:
|
| 51 |
-
{ name:
|
| 52 |
],
|
| 53 |
},
|
| 54 |
{
|
|
@@ -88,12 +88,12 @@ export const mockData: Provider[] = [
|
|
| 88 |
{ name: 'Meta Llama 3 8B Reference', inputPrice: 0.20, outputPrice: 0.20 },
|
| 89 |
{ name: 'Gemma-2 Instruct (27B)', inputPrice: 0.80, outputPrice: 0.80 },
|
| 90 |
{ name: 'Gemma-2 Instruct (9B)', inputPrice: 0.30, outputPrice: 0.30 },
|
| 91 |
-
{ name:
|
| 92 |
-
{ name:
|
| 93 |
-
{ name:
|
| 94 |
{ name: 'Qwen 2 Instruct (72B)', inputPrice: 0.90, outputPrice: 0.90 },
|
| 95 |
{ name: 'Snowflake Arctic Instruct', inputPrice: 2.40, outputPrice: 2.40 },
|
| 96 |
-
{ name:
|
| 97 |
],
|
| 98 |
},
|
| 99 |
{
|
|
@@ -108,13 +108,13 @@ export const mockData: Provider[] = [
|
|
| 108 |
provider: "Groq",
|
| 109 |
uri: "https://wow.groq.com/",
|
| 110 |
models: [
|
| 111 |
-
{ name:
|
| 112 |
-
{ name:
|
| 113 |
-
{ name:
|
| 114 |
-
{ name:
|
| 115 |
-
{ name:
|
| 116 |
-
{ name:
|
| 117 |
-
{ name:
|
| 118 |
]
|
| 119 |
},
|
| 120 |
{
|
|
|
|
| 43 |
provider: 'Mistral',
|
| 44 |
uri: 'https://docs.mistral.ai/platform/pricing',
|
| 45 |
models: [
|
| 46 |
+
{ name: 'Mistral Large 2402', inputPrice: 4.0, outputPrice: 12.0 },
|
| 47 |
+
{ name: 'Codestral 2405', inputPrice: 1.0, outputPrice: 3.0 },
|
| 48 |
+
{ name: 'Mixtral 8x22B', inputPrice: 2.0, outputPrice: 6.0 },
|
| 49 |
+
{ name: 'Mixtral 8x7B', inputPrice: 0.7, outputPrice: 0.7 },
|
| 50 |
+
{ name: 'Codestral Mamba', inputPrice: 0.25, outputPrice: 0.25 },
|
| 51 |
+
{ name: 'Mistral Nemo 2407', inputPrice: 0.3, outputPrice: 0.3 }
|
| 52 |
],
|
| 53 |
},
|
| 54 |
{
|
|
|
|
| 88 |
{ name: 'Meta Llama 3 8B Reference', inputPrice: 0.20, outputPrice: 0.20 },
|
| 89 |
{ name: 'Gemma-2 Instruct (27B)', inputPrice: 0.80, outputPrice: 0.80 },
|
| 90 |
{ name: 'Gemma-2 Instruct (9B)', inputPrice: 0.30, outputPrice: 0.30 },
|
| 91 |
+
{ name: 'Mixtral 8x22B', inputPrice: 1.20, outputPrice: 1.20 },
|
| 92 |
+
{ name: 'Mixtral 8x7B', inputPrice: 0.60, outputPrice: 0.60 },
|
| 93 |
+
{ name: 'Mistral 7B', inputPrice: 0.20, outputPrice: 0.20 },
|
| 94 |
{ name: 'Qwen 2 Instruct (72B)', inputPrice: 0.90, outputPrice: 0.90 },
|
| 95 |
{ name: 'Snowflake Arctic Instruct', inputPrice: 2.40, outputPrice: 2.40 },
|
| 96 |
+
{ name: 'DBRX', inputPrice: 1.20, outputPrice: 1.20 }
|
| 97 |
],
|
| 98 |
},
|
| 99 |
{
|
|
|
|
| 108 |
provider: "Groq",
|
| 109 |
uri: "https://wow.groq.com/",
|
| 110 |
models: [
|
| 111 |
+
{ name: 'Llama 3 8B 8K', inputPrice: 0.05, outputPrice: 0.08 },
|
| 112 |
+
{ name: 'Llama 3 70B 8K', inputPrice: 0.59, outputPrice: 0.79 },
|
| 113 |
+
{ name: 'Llama 3 8B 8192 Tool Use', inputPrice: 0.19, outputPrice: 0.19 },
|
| 114 |
+
{ name: 'Llama 3 70B 8192 Tool Use', inputPrice: 0.89, outputPrice: 0.89 },
|
| 115 |
+
{ name: 'Mixtral 8x7B 32k Instruct', inputPrice: 0.24, outputPrice: 0.24 },
|
| 116 |
+
{ name: 'Gemma 7B Instruct', inputPrice: 0.07, outputPrice: 0.07 },
|
| 117 |
+
{ name: 'Gemma 2 9B Instruct', inputPrice: 0.20, outputPrice: 0.20 }
|
| 118 |
]
|
| 119 |
},
|
| 120 |
{
|