Skip to content

fix: Consistent agent naming #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions src/frontend/src/api/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/src/pages/modernizationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}


Expand Down