Lyiosvf commited on
Commit
f477c9e
·
verified ·
1 Parent(s): 6cfd209

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -12
app.py CHANGED
@@ -1,35 +1,56 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
- from sentence_transformers import SentenceTransformer
4
- import torch
5
- import numpy as np # import libraries
6
-
7
 
8
  client = InferenceClient("microsoft/phi-4")
9
 
10
  def respond(message, history):
11
- #context = get_relevent_context(message, top_k=3)
12
-
13
-
14
-
15
- messages = [{"role": "system", "content": "You are a friendly chatbot."}]
16
-
17
  if history:
18
  messages.extend(history)
 
19
  messages.append({"role": "user", "content": message})
 
20
  response = client.chat_completion(
21
  messages,
22
- max_tokens=100
23
  )
 
24
  return response['choices'][0]['message']['content'].strip()
 
25
  chatbot = gr.ChatInterface(respond, type="messages")
26
 
27
  title = "Kpop chatbot"
28
 
29
  topics = """
30
- Welcome to Kpop Song Hunters!
 
 
 
 
 
 
 
31
  """
32
  disclaimer = ""
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  with gr.Blocks() as chatbot:
34
  with gr.Row():
35
  with gr.Column(scale=1): # ← LEFT COLUMN (sidebar)
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ #from sentence_transformers import SentenceTransformer
4
+ #import torch
5
+ #import numpy as np # import libraries
 
6
 
7
  client = InferenceClient("microsoft/phi-4")
8
 
9
  def respond(message, history):
10
+ #context = get_relevent_context(message, top_k=3)
11
+
12
+ messages = [{"role": "system", "content": "You are a friendly kpop expert chatbot."}]
13
+
 
 
14
  if history:
15
  messages.extend(history)
16
+
17
  messages.append({"role": "user", "content": message})
18
+
19
  response = client.chat_completion(
20
  messages,
21
+ max_tokens=10000
22
  )
23
+
24
  return response['choices'][0]['message']['content'].strip()
25
+
26
  chatbot = gr.ChatInterface(respond, type="messages")
27
 
28
  title = "Kpop chatbot"
29
 
30
  topics = """
31
+ <div class='big-paragraph'>
32
+ 👋 Hey Kpop fan! <br>
33
+ 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>
34
+ Want to find your perfect group or bias? Just ask me! 💜🎤 <br><br>
35
+ 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>
36
+ So whether you’re looking for your first bias or your next obsession, I’ve got you covered. <br>
37
+ Let’s dive into the colorful, energetic, and ever-growing universe of Kpop together! 🚀💫
38
+ </div>
39
  """
40
  disclaimer = ""
41
+
42
+ css = """
43
+ .big-text {
44
+ font-size: 100px;
45
+ font-weight: bold;
46
+ }
47
+ .big-paragraph {
48
+ font-size: 100px;
49
+ line-height: 3;
50
+ }
51
+ """
52
+
53
+
54
  with gr.Blocks() as chatbot:
55
  with gr.Row():
56
  with gr.Column(scale=1): # ← LEFT COLUMN (sidebar)