NexusAI Studio โ Multi-Persona AI Workspace
Full-stack AI workspace featuring token-by-token Server-Sent Events (SSE) streaming, specialized workspace personas, prompt template library, and hybrid Google Gemini API + offline simulation.
// Express SSE Streaming Handler
app.post('/api/chat/stream', async (req, res) => {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
});
const { prompt, persona, history } = req.body;
const stream = await geminiModel.generateContentStream({
contents: [...history, { role: 'user', parts: [{ text: prompt }] }],
systemInstruction: getPersonaPrompt(persona)
});
for await (const chunk of stream.stream) {
res.write(`data: ${JSON.stringify({ text: chunk.text() })}\n\n`);
}
res.write('data: [DONE]\n\n');
res.end();
});