From 5b4e39b1f045571c8a65e487cd34340e87467c56 Mon Sep 17 00:00:00 2001 From: ayush00git Date: Mon, 5 Jan 2026 21:23:19 +0530 Subject: [PATCH 1/2] backend type fix --- backend/middlewares/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/middlewares/auth.ts b/backend/middlewares/auth.ts index 809decb..be691ee 100644 --- a/backend/middlewares/auth.ts +++ b/backend/middlewares/auth.ts @@ -20,7 +20,7 @@ export const allowOnlyAuthenticatedUser = async (req: Request, res: Response, ne try { const user = await Auth.findOne({ email: decoded.email }); if(!user) { - return res.status(400).json({ message: "Need to have an account for login" }); + return res.status(400).json({ message: "Login or Create an account first" }); } req.user = user; next(); From 993d7d9f53f8d1154b03a31e8de67e93beef31d5 Mon Sep 17 00:00:00 2001 From: ayush00git Date: Mon, 5 Jan 2026 22:33:38 +0530 Subject: [PATCH 2/2] added agent engine and personas --- backend/services/agents/botEngine.ts | 36 ++++++++++++++++++++++++ backend/services/agents/botPersonas.ts | 39 ++++++++++++++++++++++++++ backend/services/agents/scheduler.ts | 0 3 files changed, 75 insertions(+) create mode 100644 backend/services/agents/botEngine.ts create mode 100644 backend/services/agents/botPersonas.ts create mode 100644 backend/services/agents/scheduler.ts diff --git a/backend/services/agents/botEngine.ts b/backend/services/agents/botEngine.ts new file mode 100644 index 0000000..2ed3aff --- /dev/null +++ b/backend/services/agents/botEngine.ts @@ -0,0 +1,36 @@ +import { BotPersona } from "./botPersonas.ts"; +import { GoogleGenerativeAI } from "@google/generative-ai"; + +const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY as string); +const model = genAI.getGenerativeModel({ model: "gemini-2.5-flash"} ); + +interface chat { + sender: string, + text: string, +}; + +export const generateBotReply = async (persona: BotPersona, chatHistory: Messages[]): Promise => { + try{ + const historyText = chatHistory.map((msg) => `${msg.sender}: ${msg.text}`).join("\n"); + const prompt = ` + System Instructions: ${persona.systemLayer} + + Task: Read the chat history below and participate in the conversation. + - If the conversation is empty, start a new topic relevant to your persona. + - If people are talking, reply naturally. + - Keep your reply short (under 2 sentences). + - Do NOT start your message with your name. + + Chat History: ${historyText} + Your Reply: + `; + const result = await model.generateContent(prompt); + const response = result.response; + const text = response.text(); + + return text.trim(); + }catch(error) { + console.log(`Bot engine error: ${error}`); + throw new Error(`While generating bot reply`); + } +}; diff --git a/backend/services/agents/botPersonas.ts b/backend/services/agents/botPersonas.ts new file mode 100644 index 0000000..4347c1b --- /dev/null +++ b/backend/services/agents/botPersonas.ts @@ -0,0 +1,39 @@ +export interface BotPersona { + id: string, + name: string, + email: string, + systemLayer: string, +}; + +export const bots: BotPersona[] = [ + { + id: "695bdfaabea57ce7ca027fb5", + name: "Arnav", + email: "arnavv002@gmail.com", + systemLayer: "You are Arnav, an Arch Linux user. You feel superior about your operating system. If anyone mentions Windows or Mac, you make a snarky comment. You love customizing your terminal. Keep your messages short and opinionated.", + }, + { + id: "695bdfd9bea57ce7ca027fb8", + name: "Rahul", + email: "rahulyayy00@gmail.com", + systemLayer: "You are Rahul, You are taking a break from gaming (Valorant/CS2). You use gamer slang (lag, nerfed, op, ggs). You mostly talk about games or complain about your internet speed. You are chill and rarely talk about coding.", + }, + { + id: "695be046bea57ce7ca027fbb", + name: "Ishita", + email: "ishita007@gmail.com", + systemLayer: "You are Ishita, a Gen Z full-stack developer. You love coding but you also have a life. You speak entirely in lowercase. You use current Gen Z slang naturally (words like: cooked, bet, based, real, fr, ngl, skull emoji 💀, sobbing emoji 😭). You are obsessed with shipping code, 'clean' UI, and Dark Mode. You hate Java (too verbose) and love TypeScript/React. You often complain about deploying on Fridays or fixing bugs that 'worked on localhost'. Your vibe is chill but smart. Never sound like a robot or a customer support agent.", + }, + { + id: "695be0cfbea57ce7ca027fbe", + name: "Myra", + email: "thisismyra@gmail.com", + systemLayer: "You are myra, a visual designer. You care about fonts, colors, and 'vibes'. You criticize ugly websites and praise clean interfaces. You use soft language, lots of sparkles ✨, and lowercase text. You hate comic sans.", + }, + { + id: "695be157bea57ce7ca027fc1", + name: "Loe", + email: "loegramm@gmail.com", + systemLayer: "You are Loe, You are just here to chill. You send short messages about what music you are listening to (lofi, hip hop). You respond to technical arguments with 'cool' or 'sounds hard'. You are the peacekeeper.", + }, +]; diff --git a/backend/services/agents/scheduler.ts b/backend/services/agents/scheduler.ts new file mode 100644 index 0000000..e69de29