faizah2512 commited on
Commit
72b515c
·
verified ·
1 Parent(s): a460a60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -22
app.py CHANGED
@@ -1,12 +1,8 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- """
5
- For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
- """
7
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
8
 
9
-
10
  def respond(
11
  message,
12
  history: list[tuple[str, str]],
@@ -39,25 +35,62 @@ def respond(
39
  response += token
40
  yield response
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  """
43
- For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
44
- """
45
- demo = gr.ChatInterface(
46
- respond,
47
- additional_inputs=[
48
- gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
49
- gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
50
- gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
51
- gr.Slider(
52
- minimum=0.1,
53
- maximum=1.0,
54
- value=0.95,
55
- step=0.05,
56
- label="Top-p (nucleus sampling)",
57
- ),
58
- ],
59
- )
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  if __name__ == "__main__":
63
- demo.launch()
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
 
 
 
4
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
5
 
 
6
  def respond(
7
  message,
8
  history: list[tuple[str, str]],
 
35
  response += token
36
  yield response
37
 
38
+ css = """
39
+ /* Customize the background color and text color */
40
+ body {
41
+ background-color: #f0f0f0;
42
+ color: #333333;
43
+ }
44
+
45
+ /* Customize the chat window */
46
+ .gradio-chatbox {
47
+ border: 1px solid #dddddd;
48
+ background-color: #ffffff;
49
+ border-radius: 10px;
50
+ }
51
+
52
+ /* Customize the user input and response */
53
+ .gradio-chat-message-user {
54
+ background-color: #e1f5fe;
55
+ color: #01579b;
56
+ }
57
+
58
+ .gradio-chat-message-assistant {
59
+ background-color: #fff3e0;
60
+ color: #ef6c00;
61
+ }
62
+
63
+ /* Customize the sliders and text boxes */
64
+ .gradio-input {
65
+ background-color: #ffffff;
66
+ border: 1px solid #dddddd;
67
+ border-radius: 5px;
68
+ padding: 5px;
69
+ color: #333333;
70
+ }
71
+
72
+ .gradio-slider {
73
+ color: #01579b;
74
+ }
75
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
 
77
+ with gr.Blocks(css=css) as demo:
78
+ chat_interface = gr.ChatInterface(
79
+ respond,
80
+ additional_inputs=[
81
+ gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
82
+ gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
83
+ gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
84
+ gr.Slider(
85
+ minimum=0.1,
86
+ maximum=1.0,
87
+ value=0.95,
88
+ step=0.05,
89
+ label="Top-p (nucleus sampling)",
90
+ ),
91
+ ],
92
+ theme="default",
93
+ )
94
 
95
  if __name__ == "__main__":
96
+ demo.launch()