LibreChat/config/seed-categories.js
Danny Avila 658480d7cd
🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)
WIP: pre-granular-permissions commit

feat: Add category and support contact fields to Agent schema and UI components

Revert "feat: Add category and support contact fields to Agent schema and UI components"

This reverts commit c43a52b4c9.

Fix: Update import for renderHook in useAgentCategories.spec.tsx

fix: Update icon rendering in AgentCategoryDisplay tests to use empty spans

refactor: Improve category synchronization logic and clean up AgentConfig component

refactor: Remove unused UI flow translations from translation.json

feat: agent marketplace features

🔐 feat: Granular Role-based Permissions + Entra ID Group Discovery (#7804)
2025-06-28 12:37:58 -04:00

106 lines
3.1 KiB
JavaScript

const connectDb = require('../api/lib/db/connectDb');
const AgentCategory = require('../api/models/AgentCategory');
// Define category constants directly since the constants file was removed
const CATEGORY_VALUES = {
GENERAL: 'general',
HR: 'hr',
RD: 'rd',
FINANCE: 'finance',
IT: 'it',
SALES: 'sales',
AFTERSALES: 'aftersales',
};
const CATEGORY_DESCRIPTIONS = {
general: 'General purpose agents for common tasks and inquiries',
hr: 'Agents specialized in HR processes, policies, and employee support',
rd: 'Agents focused on R&D processes, innovation, and technical research',
finance: 'Agents specialized in financial analysis, budgeting, and accounting',
it: 'Agents for IT support, technical troubleshooting, and system administration',
sales: 'Agents focused on sales processes, customer relations, and marketing',
aftersales: 'Agents specialized in post-sale support, maintenance, and customer service',
};
/**
* Seed agent categories from existing constants into MongoDB
* This migration creates the initial category data in the database
*/
async function seedCategories() {
try {
await connectDb();
console.log('Connected to database');
// Prepare category data from existing constants
const categoryData = [
{
value: CATEGORY_VALUES.GENERAL,
label: 'General',
description: CATEGORY_DESCRIPTIONS.general,
order: 0,
},
{
value: CATEGORY_VALUES.HR,
label: 'Human Resources',
description: CATEGORY_DESCRIPTIONS.hr,
order: 1,
},
{
value: CATEGORY_VALUES.RD,
label: 'Research & Development',
description: CATEGORY_DESCRIPTIONS.rd,
order: 2,
},
{
value: CATEGORY_VALUES.FINANCE,
label: 'Finance',
description: CATEGORY_DESCRIPTIONS.finance,
order: 3,
},
{
value: CATEGORY_VALUES.IT,
label: 'Information Technology',
description: CATEGORY_DESCRIPTIONS.it,
order: 4,
},
{
value: CATEGORY_VALUES.SALES,
label: 'Sales & Marketing',
description: CATEGORY_DESCRIPTIONS.sales,
order: 5,
},
{
value: CATEGORY_VALUES.AFTERSALES,
label: 'After Sales',
description: CATEGORY_DESCRIPTIONS.aftersales,
order: 6,
},
];
console.log('Seeding categories...');
const result = await AgentCategory.seedCategories(categoryData);
console.log(`Successfully seeded ${result.upsertedCount} new categories`);
console.log(`Modified ${result.modifiedCount} existing categories`);
// Verify the seeded data
const categories = await AgentCategory.getActiveCategories();
console.log('Active categories in database:');
categories.forEach((cat) => {
console.log(` - ${cat.value}: ${cat.label} (order: ${cat.order})`);
});
console.log('Category seeding completed successfully');
process.exit(0);
} catch (error) {
console.error('Error seeding categories:', error);
process.exit(1);
}
}
// Run if called directly
if (require.main === module) {
seedCategories();
}
module.exports = seedCategories;