Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,54 +1,34 @@
|
|
| 1 |
-
|
| 2 |
-
from
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
{"
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
""
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
"TWICE, or BLACKPINK! They're known for catchy melodies and energetic choreography."
|
| 35 |
-
)
|
| 36 |
-
bot_reply = greeting + recommendation
|
| 37 |
-
history.append((message, bot_reply))
|
| 38 |
-
return "", history
|
| 39 |
-
|
| 40 |
-
# Fallback to BlenderBot for other questions
|
| 41 |
-
result = chatbot(message, max_length=100)
|
| 42 |
-
bot_reply = greeting + result[0]['generated_text']
|
| 43 |
-
history.append((message, bot_reply))
|
| 44 |
-
return "", history
|
| 45 |
-
|
| 46 |
-
iface = gr.ChatInterface(
|
| 47 |
-
fn=custom_kpop_response,
|
| 48 |
-
title="K-Pop Genie Chatbot",
|
| 49 |
-
description="Say hi! Ask for K-pop groups, or songs similar to your Western favorites."
|
| 50 |
-
)
|
| 51 |
-
|
| 52 |
-
if __name__ == "__main__":
|
| 53 |
-
iface.launch()
|
| 54 |
|
|
|
|
| 1 |
+
iimport gradio as gr
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
client = InferenceClient("microsoft/phi-4")
|
| 5 |
+
|
| 6 |
+
def respond(message, history):
|
| 7 |
+
messages = [{"role": "system", "content": "You are a friendly kpop chatbot."}]
|
| 8 |
+
if history:
|
| 9 |
+
messages.extend(history)
|
| 10 |
+
messages.append({"role": "user", "content": message})
|
| 11 |
+
response = client.chat_completion(messages, max_tokens=100)
|
| 12 |
+
return response['choices'][0]['message']['content'].strip()
|
| 13 |
+
|
| 14 |
+
spotify_iframe = """
|
| 15 |
+
<div style="max-width: 720px; margin: 12px auto;">
|
| 16 |
+
<iframe
|
| 17 |
+
data-testid="embed-iframe"
|
| 18 |
+
style="border-radius:12px"
|
| 19 |
+
src="https://open.spotify.com/embed/playlist/2EoheVFjqIxgJMb8VnDRtZ?utm_source=generator&theme=0"
|
| 20 |
+
width="100%"
|
| 21 |
+
height="352"
|
| 22 |
+
frameborder="0"
|
| 23 |
+
allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
|
| 24 |
+
loading="lazy">
|
| 25 |
+
</iframe>
|
| 26 |
+
</div>
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
with gr.Blocks() as demo:
|
| 30 |
+
chatbot = gr.ChatInterface(respond, type="messages", title="Kpop Song Hunters")
|
| 31 |
+
gr.HTML(spotify_iframe)
|
| 32 |
+
|
| 33 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|