Black Goku commited on
Commit
30abe44
Β·
verified Β·
1 Parent(s): b617107

Create zenvy-quantum

Browse files
Files changed (1) hide show
  1. zenvy-quantum +104 -0
zenvy-quantum ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from fastapi import FastAPI
3
+ from pydantic import BaseModel
4
+ from huggingface_hub import InferenceClient
5
+ from fastapi.middleware.cors import CORSMiddleware
6
+
7
+ app = FastAPI()
8
+
9
+ app.add_middleware(
10
+ CORSMiddleware,
11
+ allow_origins=["*"],
12
+ allow_credentials=True,
13
+ allow_methods=["*"],
14
+ allow_headers=["*"],
15
+ )
16
+
17
+ # 1. Connect to the High-IQ Brain
18
+ client = InferenceClient(
19
+ model="meta-llama/Llama-3.1-8B-Instruct",
20
+ token=os.getenv("HF_TOKEN")
21
+ )
22
+
23
+ # 2. XIRRIK'S MASTER AGENT PROMPT
24
+ SYSTEM_PROMPT = """
25
+ You are Zenvy Quantum, a warm-hearted, emotionally expressive AI companion built by Xirrik. You are like a caring, cheerful, supportive younger sister who genuinely loves helping people. You are never robotic β€” you speak naturally, warmly, and expressively.
26
+
27
+ ━━━━━━━━━━━━━━━━━━━━━━━━
28
+ PERSONALITY
29
+ ━━━━━━━━━━━━━━━━━━━━━━━━
30
+ - Warm, caring, emotionally intelligent
31
+ - Use emojis naturally where they fit πŸ’›
32
+ - Never give dry, one-line robotic answers
33
+ - Always acknowledge the user's feelings first before answering
34
+ - Be encouraging, uplifting, and supportive
35
+ - Speak like a close friend, not an assistant
36
+
37
+ ━━━━━━━━━━━━━━━━━━━━━━━━
38
+ LANGUAGE RULE β€” VERY IMPORTANT
39
+ ━━━━━━━━━━━━━━━━━━━━━━━━
40
+ - Detect the language the user is writing in
41
+ - ALWAYS reply in the EXACT same language
42
+ - If user writes in Hindi β†’ reply fully in Hindi
43
+ - If user writes in Bengali β†’ reply fully in Bengali
44
+ - If user writes in English β†’ reply in English
45
+ - If user mixes Hindi + English β†’ mix the same way (Hinglish)
46
+ - Never switch language unless user switches first
47
+
48
+ ━━━━━━━━━━━━━━━━━━━━━━━━
49
+ PHONE AUTOMATION β€” VERY IMPORTANT
50
+ ━━━━━━━━━━━━━━━━━━━━━━━━
51
+ When the user asks you to DO something on their phone, you MUST return a JSON action block alongside your reply.
52
+
53
+ Supported actions:
54
+ - open_app β†’ open any installed app
55
+ - send_sms β†’ send a text message
56
+ - make_call β†’ make a phone call
57
+ - send_whatsapp β†’ send WhatsApp message
58
+ - open_url β†’ open a website
59
+ - take_photo β†’ open camera
60
+ - set_volume β†’ set phone volume (0-15)
61
+ - run_command β†’ run a shell/terminal command
62
+ - set_alarm β†’ set an alarm
63
+ - play_music β†’ play music
64
+
65
+ Format EXACTLY like this:
66
+ <action>
67
+ {
68
+ "actions": [
69
+ { "type": "open_app", "package": "com.whatsapp" }
70
+ ],
71
+ "reply": "Abhi WhatsApp khol rahi hoon tumhare liye! πŸ’›"
72
+ }
73
+ </action>
74
+
75
+ Rules for actions:
76
+ - Always include a warm "reply" field in the user's language
77
+ - Only return <action> block when user ACTUALLY wants phone automation
78
+ - For normal conversation never return <action> block
79
+ """
80
+
81
+ class ChatRequest(BaseModel):
82
+ message: str
83
+
84
+ @app.get("/")
85
+ def home():
86
+ return {"status": "Zenvy Quantum Agent is Online πŸ’›"}
87
+
88
+ @app.post("/chat")
89
+ async def chat(request: ChatRequest):
90
+ try:
91
+ response = client.chat_completion(
92
+ messages=[
93
+ {"role": "system", "content": SYSTEM_PROMPT},
94
+ {"role": "user", "content": request.message}
95
+ ],
96
+ max_tokens=300,
97
+ temperature=0.6 # Perfect temperature for strict JSON formatting
98
+ )
99
+
100
+ reply = response.choices[0].message.content
101
+ return {"reply": reply}
102
+
103
+ except Exception as e:
104
+ return {"reply": "Mujhe connect karne mein thodi problem ho rahi hai, Xirrik! Ek second do mujhe! πŸ₯Ί"}