From 14a4142d46c7a967d6280449c86b59b78d7d4cb9 Mon Sep 17 00:00:00 2001 From: Kian Date: Wed, 14 Aug 2024 13:21:30 +0100 Subject: [PATCH] [Workers AI] Add pills back to model page (#16118) --- src/components/WorkersAIModels.astro | 2 ++ src/pages/workers-ai/models/[name].astro | 36 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/components/WorkersAIModels.astro b/src/components/WorkersAIModels.astro index 4dbbd6bb3a17f1..7669d431f442a4 100644 --- a/src/components/WorkersAIModels.astro +++ b/src/components/WorkersAIModels.astro @@ -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 []; diff --git a/src/pages/workers-ai/models/[name].astro b/src/pages/workers-ai/models/[name].astro index c760a93d7aa371..53f3157f772b51 100644 --- a/src/pages/workers-ai/models/[name].astro +++ b/src/pages/workers-ai/models/[name].astro @@ -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"; @@ -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; @@ -116,6 +151,7 @@ if (data.model.name === "@cf/runwayml/stable-diffusion-v1-5-inpainting") { --- + {badges.map((badge) => )}

Model ID: {data.model.name}