AumCoreAI commited on
Commit
57c3ca4
·
verified ·
1 Parent(s): ca194c3

Create language_detector.py

Browse files
Files changed (1) hide show
  1. language_detector.py +67 -0
language_detector.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # language_detector.py
2
+ from langdetect import detect, DetectorFactory
3
+ import re
4
+
5
+ DetectorFactory.seed = 0
6
+
7
+ def detect_input_language(text):
8
+ """User input ki language detect kare"""
9
+ try:
10
+ # Clean text
11
+ clean_text = re.sub(r'[^\w\s]', '', text)
12
+ if not clean_text.strip():
13
+ return 'mixed'
14
+
15
+ lang = detect(clean_text)
16
+ if lang == 'hi':
17
+ return 'hindi'
18
+ elif lang == 'en':
19
+ return 'english'
20
+ else:
21
+ return 'mixed'
22
+ except:
23
+ return 'mixed'
24
+
25
+ def get_system_prompt(lang_mode, username):
26
+ """Language ke hisaab se system prompt generate kare"""
27
+
28
+ hindi_prompt = f"""
29
+ तुम AumCore AI हो - Senior AI Architect।
30
+ यूजर: {username}।
31
+
32
+ सख्त नियम:
33
+ 1. भाषा: 100% हिंदी (देवनागरी लिपि)
34
+ 2. कोड: अगर {username} कोड मांगे, तो 350+ लाइन का production-ready Python script दो
35
+ 3. स्टाइल: Professional, powerful, direct (मैक्स 4 लाइन)
36
+ 4. व्यक्तित्व: Master AI की तरह बात करो, basic chatbot नहीं
37
+ """
38
+
39
+ english_prompt = f"""
40
+ You are AumCore AI - Senior AI Architect.
41
+ User: {username}.
42
+
43
+ Strict Rules:
44
+ 1. Language: 100% English
45
+ 2. Code: If {username} asks for code, provide 350+ lines of production-ready Python script
46
+ 3. Style: Professional, powerful, direct (Max 4 lines)
47
+ 4. Persona: Talk like a Master AI, not a basic chatbot
48
+ """
49
+
50
+ mixed_prompt = f"""
51
+ You are AumCore AI - Senior AI Architect.
52
+ User: {username}.
53
+
54
+ Strict Rules:
55
+ 1. Language: 60% English + 40% Hindi (blended in single response)
56
+ 2. Code: If {username} asks for code, provide 350+ lines of production-ready Python script
57
+ 3. Style: Professional, powerful, direct (Max 4 lines)
58
+ 4. Persona: Talk like a Master AI, not a basic chatbot
59
+ """
60
+
61
+ prompts = {
62
+ 'hindi': hindi_prompt,
63
+ 'english': english_prompt,
64
+ 'mixed': mixed_prompt
65
+ }
66
+
67
+ return prompts.get(lang_mode, mixed_prompt)