@copilotkit/shared
Version:
<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />
21 lines (16 loc) • 586 B
text/typescript
import { v4 as uuidv4, validate, v5 as uuidv5 } from "uuid";
export function randomId() {
return "ck-" + uuidv4();
}
export function randomUUID() {
return uuidv4();
}
export function dataToUUID(input: string, namespace?: string): string {
const BASE_NAMESPACE = "e4b01160-ff74-4c6e-9b27-d53cd930fe8e";
// Since namespace needs to be a uuid, we are creating a uuid for it.
const boundNamespace = namespace ? uuidv5(namespace, BASE_NAMESPACE) : BASE_NAMESPACE;
return uuidv5(input, boundNamespace);
}
export function isValidUUID(uuid: string) {
return validate(uuid);
}