VishekKumar1 commited on
Commit
9bffd62
·
verified ·
1 Parent(s): 5d340e0

Recheck yah acche se response nahin de raha aur isko bolo kuchh aur to yah rispos kuchh aur de raha hai

Browse files
Files changed (1) hide show
  1. script.js +61 -24
script.js CHANGED
@@ -285,37 +285,74 @@ async function generateAIResponse(userMessage) {
285
  lowerMessage.endsWith('कब') || lowerMessage.endsWith('कहाँ') || lowerMessage.endsWith('क्यों') ||
286
  lowerMessage.endsWith('what') || lowerMessage.endsWith('who') || lowerMessage.endsWith('when') ||
287
  lowerMessage.endsWith('where') || lowerMessage.endsWith('why')) {
288
- response = useHindi ?
289
- "यह एक अच्छा सवाल है! मैं आपकी मदद करने की कोशिश करूंगा। क्या आप और विवरण दे सकते हैं?" :
290
- "That's a good question! I'll try to help you. Can you provide more details?";
291
- }
292
- else if (lowerMessage.includes('help') || lowerMessage.includes('मदद')) {
293
- response = useHindi ?
294
- "मैं आपकी कैसे मदद कर सकता हूँ? आप मुझसे बातचीत कर सकते हैं, सवाल पूछ सकते हैं, मजाक सुन सकते हैं, कहानियाँ सुन सकते हैं, या कोडिंग सहायता ले सकते हैं!" :
295
- "How can I help you? You can chat with me, ask questions, hear jokes, listen to stories, or get coding help!";
296
- }
297
- else {
298
- // Generic but more engaging responses
299
  const hindiResponses = [
300
- "मैं समझ या! बताइ...",
301
- "बहुत अच! क्या आप और कुछ पूछना चाहेंगे?",
302
- "धन्यवाद इस जानकरी के लिए!",
303
- "मैं आपकी बात समझ रहा हूँ।",
304
- "यह दिलचस्प है! कृपया आगे बताएं।"
305
  ];
306
  const englishResponses = [
307
- "I understand! Tell me more...",
308
- "That's great! Would you like to ask something else?",
309
- "Thank you for sharing that!",
310
- "I'm following what you're saying.",
311
- "That's interesting! Please continue."
312
  ];
313
 
314
- const randomIndex = Math.floor(Math.random() * 5);
315
  response = useHindi ? hindiResponses[randomIndex] : englishResponses[randomIndex];
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
317
-
318
- addMessage(response, 'ai');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  isTyping = false;
320
  }
321
  // Toggle theme
 
285
  lowerMessage.endsWith('कब') || lowerMessage.endsWith('कहाँ') || lowerMessage.endsWith('क्यों') ||
286
  lowerMessage.endsWith('what') || lowerMessage.endsWith('who') || lowerMessage.endsWith('when') ||
287
  lowerMessage.endsWith('where') || lowerMessage.endsWith('why')) {
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
+ else if (lowerMessage.includes('help') || lowerMessage.includes('मदद')) {
316
+ response = useHindi ?
317
+ "मैं आपकी कैसे मदद कर सकता हूँ? आप मुझसे बातचीत कर सकते हैं, सवाल पूछ सकते हैं, मजाक सुन सकते हैं, कहानियाँ सुन सकते हैं, या कोडिंग सहायता ले सकते हैं!" :
318
+ "How can I help you? You can chat with me, ask questions, hear jokes, listen to stories, or get coding help!";
319
+ }
320
+ else {
321
+ // More specific and contextual responses
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
+ addMessage(response, 'ai');
356
  isTyping = false;
357
  }
358
  // Toggle theme