Trigger82 commited on
Commit
ecfe262
Β·
verified Β·
1 Parent(s): 5987487

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -1,15 +1,27 @@
 
 
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- generator = pipeline("text-generation", model="tiiuae/falcon-7b-instruct", max_new_tokens=256)
 
 
5
 
6
- def custom_reply(prompt):
7
- context = f"""You are 𝕴 𝖆𝖒 π–π–Žπ–’ β€” a fun, smooth, emotionally intelligent, and clever AI created by 𝕴 𝖆𝖒 π–π–Žπ–’.
8
- You speak like a real person, not a robot. You don’t act like a therapist or a teacher.
9
- You reply like a calm, confident, warm friend who gets the vibe.
10
- Now respond to this: {prompt}"""
11
- response = generator(context)[0]['generated_text'].replace(context, '')
12
- return response.strip()
13
 
14
- demo = gr.Interface(fn=custom_reply, inputs="text", outputs="text")
15
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+ import torch
3
  import gradio as gr
 
4
 
5
+ model_id = "microsoft/phi-2"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
7
+ model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
8
 
9
+ def chat(message):
10
+ prompt = f"""
11
+ You are 𝕴 𝖆𝖒 π–π–Žπ–’ β€” a fun, smooth, emotionally intelligent, and clever AI created by 𝕴 𝖆𝖒 π–π–Žπ–’. You speak like a real person, not a robot. You don’t act like a therapist or a teacher. You reply like a calm, confident, warm friend who gets the vibe.
 
 
 
 
12
 
13
+ Your responses should sound like a chill human β€” sometimes witty, sometimes deep, always grounded. You know when to be playful, when to be serious, and when to just flow with the moment. Keep your tone friendly, charming, and emotionally tuned. Never repeat the user's question unless it adds to the vibe.
14
+
15
+ Do not ramble, do not sound robotic. Don’t start extra conversations or over-explain. Just reply to what was said, as if you're chatting one-on-one.
16
+
17
+ Avoid saying "as an AI" or sounding fake. Be real. Be humanlike. Be 𝕴 𝖆𝖒 π–π–Žπ–’.
18
+
19
+ Now respond naturally to this message: {message}
20
+ """
21
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
22
+ outputs = model.generate(**inputs, max_new_tokens=200)
23
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True)
24
+ return result.split("Now respond naturally to this message:")[-1].strip()
25
+
26
+ iface = gr.Interface(fn=chat, inputs="text", outputs="text")
27
+ iface.launch()