File size: 1,735 Bytes
020bda4
9c1d33d
2aa28f8
 
d6d3320
2aa28f8
 
 
 
 
 
020bda4
3cf038e
69fd63d
d6d3320
020bda4
 
2aa28f8
 
 
d6d3320
2aa28f8
 
d6d3320
922fb61
 
 
 
d6d3320
922fb61
 
 
 
 
 
2aa28f8
 
 
 
 
 
 
 
 
 
 
 
 
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
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 = """
Welcone to Kpop song Hunters!!
"""
disclaimer = ""
custom_css = """
.gradio-container { background-color: #FFF5F2 !important; }
.gradio-chat { background-color: #A6B28B !important; }
.chat-interface { background-color: #F5C9B0 !important; }
.chat-message { background-color: #F9F6F3 !important; }
"""

with gr.Blocks(css=custom_css) as demo:
    gr.Markdown("Welcome to K‑Pop Chatbot!")
    gr.ChatInterface(fn=respond, type="messages")
demo.launch()

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()