Jason4Cheese commited on
Commit
bfb1a9c
verified
1 Parent(s): 44d5178

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # ----------------------------
5
+ # Load personality and knowledge
6
+ # ----------------------------
7
+ with open("personality.txt", "r") as f:
8
+ personality_core = f.read()
9
+
10
+ with open("quantum_knowledge.txt", "r") as f:
11
+ quantum_knowledge = f.read()
12
+
13
+ # ----------------------------
14
+ # Load language model
15
+ # ----------------------------
16
+ generator = pipeline("text-generation", model="gpt2") # can upgrade to a stronger model later
17
+
18
+ # ----------------------------
19
+ # Response function
20
+ # ----------------------------
21
+ def respond(user_input):
22
+ # Combine personality + quantum knowledge + user input
23
+ prompt = f"{personality_core}\n\nQuantum Knowledge Reference:\n{quantum_knowledge}\n\nUser said: {user_input}\nResponse:"
24
+ response = generator(prompt, max_length=300, do_sample=True)[0]['generated_text']
25
+ # Remove repeated prompt from the output
26
+ return response.replace(prompt, '').strip()
27
+
28
+ # ----------------------------
29
+ # Gradio interface
30
+ # ----------------------------
31
+ iface = gr.Interface(
32
+ fn=respond,
33
+ inputs=gr.Textbox(lines=2, placeholder="Say something..."),
34
+ outputs="text",
35
+ title="Quantum Activation Bot",
36
+ description="A bot infused with a quantum-aware essence."
37
+ )
38
+
39
+ iface.launch()