Skip to content

Commit 14a4142

Browse files
authored
[Workers AI] Add pills back to model page (#16118)
1 parent 44ae159 commit 14a4142

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/components/WorkersAIModels.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ const entries = Object.entries(grouped).reverse();
5151
if (Date.now() > timestamp) {
5252
return { variant: "danger", text: "Deprecated" }
5353
}
54+
55+
return { variant: "danger", text: "Planned deprecation" };
5456
}
5557

5658
return [];

src/pages/workers-ai/models/[name].astro

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { GetStaticPaths } from "astro";
33
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
44
import { getCollection } from "astro:content";
5+
import { InlineBadge } from "~/components";
56
import Schemas from "~/components/models/Schemas.astro";
67
import Playground from "~/components/models/Playground.astro";
78
import TextGenerationResponses from "~/components/models/responses/TextGenerationResponses.astro";
@@ -51,6 +52,40 @@ const hasLora = Boolean(
5152
data.model.properties.find((x) => x.property_id === "lora"),
5253
);
5354
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+
5489
let CodeExamples;
5590
let Responses;
5691
@@ -116,6 +151,7 @@ if (data.model.name === "@cf/runwayml/stable-diffusion-v1-5-inpainting") {
116151
---
117152

118153
<StarlightPage frontmatter={{ title: name, description }}>
154+
{badges.map((badge) => <InlineBadge {...badge} /> )}
119155
<p>
120156
<strong>Model ID: </strong>
121157
<code>{data.model.name}</code>

0 commit comments

Comments
 (0)