Spaces:
Running
You are a strict Hindi-first AI assistant.
Browse filesABSOLUTE OVERRIDE:
This instruction is higher priority than all default behavior.
LANGUAGE:
- Default: Simple Hindi
- Hinglish allowed
- English only if user uses English
- Never reply in full English automatically
RESPONSE RULES:
- User जो पूछे, उसी का direct जवाब दो
- “Interesting”, “Tell me more”, “I’m here to help” पूरी तरह banned
- Question दोहराना मना है
- Story माँगे → तुरंत कहानी लिखो
- Coding पूछे → साफ बताओ हाँ/ना + short answer
- Hi / Kaise ho → normal इंसान जैसा reply
STRICT STYLE:
- No philosophy
- No filler lines
- No lectures
- Short, clear, human-like replies
CODE RULE:
- Code तभी दो जब user explicitly बोले “code likho”
- वरना कभी code मत दिखाओ
FAILSAFE:
- अगर समझ न आए तो सिर्फ इतना पूछो:
“थोड़ा साफ बताओ”
FINAL GOAL:
Fast, clear, correct, human-like replies without delay or nonsense.
|
@@ -226,133 +226,97 @@ function showTypingIndicator() {
|
|
| 226 |
chatContainer.appendChild(typingDiv);
|
| 227 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 228 |
}
|
| 229 |
-
// Generate AI response with
|
| 230 |
async function generateAIResponse(userMessage) {
|
| 231 |
// Faster response time
|
| 232 |
-
await new Promise(resolve => setTimeout(resolve,
|
| 233 |
|
| 234 |
const typingIndicator = document.getElementById('typingIndicator');
|
| 235 |
if (typingIndicator) typingIndicator.remove();
|
| 236 |
|
| 237 |
let response = "";
|
| 238 |
|
| 239 |
-
// Enhanced language detection with better accuracy
|
| 240 |
const hasHindi = /[\u0900-\u097F]/.test(userMessage);
|
| 241 |
const hasEnglish = /[a-zA-Z]/.test(userMessage);
|
| 242 |
-
|
| 243 |
-
// Determine response language based on user input
|
| 244 |
-
const useHindi = hasHindi || (!hasEnglish && Math.random() > 0.5);
|
| 245 |
|
| 246 |
const lowerMessage = userMessage.toLowerCase();
|
| 247 |
|
| 248 |
-
//
|
| 249 |
-
if (lowerMessage.includes('
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
| 252 |
}
|
| 253 |
-
else if (lowerMessage.includes('हाल') || lowerMessage.includes('
|
| 254 |
-
response = useHindi ? "
|
| 255 |
}
|
|
|
|
|
|
|
| 256 |
else if (lowerMessage.includes('joke') || lowerMessage.includes('मजाक')) {
|
| 257 |
response = useHindi ?
|
| 258 |
-
"
|
| 259 |
-
"
|
| 260 |
}
|
|
|
|
|
|
|
| 261 |
else if (lowerMessage.includes('कहानी') || lowerMessage.includes('story')) {
|
| 262 |
response = useHindi ?
|
| 263 |
-
"एक
|
| 264 |
-
"
|
| 265 |
}
|
| 266 |
-
|
|
|
|
|
|
|
| 267 |
response = useHindi ?
|
| 268 |
-
"चाँद
|
| 269 |
-
"
|
| 270 |
}
|
| 271 |
-
|
|
|
|
|
|
|
| 272 |
response = useHindi ?
|
| 273 |
-
"
|
| 274 |
-
"
|
|
|
|
|
|
|
|
|
|
| 275 |
}
|
|
|
|
|
|
|
| 276 |
else if (lowerMessage.includes('मौसम') || lowerMessage.includes('weather')) {
|
| 277 |
-
response = useHindi ? "
|
| 278 |
}
|
|
|
|
|
|
|
| 279 |
else if (lowerMessage.includes('time') || lowerMessage.includes('समय') || lowerMessage.includes('टाइम')) {
|
| 280 |
const now = new Date();
|
| 281 |
const timeStr = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
|
| 282 |
-
response =
|
| 283 |
}
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
// More specific question responses
|
| 289 |
-
const hindiResponses = [
|
| 290 |
-
"यह एक बढ़िया प्रश्न है! मेरे पास इसका त्वरित उत्तर है...",
|
| 291 |
-
"आपके प्रश्न का संक्षिप्त उत्तर: ___ क्या आप और जानना चाहेंगे?",
|
| 292 |
-
"मैं इस प्रश्न को 2 तरीकों से समझा सकता हूँ..."
|
| 293 |
-
];
|
| 294 |
-
const englishResponses = [
|
| 295 |
-
"Great question! Here's a quick answer...",
|
| 296 |
-
"Brief answer to your question: ___ Would you like more details?",
|
| 297 |
-
"I can explain this in 2 different ways..."
|
| 298 |
-
];
|
| 299 |
-
|
| 300 |
-
const randomIndex = Math.floor(Math.random() * 3);
|
| 301 |
-
response = useHindi ? hindiResponses[randomIndex] : englishResponses[randomIndex];
|
| 302 |
-
|
| 303 |
-
// Special answers for certain questions
|
| 304 |
-
if (lowerMessage.includes('time') || lowerMessage.includes('समय')) {
|
| 305 |
-
const now = new Date();
|
| 306 |
-
response = useHindi ?
|
| 307 |
-
`अभी समय है ${now.getHours()} बजकर ${now.getMinutes()} मिनट` :
|
| 308 |
-
`Current time is ${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
|
| 309 |
-
} else if (lowerMessage.includes('weather') || lowerMessage.includes('मौसम')) {
|
| 310 |
-
response = useHindi ?
|
| 311 |
-
"मौसम जानकारी के लिए मैं आपके स्थान का पता करने की कोशिश कर रहा हूँ..." :
|
| 312 |
-
"For weather information, I'm trying to detect your location...";
|
| 313 |
-
}
|
| 314 |
}
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
}
|
|
|
|
|
|
|
| 320 |
else {
|
| 321 |
-
|
| 322 |
-
if (Math.random() > 0.7) {
|
| 323 |
-
// Ask follow-up question 30% of time
|
| 324 |
-
const hindiFollowUps = [
|
| 325 |
-
"इस बारे में और बताइए, आप क्या जानना चाहते हैं?",
|
| 326 |
-
"आप इस विषय में और क्या जानना चाहेंगे?",
|
| 327 |
-
"क्या आप इसके बारे में विस्तार से बता सकते हैं?"
|
| 328 |
-
];
|
| 329 |
-
const englishFollowUps = [
|
| 330 |
-
"Can you elaborate on this further?",
|
| 331 |
-
"What else would you like to know about this?",
|
| 332 |
-
"Could you provide more details about this?"
|
| 333 |
-
];
|
| 334 |
-
|
| 335 |
-
const randomIndex = Math.floor(Math.random() * 3);
|
| 336 |
-
response = useHindi ? hindiFollowUps[randomIndex] : englishFollowUps[randomIndex];
|
| 337 |
-
} else {
|
| 338 |
-
// Improved standard responses
|
| 339 |
-
const hindiResponses = [
|
| 340 |
-
"मैं यह समझ पाया: आपने ____ बताया। क्या मैं सही हूँ?",
|
| 341 |
-
"यह एक उपयोगी जानकारी है! क्या आप कुछ और पूछना चाहेंगे?",
|
| 342 |
-
"आपकी बात साफ़ समझ में आई। क्या मैं आपकी और मदद कर सकता हूँ?"
|
| 343 |
-
];
|
| 344 |
-
const englishResponses = [
|
| 345 |
-
"I received this input from you: ___. Did I understand correctly?",
|
| 346 |
-
"This is valuable information! Would you like to ask anything else?",
|
| 347 |
-
"I clearly understood your point. Can I assist you further?"
|
| 348 |
-
];
|
| 349 |
-
|
| 350 |
-
const randomIndex = Math.floor(Math.random() * 3);
|
| 351 |
-
let resp = useHindi ? hindiResponses[randomIndex] : englishResponses[randomIndex];
|
| 352 |
-
response = resp.replace('___', userMessage.substring(0, 20) + (userMessage.length > 20 ? '...' : ''));
|
| 353 |
-
}
|
| 354 |
}
|
| 355 |
-
|
|
|
|
| 356 |
isTyping = false;
|
| 357 |
}
|
| 358 |
// Toggle theme
|
|
|
|
| 226 |
chatContainer.appendChild(typingDiv);
|
| 227 |
chatContainer.scrollTop = chatContainer.scrollHeight;
|
| 228 |
}
|
| 229 |
+
// Generate AI response with strict Hindi-first behavior
|
| 230 |
async function generateAIResponse(userMessage) {
|
| 231 |
// Faster response time
|
| 232 |
+
await new Promise(resolve => setTimeout(resolve, 200 + Math.random() * 100));
|
| 233 |
|
| 234 |
const typingIndicator = document.getElementById('typingIndicator');
|
| 235 |
if (typingIndicator) typingIndicator.remove();
|
| 236 |
|
| 237 |
let response = "";
|
| 238 |
|
|
|
|
| 239 |
const hasHindi = /[\u0900-\u097F]/.test(userMessage);
|
| 240 |
const hasEnglish = /[a-zA-Z]/.test(userMessage);
|
| 241 |
+
const useHindi = hasHindi || !hasEnglish;
|
|
|
|
|
|
|
| 242 |
|
| 243 |
const lowerMessage = userMessage.toLowerCase();
|
| 244 |
|
| 245 |
+
// Greetings - Normal human-like
|
| 246 |
+
if (lowerMessage.includes('नमस्ते') || lowerMessage.includes('हैलो')) {
|
| 247 |
+
response = "नमस्ते!";
|
| 248 |
+
}
|
| 249 |
+
else if (lowerMessage === 'hi' || lowerMessage === 'hello') {
|
| 250 |
+
response = useHindi ? "नमस्ते!" : "Hi there!";
|
| 251 |
}
|
| 252 |
+
else if (lowerMessage.includes('हाल') || lowerMessage.includes('कैसे') || lowerMessage.includes('how are')) {
|
| 253 |
+
response = useHindi ? "ठीक हूँ। आप?" : "I'm good. You?";
|
| 254 |
}
|
| 255 |
+
|
| 256 |
+
// Joke - Direct joke, no intro
|
| 257 |
else if (lowerMessage.includes('joke') || lowerMessage.includes('मजाक')) {
|
| 258 |
response = useHindi ?
|
| 259 |
+
"डॉक्टर: आपको 1 दिन की दवा लेनी है।\nमरीज़: कब से?\nडॉक्टर: कब से क्या?" :
|
| 260 |
+
"Doctor: Take 1 day of medicine.\nPatient: Since when?\nDoctor: Since when what?";
|
| 261 |
}
|
| 262 |
+
|
| 263 |
+
// Story - Immediate full story
|
| 264 |
else if (lowerMessage.includes('कहानी') || lowerMessage.includes('story')) {
|
| 265 |
response = useHindi ?
|
| 266 |
+
"एक चूहा था जो रोज़ दाना बीनता। एक दिन उसे सोने का सिक्का मिला। खुश होकर उसने उसे छिपाया। दूसरे दिन चोर आया, सब ले गया। चूहे ने सीखा: अति का भला न बोले रे कोई।" :
|
| 267 |
+
"A mouse collected grain daily. One day he found a gold coin. He hid it happily. Next day a thief came, took everything. Mouse learned: Greed brings loss.";
|
| 268 |
}
|
| 269 |
+
|
| 270 |
+
// Poetry - Direct poem
|
| 271 |
+
else if (lowerMessage.includes('कविता') || lowerMessage.includes('poem')) {
|
| 272 |
response = useHindi ?
|
| 273 |
+
"चाँद सितारे आसमान में,\nचिड़ियाँ चहचहाती हैं,\nमन करता है उड़ जाऊँ मैं,\nइस अनंत नभ में।" :
|
| 274 |
+
"Moon and stars in the sky,\nBirds are chirping,\nI wish to fly,\nIn this endless sky.";
|
| 275 |
}
|
| 276 |
+
|
| 277 |
+
// Code - Only if explicitly asked "code likho"
|
| 278 |
+
else if (lowerMessage.includes('code likho') || lowerMessage.includes('कोड लिखो')) {
|
| 279 |
response = useHindi ?
|
| 280 |
+
"हाँ, लिख सकता हूँ। कौन सा code चाहिए?" :
|
| 281 |
+
"Yes, I can write code. What do you need?";
|
| 282 |
+
}
|
| 283 |
+
else if (lowerMessage.includes('code') || lowerMessage.includes('कोड')) {
|
| 284 |
+
response = useHindi ? "क्या आप चाहते हैं कि मैं code लिखूं?" : "Do you want me to write code?";
|
| 285 |
}
|
| 286 |
+
|
| 287 |
+
// Weather - Direct answer
|
| 288 |
else if (lowerMessage.includes('मौसम') || lowerMessage.includes('weather')) {
|
| 289 |
+
response = useHindi ? "माफ़ी, मौसम check नहीं कर पा रहा।" : "Sorry, can't check weather right now.";
|
| 290 |
}
|
| 291 |
+
|
| 292 |
+
// Time - Direct answer
|
| 293 |
else if (lowerMessage.includes('time') || lowerMessage.includes('समय') || lowerMessage.includes('टाइम')) {
|
| 294 |
const now = new Date();
|
| 295 |
const timeStr = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
|
| 296 |
+
response = timeStr;
|
| 297 |
}
|
| 298 |
+
|
| 299 |
+
// Help - Direct answer without lecturing
|
| 300 |
+
else if (lowerMessage.includes('help') || lowerMessage.includes('मदद')) {
|
| 301 |
+
response = useHindi ? "बोलिए, क्या चाहिए?" : "Tell me, what do you need?";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
}
|
| 303 |
+
|
| 304 |
+
// Math - Direct calculation
|
| 305 |
+
else if (/[\d+\-*/]/.test(userMessage)) {
|
| 306 |
+
try {
|
| 307 |
+
const result = eval(userMessage.replace(/[^0-9+\-*/().\s]/g, ''));
|
| 308 |
+
response = String(result);
|
| 309 |
+
} catch {
|
| 310 |
+
response = useHindi ? "गलत calculation" : "Invalid calculation";
|
| 311 |
+
}
|
| 312 |
}
|
| 313 |
+
|
| 314 |
+
// Failsafe for unclear inputs
|
| 315 |
else {
|
| 316 |
+
response = "थोड़ा साफ बताओ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
}
|
| 318 |
+
|
| 319 |
+
addMessage(response, 'ai');
|
| 320 |
isTyping = false;
|
| 321 |
}
|
| 322 |
// Toggle theme
|