From 9b47349ea230c0fb64a5d669f8d3ba34d52edc7e Mon Sep 17 00:00:00 2001 From: Ryan Hopper-Lowe <46546486+ryanhopperlowe@users.noreply.github.com> Date: Tue, 26 Nov 2024 00:08:12 -0600 Subject: [PATCH] enhance: turn up the heat in the agent/workflow name generation (#679) --- ui/admin/app/lib/service/nameGenerator.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ui/admin/app/lib/service/nameGenerator.ts b/ui/admin/app/lib/service/nameGenerator.ts index be003710..31b63819 100644 --- a/ui/admin/app/lib/service/nameGenerator.ts +++ b/ui/admin/app/lib/service/nameGenerator.ts @@ -1,12 +1,10 @@ import { faker } from "@faker-js/faker"; -export function generateRandomName(): string { - // faker doesn't have a "capitalized word" function, so we need to do it manually :( - const rawAdjective = faker.word.adjective(); - const rawAnimal = faker.animal.type(); - const adjective = - rawAdjective.charAt(0).toUpperCase() + rawAdjective.slice(1); - const animal = rawAnimal.charAt(0).toUpperCase() + rawAnimal.slice(1); +const uppercaseFirst = (word: string) => + word.charAt(0).toUpperCase() + word.slice(1); - return `${adjective} ${animal}`; +export function generateRandomName(): string { + return [faker.word.adjective(), faker.word.noun()] + .map(uppercaseFirst) + .join(" "); }