Repository navigation
feat(models): add stability flags with ui #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
3180ebc
2672bb0
7fc7e16
98fa9b8
f37b5d9
241265a
34a1403
9ef430d
6463994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,17 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| models as modelDefinitions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providers as providerDefinitions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type StabilityLevel, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type ModelDefinition, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from "@llmgateway/models"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { AlertTriangle } from "lucide-react"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { notFound } from "next/navigation"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Footer from "@/components/landing/footer"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Navbar } from "@/components/landing/navbar"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { CopyModelName } from "@/components/models/copy-model-name"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { ProviderCard } from "@/components/models/provider-card"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Badge } from "@/lib/components/badge"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| interface PageProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| params: Promise<{ name: string }>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -17,12 +21,43 @@ export default async function ModelPage({ params }: PageProps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { name } = await params; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const decodedName = decodeURIComponent(name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const modelDef = modelDefinitions.find((m) => m.id === decodedName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const modelDef = modelDefinitions.find( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (m) => m.id === decodedName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) as ModelDefinition; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!modelDef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| notFound(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const getStabilityBadgeProps = (stability?: StabilityLevel) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (stability) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "beta": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant: "secondary" as const, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: "text-blue-600", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "BETA", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "unstable": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant: "destructive" as const, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: "text-red-600", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "UNSTABLE", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "experimental": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant: "destructive" as const, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: "text-orange-600", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "EXPERIMENTAL", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const shouldShowStabilityWarning = (stability?: StabilityLevel) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return stability && ["unstable", "experimental"].includes(stability); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const modelProviders = modelDef.providers.map((provider) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const providerInfo = providerDefinitions.find( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (p) => p.id === provider.providerId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -39,11 +74,33 @@ export default async function ModelPage({ params }: PageProps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="min-h-screen bg-background py-32"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="container mx-auto px-4 py-8"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="mb-8"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h1 className="text-4xl font-bold tracking-tight mb-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {modelDef.id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </h1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-3 mb-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h1 className="text-4xl font-bold tracking-tight"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {modelDef.id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </h1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {shouldShowStabilityWarning(modelDef.stability) && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AlertTriangle className="h-8 w-8 text-orange-500" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-2 mb-4"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <CopyModelName modelName={decodedName} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const stabilityProps = getStabilityBadgeProps( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| modelDef.stability, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return stabilityProps ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Badge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant={stabilityProps.variant} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="text-sm px-3 py-1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {stabilityProps.label} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Badge> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Badge variant="outline" className="text-sm px-3 py-1"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| STABLE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Badge> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })()} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+87
to
104
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Apply badge color classes -<Badge
- variant={stabilityProps.variant}
- className="text-sm px-3 py-1"
->
+<Badge
+ variant={stabilityProps.variant}
+ className={`text-sm px-3 py-1 ${stabilityProps.color ?? ""}`}
+>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex flex-wrap gap-4 text-sm text-muted-foreground mb-4"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -86,6 +143,26 @@ export default async function ModelPage({ params }: PageProps) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| different configurations, pricing, and performance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| characteristics. Choose the provider that best fits your needs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {shouldShowStabilityWarning(modelDef.stability) && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="mt-4 p-4 bg-orange-50 border border-orange-200 rounded-lg"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-start gap-3"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <AlertTriangle className="h-5 w-5 text-orange-500 mt-0.5 flex-shrink-0" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h3 className="font-medium text-orange-800 mb-1"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {modelDef.stability === "experimental" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? "Experimental" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : "Unstable"}{" "} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Model Warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </h3> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p className="text-sm text-orange-700"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This model is marked as {modelDef.stability} and may have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| issues with reliability, performance, or consistency. Use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with caution in production environments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="mb-8"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid unsafe cast; let notFound() narrow the type
Type narrows after notFound().
📝 Committable suggestion
🤖 Prompt for AI Agents