File size: 2,157 Bytes
d948981 f477c9e d948981 806466e d948981 806466e f477c9e 806466e f477c9e 806466e f477c9e 806466e d948981 f477c9e 806466e f477c9e 806466e f477c9e 806466e d948981 806466e d948981 806466e f477c9e d948981 806466e f477c9e 806466e |
1 2 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import gradio as gr
from huggingface_hub import InferenceClient
#from sentence_transformers import SentenceTransformer
#import torch
#import numpy as np # import libraries
client = InferenceClient("microsoft/phi-4")
def respond(message, history):
#context = get_relevent_context(message, top_k=3)
messages = [{"role": "system", "content": "You are a friendly kpop expert chatbot."}]
if history:
messages.extend(history)
messages.append({"role": "user", "content": message})
response = client.chat_completion(
messages,
max_tokens=10000
)
return response['choices'][0]['message']['content'].strip()
chatbot = gr.ChatInterface(respond, type="messages")
title = "Kpop chatbot"
topics = """
<div class='big-paragraph'>
👋 Hey Kpop fan! <br>
Whether you’re new to the fandom or a longtime stan, I’m your ultimate Kpop buddy here to spill all the tea ☕️, trivia 🧠, and facts 📚 about your favorite groups and idols! 🌟<br><br>
Want to find your perfect group or bias? Just ask me! 💜🎤 <br><br>
Not only that, if you love an artist outside of Kpop, I can help you discover similar vibes and styles from the amazing world of Kpop too! 🎧✨<br><br>
So whether you’re looking for your first bias or your next obsession, I’ve got you covered. <br>
Let’s dive into the colorful, energetic, and ever-growing universe of Kpop together! 🚀💫
</div>
"""
disclaimer = ""
css = """
.big-text {
font-size: 100px;
font-weight: bold;
}
.big-paragraph {
font-size: 100px;
line-height: 3;
}
"""
with gr.Blocks() as chatbot:
with gr.Row():
with gr.Column(scale=1): # ← LEFT COLUMN (sidebar)
gr.Markdown(title) # Shows your "# :rocket: Lift Off :rocket: "heading
gr.Markdown(topics) # Shows your welcome text & bullet list
with gr.Column(scale=2): # ← RIGHT COLUMN (main chat area)
gr.ChatInterface(
fn=respond,
type="messages"
)
with gr.Row():
gr.Markdown(disclaimer) # Footer disclaimer text
chatbot.launch() |