|
2 | 2 | import type { GetStaticPaths } from "astro"; |
3 | 3 | import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro"; |
4 | 4 | import { getCollection } from "astro:content"; |
| 5 | +import { InlineBadge } from "~/components"; |
5 | 6 | import Schemas from "~/components/models/Schemas.astro"; |
6 | 7 | import Playground from "~/components/models/Playground.astro"; |
7 | 8 | import TextGenerationResponses from "~/components/models/responses/TextGenerationResponses.astro"; |
@@ -51,6 +52,40 @@ const hasLora = Boolean( |
51 | 52 | data.model.properties.find((x) => x.property_id === "lora"), |
52 | 53 | ); |
53 | 54 |
|
| 55 | +const badges = data.model.properties.flatMap(({ property_id, value }) => { |
| 56 | + if (property_id === "beta" && value === "true") { |
| 57 | + return { |
| 58 | + preset: "beta", |
| 59 | + }; |
| 60 | + } |
| 61 | +
|
| 62 | + if (property_id === "lora" && value === "true") { |
| 63 | + return { |
| 64 | + variant: "tip", |
| 65 | + text: "LoRA", |
| 66 | + }; |
| 67 | + } |
| 68 | +
|
| 69 | + if (property_id === "function_calling" && value === "true") { |
| 70 | + return { |
| 71 | + variant: "note", |
| 72 | + text: "Function calling", |
| 73 | + }; |
| 74 | + } |
| 75 | +
|
| 76 | + if (property_id === "planned_deprecation_date") { |
| 77 | + const timestamp = Math.floor(new Date(value).getTime() / 1000); |
| 78 | +
|
| 79 | + if (Date.now() > timestamp) { |
| 80 | + return { variant: "danger", text: "Deprecated" }; |
| 81 | + } |
| 82 | +
|
| 83 | + return { variant: "danger", text: "Planned deprecation" }; |
| 84 | + } |
| 85 | +
|
| 86 | + return []; |
| 87 | +}); |
| 88 | +
|
54 | 89 | let CodeExamples; |
55 | 90 | let Responses; |
56 | 91 |
|
@@ -116,6 +151,7 @@ if (data.model.name === "@cf/runwayml/stable-diffusion-v1-5-inpainting") { |
116 | 151 | --- |
117 | 152 |
|
118 | 153 | <StarlightPage frontmatter={{ title: name, description }}> |
| 154 | + {badges.map((badge) => <InlineBadge {...badge} /> )} |
119 | 155 | <p> |
120 | 156 | <strong>Model ID: </strong> |
121 | 157 | <code>{data.model.name}</code> |
|
0 commit comments