Spaces:
Running
Running
Commit
•
67dfb22
1
Parent(s):
1ae14ee
fix filtered data
Browse files- src/App.tsx +17 -11
- src/lib/data.ts +5 -5
src/App.tsx
CHANGED
@@ -32,7 +32,7 @@ const App: React.FC = () => {
|
|
32 |
|
33 |
useEffect(() => {
|
34 |
setData(mockData)
|
35 |
-
setComparisonModels(['OpenAI:GPT-4o', 'Anthropic:Claude 3.5 (Sonnet)', 'Google
|
36 |
}, [])
|
37 |
|
38 |
const calculatePrice = (price: number, tokens: number): number => {
|
@@ -42,15 +42,15 @@ const App: React.FC = () => {
|
|
42 |
const calculateComparison = (modelPrice: number, comparisonPrice: number): string => {
|
43 |
return (((modelPrice - comparisonPrice) / comparisonPrice) * 100).toFixed(2)
|
44 |
}
|
45 |
-
const filteredData = data
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
const toggleProviderExpansion = (provider: string) => {
|
56 |
setExpandedProviders((prev) => (prev.includes(provider) ? prev.filter((p) => p !== provider) : [...prev, provider]))
|
@@ -169,7 +169,13 @@ const App: React.FC = () => {
|
|
169 |
options={
|
170 |
data
|
171 |
.flatMap((provider) => provider.models)
|
172 |
-
.map((model) => ({ label: model.name, value: model.name }))
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
174 |
defaultValue={selectedModels}
|
175 |
onValueChange={setSelectedModels}
|
|
|
32 |
|
33 |
useEffect(() => {
|
34 |
setData(mockData)
|
35 |
+
setComparisonModels(['OpenAI:GPT-4o', 'Anthropic:Claude 3.5 (Sonnet)', 'Google:Gemini 1.5 Pro'])
|
36 |
}, [])
|
37 |
|
38 |
const calculatePrice = (price: number, tokens: number): number => {
|
|
|
42 |
const calculateComparison = (modelPrice: number, comparisonPrice: number): string => {
|
43 |
return (((modelPrice - comparisonPrice) / comparisonPrice) * 100).toFixed(2)
|
44 |
}
|
45 |
+
const filteredData = data
|
46 |
+
.filter((provider) => selectedProviders.length === 0 || selectedProviders.includes(provider.provider))
|
47 |
+
.map((provider) => ({
|
48 |
+
...provider,
|
49 |
+
models: provider.models.filter((model) => selectedModels.length === 0 || selectedModels.includes(model.name)),
|
50 |
+
}))
|
51 |
+
.filter((provider) => provider.models.length > 0)
|
52 |
+
|
53 |
+
console.log(filteredData)
|
54 |
|
55 |
const toggleProviderExpansion = (provider: string) => {
|
56 |
setExpandedProviders((prev) => (prev.includes(provider) ? prev.filter((p) => p !== provider) : [...prev, provider]))
|
|
|
169 |
options={
|
170 |
data
|
171 |
.flatMap((provider) => provider.models)
|
172 |
+
.map((model) => ({ label: model.name, value: model.name }))
|
173 |
+
.reduce((acc, curr) => {
|
174 |
+
if (acc.findIndex((m) => m.label === curr.label) === -1) {
|
175 |
+
acc.push(curr)
|
176 |
+
}
|
177 |
+
return acc
|
178 |
+
}, []) || []
|
179 |
}
|
180 |
defaultValue={selectedModels}
|
181 |
onValueChange={setSelectedModels}
|
src/lib/data.ts
CHANGED
@@ -21,7 +21,7 @@ export const mockData: Provider[] = [
|
|
21 |
],
|
22 |
},
|
23 |
{
|
24 |
-
provider: 'Google
|
25 |
uri: 'https://ai.google.dev/pricing?hl=en',
|
26 |
models: [
|
27 |
{ name: 'Gemini 1.5 Pro', inputPrice: 3.5, outputPrice: 7.0 },
|
@@ -42,8 +42,8 @@ export const mockData: Provider[] = [
|
|
42 |
models: [
|
43 |
{ name: 'mistral-large-2402', inputPrice: 4.0, outputPrice: 12.0 },
|
44 |
{ name: 'codestral-2405', inputPrice: 1.0, outputPrice: 3.0 },
|
45 |
-
{ name: '
|
46 |
-
{ name: '
|
47 |
],
|
48 |
},
|
49 |
{
|
@@ -58,7 +58,7 @@ export const mockData: Provider[] = [
|
|
58 |
provider: 'Anyscale',
|
59 |
uri: 'https://www.anyscale.com/pricing-detail',
|
60 |
models: [
|
61 |
-
{ name: '
|
62 |
{ name: 'Llama 3 70b', inputPrice: 1.0, outputPrice: 1.0 },
|
63 |
],
|
64 |
},
|
@@ -67,7 +67,7 @@ export const mockData: Provider[] = [
|
|
67 |
provider: 'Together.AI',
|
68 |
uri: 'https://www.together.ai/pricing',
|
69 |
models: [
|
70 |
-
{ name: '
|
71 |
{ name: 'Llama 3 70b', inputPrice: 0.9, outputPrice: 0.9 },
|
72 |
],
|
73 |
},
|
|
|
21 |
],
|
22 |
},
|
23 |
{
|
24 |
+
provider: 'Google',
|
25 |
uri: 'https://ai.google.dev/pricing?hl=en',
|
26 |
models: [
|
27 |
{ name: 'Gemini 1.5 Pro', inputPrice: 3.5, outputPrice: 7.0 },
|
|
|
42 |
models: [
|
43 |
{ name: 'mistral-large-2402', inputPrice: 4.0, outputPrice: 12.0 },
|
44 |
{ name: 'codestral-2405', inputPrice: 1.0, outputPrice: 3.0 },
|
45 |
+
{ name: 'Mixtral 8x22B', inputPrice: 2.0, outputPrice: 6.0 },
|
46 |
+
{ name: 'Mixtral 8x7B', inputPrice: 0.7, outputPrice: 0.7 },
|
47 |
],
|
48 |
},
|
49 |
{
|
|
|
58 |
provider: 'Anyscale',
|
59 |
uri: 'https://www.anyscale.com/pricing-detail',
|
60 |
models: [
|
61 |
+
{ name: 'Mixtral 8x7B', inputPrice: 0.5, outputPrice: 0.5 },
|
62 |
{ name: 'Llama 3 70b', inputPrice: 1.0, outputPrice: 1.0 },
|
63 |
],
|
64 |
},
|
|
|
67 |
provider: 'Together.AI',
|
68 |
uri: 'https://www.together.ai/pricing',
|
69 |
models: [
|
70 |
+
{ name: 'Mixtral 8x7B', inputPrice: 0.6, outputPrice: 0.6 },
|
71 |
{ name: 'Llama 3 70b', inputPrice: 0.9, outputPrice: 0.9 },
|
72 |
],
|
73 |
},
|