import { generateBatchProfiles, MediaOutletProfile } from "./server/openai-utils"; import { storage } from "./server/storage"; // Define the specific 12 media outlets we want to generate profiles for const TARGET_OUTLETS = [ 'alex-karp', 'arthur-hayes', 'jacob-robert-steeves', '07806f4a-4fdd-4a46-a814-a06d07b5bb2c', '80a9a613-b6e8-4431-a0c2-1f531d43a9c0', 'ai', 'dex', 'a60f82a2-2d56-4889-b312-28c232c660f9', '7f641e7b-0eca-4688-8bb4-74a7a15a844e', 'bittensor', 'hyperliquid', 'palantir' ]; async function main() { try { console.log("šŸš€ Starting AI profile generation for 12 media outlets..."); // Get all outlets first to find the ones we need const allExistingOutlets = await storage.getAllOutlets(); const targetOutlets = allExistingOutlets.filter(outlet => TARGET_OUTLETS.includes(outlet.id) ); console.log(`šŸ“Š Found ${targetOutlets.length} outlets to process`); // Convert to the format expected by AI generation const outletProfiles: MediaOutletProfile[] = targetOutlets.map(outlet => ({ name: outlet.name, category: outlet.category, focusSubject: outlet.focusSubject, bio: outlet.bio, fullBio: outlet.fullBio || [] })); // Generate detailed profiles using AI console.log("šŸ¤– Generating detailed Wikipedia-style profiles with AI..."); const generatedProfiles = await generateBatchProfiles(outletProfiles); // Update each outlet with the generated profile console.log("šŸ’¾ Saving generated profiles to database..."); let successCount = 0; for (const outlet of targetOutlets) { const generatedProfile = generatedProfiles[outlet.name]; if (generatedProfile) { try { await storage.updateOutlet(outlet.id, { wikiProfile: generatedProfile }); console.log(`āœ… Updated profile for ${outlet.name}`); successCount++; } catch (error) { console.error(`āŒ Failed to update ${outlet.name}:`, error); } } } console.log(`\nšŸŽ‰ Profile generation completed!`); console.log(`āœ… Successfully generated and saved ${successCount}/${targetOutlets.length} profiles`); console.log("\nNext steps:"); console.log("1. Update the frontend UI to display the new detailed profiles"); console.log("2. Test the new profile display functionality"); } catch (error) { console.error("āŒ Error during profile generation:", error); process.exit(1); } } // Only run if this file is executed directly if (import.meta.url === `file://${process.argv[1]}`) { main().then(() => { console.log("✨ Profile generation script completed successfully"); process.exit(0); }).catch((error) => { console.error("šŸ’„ Profile generation script failed:", error); process.exit(1); }); } export { main as generateAllProfiles };