Skip to content

Commit

Permalink
[Workers AI] Add pills back to model page (#16118)
Browse files Browse the repository at this point in the history
  • Loading branch information
KianNH authored Aug 14, 2024
1 parent 44ae159 commit 14a4142
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/WorkersAIModels.astro
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const entries = Object.entries(grouped).reverse();
if (Date.now() > timestamp) {
return { variant: "danger", text: "Deprecated" }
}

return { variant: "danger", text: "Planned deprecation" };
}

return [];
Expand Down
36 changes: 36 additions & 0 deletions src/pages/workers-ai/models/[name].astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { GetStaticPaths } from "astro";
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
import { getCollection } from "astro:content";
import { InlineBadge } from "~/components";
import Schemas from "~/components/models/Schemas.astro";
import Playground from "~/components/models/Playground.astro";
import TextGenerationResponses from "~/components/models/responses/TextGenerationResponses.astro";
Expand Down Expand Up @@ -51,6 +52,40 @@ const hasLora = Boolean(
data.model.properties.find((x) => x.property_id === "lora"),
);
const badges = data.model.properties.flatMap(({ property_id, value }) => {
if (property_id === "beta" && value === "true") {
return {
preset: "beta",
};
}
if (property_id === "lora" && value === "true") {
return {
variant: "tip",
text: "LoRA",
};
}
if (property_id === "function_calling" && value === "true") {
return {
variant: "note",
text: "Function calling",
};
}
if (property_id === "planned_deprecation_date") {
const timestamp = Math.floor(new Date(value).getTime() / 1000);
if (Date.now() > timestamp) {
return { variant: "danger", text: "Deprecated" };
}
return { variant: "danger", text: "Planned deprecation" };
}
return [];
});
let CodeExamples;
let Responses;
Expand Down Expand Up @@ -116,6 +151,7 @@ if (data.model.name === "@cf/runwayml/stable-diffusion-v1-5-inpainting") {
---

<StarlightPage frontmatter={{ title: name, description }}>
{badges.map((badge) => <InlineBadge {...badge} /> )}
<p>
<strong>Model ID: </strong>
<code>{data.model.name}</code>
Expand Down

0 comments on commit 14a4142

Please sign in to comment.