feat: Add badge support to model specifications with TBadge type and schema

This commit is contained in:
Ruben Talstra 2025-02-22 12:38:12 +01:00
parent acafdb54c2
commit b50406ab9e
No known key found for this signature in database
GPG key ID: 2A5A7174A60F3BEA
2 changed files with 26 additions and 5 deletions

View file

@ -76,6 +76,19 @@ const MenuItem: FC<MenuItemProps> = ({
<div>
{title}
<div className="text-token-text-tertiary">{description}</div>
{spec.badges && spec.badges.length > 0 && (
<div className="mt-1 flex gap-2">
{spec.badges.map((badge, index) => (
<span
key={index}
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-semibold shadow-sm"
style={{ backgroundColor: badge.color, color: '#fff' }}
>
{badge.text}
</span>
))}
</div>
)}
</div>
</div>
</div>

View file

@ -8,6 +8,11 @@ import {
authTypeSchema,
} from './schemas';
export type TBadge = {
text: string;
color: string;
};
export type TModelSpec = {
name: string;
label: string;
@ -19,11 +24,15 @@ export type TModelSpec = {
showIconInHeader?: boolean;
iconURL?: string | EModelEndpoint; // Allow using project-included icons
authType?: AuthType;
groups?: Array<string>; // List of group ObjectIds allowed to access this model
// badgeIcon?: string; // URL to badge icon for visual categorization
// badgeTooltip?: string; // Tooltip text for the badge
groups?: string[];
badges?: TBadge[];
};
export const tBadgeSchema = z.object({
text: z.string(),
color: z.string(),
});
export const tModelSpecSchema = z.object({
name: z.string(),
label: z.string(),
@ -36,8 +45,7 @@ export const tModelSpecSchema = z.object({
iconURL: z.union([z.string(), eModelEndpointSchema]).optional(),
authType: authTypeSchema.optional(),
groups: z.array(z.string()).optional(),
// badgeIcon: z.string().url('Must be a valid URL').optional(),
// badgeTooltip: z.string().optional(),
badges: z.array(tBadgeSchema).optional(),
});
export const specsConfigSchema = z.object({