Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/middlewares/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
36 changes: 36 additions & 0 deletions backend/services/agents/botEngine.ts
Original file line number Diff line number Diff line change
@@ -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<string> => {
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`);
}
};
39 changes: 39 additions & 0 deletions backend/services/agents/botPersonas.ts
Original file line number Diff line number Diff line change
@@ -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.",
},
];
Empty file.