Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# Load available memes/gifs from a folder
|
| 15 |
-
MEME_FOLDER = "assets/memes"
|
| 16 |
-
memes = [os.path.join(MEME_FOLDER, f) for f in os.listdir(MEME_FOLDER) if f.endswith((".gif", ".jpg", ".png"))]
|
| 17 |
|
| 18 |
chat_history = []
|
| 19 |
|
|
@@ -24,16 +19,13 @@ def send_message(user_message, include_meme):
|
|
| 24 |
# Append user's message
|
| 25 |
chat_history.append(("You", user_message))
|
| 26 |
|
| 27 |
-
# Simulate
|
| 28 |
-
reply = f"Message sent to
|
| 29 |
chat_history.append(("Contact", reply))
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
if include_meme and memes:
|
| 34 |
-
selected_meme = random.choice(memes)
|
| 35 |
chat_history.append(("Meme", selected_meme))
|
| 36 |
-
meme_output = selected_meme
|
| 37 |
|
| 38 |
return chat_history, ""
|
| 39 |
|
|
@@ -41,13 +33,13 @@ def format_chat(chat):
|
|
| 41 |
display = ""
|
| 42 |
for sender, message in chat:
|
| 43 |
if sender == "Meme":
|
| 44 |
-
display += f"<img src='
|
| 45 |
else:
|
| 46 |
display += f"<b>{sender}:</b> {message}<br>"
|
| 47 |
return display
|
| 48 |
|
| 49 |
with gr.Blocks() as demo:
|
| 50 |
-
gr.Markdown("# 💬 Chat Box
|
| 51 |
|
| 52 |
with gr.Row():
|
| 53 |
with gr.Column():
|
|
|
|
| 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",
|
| 8 |
+
"https://media.giphy.com/media/13HgwGsXF0aiGY/giphy.gif",
|
| 9 |
+
"https://i.imgur.com/5QF9xO7.jpg",
|
| 10 |
+
"https://i.imgur.com/3vT7U1U.jpeg"
|
| 11 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
chat_history = []
|
| 14 |
|
|
|
|
| 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)
|
|
|
|
|
|
|
| 28 |
chat_history.append(("Meme", selected_meme))
|
|
|
|
| 29 |
|
| 30 |
return chat_history, ""
|
| 31 |
|
|
|
|
| 33 |
display = ""
|
| 34 |
for sender, message in chat:
|
| 35 |
if sender == "Meme":
|
| 36 |
+
display += f"<img src='{message}' width='200px'><br>"
|
| 37 |
else:
|
| 38 |
display += f"<b>{sender}:</b> {message}<br>"
|
| 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():
|