Files
sapiens-mobile/generate-profiles.ts
jungwoo choi 919afe56f2 feat: SAPIENS Mobile App - Initial commit
React Native mobile application for SAPIENS news platform.
Consolidated all previous history into single commit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 14:30:25 +09:00

76 lines
2.8 KiB
TypeScript

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 };