segun2346 commited on
Commit
ce29da3
·
1 Parent(s): 10929b1

adding files

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load text generation model
5
+ chatbot = pipeline("text-generation", model="distilgpt2")
6
+
7
+ def respond(message, history):
8
+ # Combine chat history into context
9
+ prompt = ""
10
+ for user, bot in history:
11
+ prompt += f"User: {user}\nBot: {bot}\n"
12
+ prompt += f"User: {message}\nBot:"
13
+
14
+ # Generate response
15
+ response = chatbot(
16
+ prompt,
17
+ max_length=200,
18
+ do_sample=True,
19
+ temperature=0.7
20
+ )
21
+
22
+ bot_reply = response[0]["generated_text"].split("Bot:")[-1].strip()
23
+ return bot_reply
24
+
25
+ # WhatsApp-style interface
26
+ demo = gr.ChatInterface(
27
+ respond,
28
+ title="💬 WhatsApp-Style AI Chatbot",
29
+ description="Type a message and chat with AI"
30
+ )
31
+
32
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch