Testing / app.py
Lyiosvf's picture
Update app.py
f477c9e verified
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()