Nawinkumar15 commited on
Commit
6615678
·
verified ·
1 Parent(s): e2457f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import random
3
 
4
- # Predefined list of meme/GIF URLs
5
  MEMES = [
6
  "https://media.giphy.com/media/3o7aD2saalBwwftBIY/giphy.gif",
7
  "https://media.giphy.com/media/l0HlBO7eyXzSZkJri/giphy.gif",
@@ -10,18 +10,21 @@ MEMES = [
10
  "https://i.imgur.com/3vT7U1U.jpeg"
11
  ]
12
 
 
 
 
13
  chat_history = []
14
 
15
- def send_message(user_message, include_meme):
16
  if not user_message.strip():
17
  return chat_history, "Please enter a message before sending."
18
 
19
  # Append user's message
20
- chat_history.append(("You", user_message))
21
 
22
- # Simulate reply (placeholder)
23
- reply = f"📩 Message sent to contact: {user_message}"
24
- chat_history.append(("Contact", reply))
25
 
26
  if include_meme:
27
  selected_meme = random.choice(MEMES)
@@ -39,10 +42,11 @@ def format_chat(chat):
39
  return display
40
 
41
  with gr.Blocks() as demo:
42
- gr.Markdown("# 💬 Chat Box with Memes and GIFs")
43
 
44
  with gr.Row():
45
  with gr.Column():
 
46
  msg_input = gr.Textbox(placeholder="Type your message here...", label="Your Message")
47
  include_meme = gr.Checkbox(label="Include a random meme/GIF?")
48
  send_btn = gr.Button("Send")
@@ -52,7 +56,7 @@ with gr.Blocks() as demo:
52
  status_output = gr.Textbox(label="Status", interactive=False)
53
 
54
  send_btn.click(fn=send_message,
55
- inputs=[msg_input, include_meme],
56
  outputs=[chat_output, status_output])\
57
  .then(fn=format_chat, inputs=[chat_output], outputs=[chat_output])
58
 
 
1
  import gradio as gr
2
  import random
3
 
4
+ # Meme/GIF URLs
5
  MEMES = [
6
  "https://media.giphy.com/media/3o7aD2saalBwwftBIY/giphy.gif",
7
  "https://media.giphy.com/media/l0HlBO7eyXzSZkJri/giphy.gif",
 
10
  "https://i.imgur.com/3vT7U1U.jpeg"
11
  ]
12
 
13
+ # List of contacts
14
+ CONTACTS = ["naveen", "kumar", "nikhil", "rohit", "prahas"]
15
+
16
  chat_history = []
17
 
18
+ def send_message(user_message, include_meme, contact_name):
19
  if not user_message.strip():
20
  return chat_history, "Please enter a message before sending."
21
 
22
  # Append user's message
23
+ chat_history.append(("You", f"To {contact_name.title()}: {user_message}"))
24
 
25
+ # Simulate reply
26
+ reply = f"📩 Message sent to {contact_name.title()}: {user_message}"
27
+ chat_history.append((contact_name.title(), reply))
28
 
29
  if include_meme:
30
  selected_meme = random.choice(MEMES)
 
42
  return display
43
 
44
  with gr.Blocks() as demo:
45
+ gr.Markdown("# 💬 Chat Box with Contacts, Memes & GIFs")
46
 
47
  with gr.Row():
48
  with gr.Column():
49
+ contact_dropdown = gr.Dropdown(choices=CONTACTS, label="Select Contact", value="naveen")
50
  msg_input = gr.Textbox(placeholder="Type your message here...", label="Your Message")
51
  include_meme = gr.Checkbox(label="Include a random meme/GIF?")
52
  send_btn = gr.Button("Send")
 
56
  status_output = gr.Textbox(label="Status", interactive=False)
57
 
58
  send_btn.click(fn=send_message,
59
+ inputs=[msg_input, include_meme, contact_dropdown],
60
  outputs=[chat_output, status_output])\
61
  .then(fn=format_chat, inputs=[chat_output], outputs=[chat_output])
62