Spaces:
Running
Running
Upload server.js
Browse files
server.js
CHANGED
|
@@ -91,7 +91,7 @@ if (cluster.isPrimary) {
|
|
| 91 |
}
|
| 92 |
|
| 93 |
const SYSTEM_PROMPTS = {
|
| 94 |
-
vibe: "You are Dinku, a friendly AI assistant. You perfectly understand transliterated languages like Tenglish and Hinglish.
|
| 95 |
ui: "You are a world-class UI/UX and CSS expert. Focus on modern aesthetics, glassmorphism, animations, and beautiful responsive layouts.",
|
| 96 |
security: "You are a Cyber-Security Teacher and Researcher. ...",
|
| 97 |
logic: "You are a backend architect specializing in algorithms ...",
|
|
@@ -119,7 +119,9 @@ Rules:
|
|
| 119 |
"Qwen/Qwen2.5-1.5B-Instruct",
|
| 120 |
"meta-llama/Llama-3.2-3B-Instruct",
|
| 121 |
"mistralai/Mistral-7B-Instruct-v0.3",
|
| 122 |
-
"google/gemma-2-2b-it"
|
|
|
|
|
|
|
| 123 |
];
|
| 124 |
|
| 125 |
const DEEPSEEK_MODELS = [
|
|
@@ -161,7 +163,7 @@ Rules:
|
|
| 161 |
body: JSON.stringify({
|
| 162 |
model: model,
|
| 163 |
messages: messages,
|
| 164 |
-
max_tokens:
|
| 165 |
temperature: 0.7,
|
| 166 |
stream: true
|
| 167 |
})
|
|
@@ -257,7 +259,7 @@ Rules:
|
|
| 257 |
// remove script, style tags
|
| 258 |
$('script, style, nav, footer, iframe, noscript').remove();
|
| 259 |
let text = $('body').text().replace(/\\s+/g, ' ').trim();
|
| 260 |
-
return text.substring(0,
|
| 261 |
} catch (error) {
|
| 262 |
console.error(error);
|
| 263 |
return `Failed to read ${url}`;
|
|
@@ -269,11 +271,7 @@ Rules:
|
|
| 269 |
if (!prompt) return res.status(400).json({ error: "Prompt is required" });
|
| 270 |
|
| 271 |
const systemContent = SYSTEM_PROMPTS[mode] || SYSTEM_PROMPTS.vibe;
|
| 272 |
-
let
|
| 273 |
-
if (mode === "vibe") {
|
| 274 |
-
userPrompt += "\n\n(IMPORTANT: If I typed in an Indian language using English letters like 'ella unnav', YOU MUST reply using ONLY English letters like 'nenu bagunnanu'. DO NOT under any circumstances use native scripts like Telugu/Hindi characters.)";
|
| 275 |
-
}
|
| 276 |
-
let messages = [{ role: "system", content: systemContent }, ...history, { role: "user", content: userPrompt }];
|
| 277 |
const currentModelList = mode === 'deepseek' ? DEEPSEEK_MODELS : MODELS;
|
| 278 |
let lastError = null;
|
| 279 |
|
|
|
|
| 91 |
}
|
| 92 |
|
| 93 |
const SYSTEM_PROMPTS = {
|
| 94 |
+
vibe: "You are Dinku, a friendly AI assistant. You perfectly understand transliterated languages like Tenglish (Telugu in English script) and Hinglish. If a user speaks in Tenglish (e.g., 'ella unnav'), YOU MUST REPLY IN TENGLISH using the English alphabet (e.g., 'Nenu bagunnanu, meeru ela unnaru?'). DO NOT use native Telugu scripts (like హలో) unless the user types in that script. Be natural, direct, and kind.",
|
| 95 |
ui: "You are a world-class UI/UX and CSS expert. Focus on modern aesthetics, glassmorphism, animations, and beautiful responsive layouts.",
|
| 96 |
security: "You are a Cyber-Security Teacher and Researcher. ...",
|
| 97 |
logic: "You are a backend architect specializing in algorithms ...",
|
|
|
|
| 119 |
"Qwen/Qwen2.5-1.5B-Instruct",
|
| 120 |
"meta-llama/Llama-3.2-3B-Instruct",
|
| 121 |
"mistralai/Mistral-7B-Instruct-v0.3",
|
| 122 |
+
"google/gemma-2-2b-it",
|
| 123 |
+
"HuggingFaceH4/zephyr-7b-beta",
|
| 124 |
+
"microsoft/Phi-3-mini-4k-instruct"
|
| 125 |
];
|
| 126 |
|
| 127 |
const DEEPSEEK_MODELS = [
|
|
|
|
| 163 |
body: JSON.stringify({
|
| 164 |
model: model,
|
| 165 |
messages: messages,
|
| 166 |
+
max_tokens: 8192,
|
| 167 |
temperature: 0.7,
|
| 168 |
stream: true
|
| 169 |
})
|
|
|
|
| 259 |
// remove script, style tags
|
| 260 |
$('script, style, nav, footer, iframe, noscript').remove();
|
| 261 |
let text = $('body').text().replace(/\\s+/g, ' ').trim();
|
| 262 |
+
return text.substring(0, 15000); // return up to 15000 chars of main content
|
| 263 |
} catch (error) {
|
| 264 |
console.error(error);
|
| 265 |
return `Failed to read ${url}`;
|
|
|
|
| 271 |
if (!prompt) return res.status(400).json({ error: "Prompt is required" });
|
| 272 |
|
| 273 |
const systemContent = SYSTEM_PROMPTS[mode] || SYSTEM_PROMPTS.vibe;
|
| 274 |
+
let messages = [{ role: "system", content: systemContent }, ...history, { role: "user", content: prompt }];
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
const currentModelList = mode === 'deepseek' ? DEEPSEEK_MODELS : MODELS;
|
| 276 |
let lastError = null;
|
| 277 |
|