From e09573d9a917f9dcb829ffb8cd4c0e475727d095 Mon Sep 17 00:00:00 2001 From: Shreyas-Microsoft Date: Tue, 15 Apr 2025 14:05:19 +0530 Subject: [PATCH] Consistent agent naming --- src/backend/api/api_routes.py | 2 +- src/frontend/src/api/utils.tsx | 36 +++++++++++++++----- src/frontend/src/pages/modernizationPage.tsx | 10 +++--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/backend/api/api_routes.py b/src/backend/api/api_routes.py index d3c561e..88986a1 100644 --- a/src/backend/api/api_routes.py +++ b/src/backend/api/api_routes.py @@ -26,7 +26,7 @@ logger = AppLogger("APIRoutes") # start processing the batch -from sql_agents_start import process_batch_async # noqa: E402 +# from sql_agents_start import process_batch_async # noqa: E402 # start processing the batch @router.post("/start-processing") diff --git a/src/frontend/src/api/utils.tsx b/src/frontend/src/api/utils.tsx index f66517c..95ce545 100644 --- a/src/frontend/src/api/utils.tsx +++ b/src/frontend/src/api/utils.tsx @@ -294,15 +294,35 @@ export const determineFileStatus = (file) => { return "error"; }; // Function to format agent type strings -export const formatAgent = (str = "Agents") => { - if (!str) return "Agents"; - return str +export const formatAgent = (str = "Agent") => { + if (!str) return "agent"; + + const cleaned = str .replace(/[^a-zA-Z\s]/g, " ") // Remove non-alphabetic characters - .replace(/\s+/g, " ") // Replace multiple spaces with a single space - .trim() // Remove leading/trailing spaces - .split(" ") // Split words - .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize first letter - .join(" ") || "Agents"; // Ensure default "Agent" if empty + .replace(/\s+/g, " ") // Collapse multiple spaces + .trim() + .replace(/\bAgents\b/i, "Agent"); // Singularize "Agents" if it's the only word + + const words = cleaned + .split(" ") + .filter(Boolean) + .map(w => w.toLowerCase()); + + const hasAgent = words.includes("agent"); + + // Capitalize all except "agent" (unless it's the only word) + const result = words.map((word, index) => { + if (word === "agent") { + return words.length === 1 ? "Agent" : "agent"; // Capitalize if it's the only word + } + return word.charAt(0).toUpperCase() + word.slice(1); + }); + + if (!hasAgent) { + result.push("agent"); + } + + return result.join(" "); }; // Function to handle rate limit errors and ensure descriptions end with a dot diff --git a/src/frontend/src/pages/modernizationPage.tsx b/src/frontend/src/pages/modernizationPage.tsx index 082d44f..685842c 100644 --- a/src/frontend/src/pages/modernizationPage.tsx +++ b/src/frontend/src/pages/modernizationPage.tsx @@ -425,11 +425,11 @@ enum ProcessingStage { } enum Agents { - Verifier = "Semantic Verifier", - Checker = "Syntax Checker", - Picker = "Picker", - Migrator = "Migrator", - Agents = "Agents" + Verifier = "Semantic Verifier agent", + Checker = "Syntax Checker agent", + Picker = "Picker agent", + Migrator = "Migrator agent", + Agents = "Agent" }