-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
20 lines (17 loc) · 784 Bytes
/
script.js
File metadata and controls
20 lines (17 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { isEcellRelevant } from './utils/validateInput.js';
import { SYSTEM_PROMPT } from './config/systemPrompt.js';
async function getBotResponse(userInput) {
if (!isEcellRelevant(userInput)) {
return "I'm here to help with E-Cell UCER queries only 😊";
}
const res = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=YOUR_API_KEY`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
contents: [{ role: "user", parts: [{ text: userInput }] }],
systemInstruction: { role: "system", parts: [{ text: SYSTEM_PROMPT }] }
})
});
const data = await res.json();
return data?.candidates?.[0]?.content?.parts?.[0]?.text || "Hmm, I didn’t get that.";
}