Download client/src/lib/endpoint-groups.ts from automindy/fokemal: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/spaces/automindy/fokemal/resolve/main/client/src/lib/endpoint-groups.ts
- Command line
-
hf download hf://spaces/automindy/fokemal/client/src/lib/endpoint-groups.ts
-
curl -L -o endpoint-groups.ts https://huggingface.co/spaces/automindy/fokemal/resolve/main/client/src/lib/endpoint-groups.ts
880 Bytes
| // Custom-endpoint groups (#1176): helpers shared by the Keys page components. | |
| import type { ApiKey } from '../../../shared/types' | |
| /** The labels already in use by custom endpoints, sorted, for suggestions. */ | |
| export function existingGroupLabels(keys: ApiKey[]): string[] { | |
| const labels = new Set<string>() | |
| for (const k of keys) { | |
| const label = k.platform === 'custom' ? k.groupLabel?.trim() : '' | |
| if (label) labels.add(label) | |
| } | |
| return [...labels].sort((a, b) => a.localeCompare(b)) | |
| } | |
| /** | |
| * The typable handle a group answers to after `#` in a model id (#1176) — | |
| * mirrors the server's endpointHandle slug, so `My Relays` is `my-relays`. | |
| */ | |
| export function groupHandle(label: string): string { | |
| const slug = label | |
| .toLowerCase() | |
| .replace(/[^a-z0-9.]+/g, '-') | |
| .replace(/-+/g, '-') | |
| .replace(/^[-.]+|[-.]+$/g, '') | |
| return slug || 'endpoint' | |
| } | |