Spaces:
Build error
Build error
Add ability to define custom model/dataset URLs (#347)
Browse files* Add ability to define custom model/dataset URLs
* lint
---------
Co-authored-by: Nathan Sarrazin <[email protected]>
src/lib/components/ModelCardMetadata.svelte
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
import CarbonArrowUpRight from "~icons/carbon/arrow-up-right";
|
| 4 |
import type { Model } from "$lib/types/Model";
|
| 5 |
|
| 6 |
-
export let model: Pick<Model, "name" | "datasetName" | "websiteUrl">;
|
| 7 |
|
| 8 |
export let variant: "light" | "dark" = "light";
|
| 9 |
</script>
|
|
@@ -15,7 +15,7 @@
|
|
| 15 |
: 'text-gray-800 dark:bg-gray-100 dark:text-gray-600'}"
|
| 16 |
>
|
| 17 |
<a
|
| 18 |
-
href="https://huggingface.co/
|
| 19 |
target="_blank"
|
| 20 |
rel="noreferrer"
|
| 21 |
class="flex items-center hover:underline"
|
|
@@ -23,9 +23,9 @@
|
|
| 23 |
Model
|
| 24 |
<div class="max-sm:hidden"> page</div></a
|
| 25 |
>
|
| 26 |
-
{#if model.datasetName}
|
| 27 |
<a
|
| 28 |
-
href="https://huggingface.co/datasets/
|
| 29 |
target="_blank"
|
| 30 |
rel="noreferrer"
|
| 31 |
class="flex items-center hover:underline"
|
|
|
|
| 3 |
import CarbonArrowUpRight from "~icons/carbon/arrow-up-right";
|
| 4 |
import type { Model } from "$lib/types/Model";
|
| 5 |
|
| 6 |
+
export let model: Pick<Model, "name" | "datasetName" | "websiteUrl" | "modelUrl" | "datasetUrl">;
|
| 7 |
|
| 8 |
export let variant: "light" | "dark" = "light";
|
| 9 |
</script>
|
|
|
|
| 15 |
: 'text-gray-800 dark:bg-gray-100 dark:text-gray-600'}"
|
| 16 |
>
|
| 17 |
<a
|
| 18 |
+
href={model.modelUrl || "https://huggingface.co/" + model.name}
|
| 19 |
target="_blank"
|
| 20 |
rel="noreferrer"
|
| 21 |
class="flex items-center hover:underline"
|
|
|
|
| 23 |
Model
|
| 24 |
<div class="max-sm:hidden"> page</div></a
|
| 25 |
>
|
| 26 |
+
{#if model.datasetName || model.datasetUrl}
|
| 27 |
<a
|
| 28 |
+
href={model.datasetUrl || "https://huggingface.co/datasets/" + model.datasetName}
|
| 29 |
target="_blank"
|
| 30 |
rel="noreferrer"
|
| 31 |
class="flex items-center hover:underline"
|
src/lib/server/models.ts
CHANGED
|
@@ -11,7 +11,9 @@ const modelsRaw = z
|
|
| 11 |
displayName: z.string().min(1).optional(),
|
| 12 |
description: z.string().min(1).optional(),
|
| 13 |
websiteUrl: z.string().url().optional(),
|
|
|
|
| 14 |
datasetName: z.string().min(1).optional(),
|
|
|
|
| 15 |
userMessageToken: z.string().min(1),
|
| 16 |
assistantMessageToken: z.string().min(1),
|
| 17 |
messageEndToken: z.string().min(1).optional(),
|
|
|
|
| 11 |
displayName: z.string().min(1).optional(),
|
| 12 |
description: z.string().min(1).optional(),
|
| 13 |
websiteUrl: z.string().url().optional(),
|
| 14 |
+
modelUrl: z.string().url().optional(),
|
| 15 |
datasetName: z.string().min(1).optional(),
|
| 16 |
+
datasetUrl: z.string().url().optional(),
|
| 17 |
userMessageToken: z.string().min(1),
|
| 18 |
assistantMessageToken: z.string().min(1),
|
| 19 |
messageEndToken: z.string().min(1).optional(),
|
src/lib/types/Model.ts
CHANGED
|
@@ -10,4 +10,6 @@ export type Model = Pick<
|
|
| 10 |
| "promptExamples"
|
| 11 |
| "parameters"
|
| 12 |
| "description"
|
|
|
|
|
|
|
| 13 |
>;
|
|
|
|
| 10 |
| "promptExamples"
|
| 11 |
| "parameters"
|
| 12 |
| "description"
|
| 13 |
+
| "modelUrl"
|
| 14 |
+
| "datasetUrl"
|
| 15 |
>;
|
src/routes/+layout.server.ts
CHANGED
|
@@ -67,7 +67,9 @@ export const load: LayoutServerLoad = async ({ locals, depends, url }) => {
|
|
| 67 |
id: model.id,
|
| 68 |
name: model.name,
|
| 69 |
websiteUrl: model.websiteUrl,
|
|
|
|
| 70 |
datasetName: model.datasetName,
|
|
|
|
| 71 |
displayName: model.displayName,
|
| 72 |
description: model.description,
|
| 73 |
promptExamples: model.promptExamples,
|
|
|
|
| 67 |
id: model.id,
|
| 68 |
name: model.name,
|
| 69 |
websiteUrl: model.websiteUrl,
|
| 70 |
+
modelUrl: model.modelUrl,
|
| 71 |
datasetName: model.datasetName,
|
| 72 |
+
datasetUrl: model.datasetUrl,
|
| 73 |
displayName: model.displayName,
|
| 74 |
description: model.description,
|
| 75 |
promptExamples: model.promptExamples,
|