Spaces:
Running
on
Zero
Running
on
Zero
Nihal Nayak
commited on
Commit
·
0e24f0d
1
Parent(s):
4a8131a
wip
Browse files
app.py
CHANGED
@@ -7,23 +7,23 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
7 |
"""
|
8 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
9 |
|
|
|
10 |
@spaces.GPU
|
11 |
def respond(
|
12 |
message,
|
13 |
-
|
14 |
-
system_message,
|
15 |
max_tokens,
|
16 |
temperature,
|
17 |
top_p,
|
18 |
):
|
19 |
-
messages = [{"role": "system", "content": system_message}]
|
20 |
-
|
21 |
-
for val in history:
|
22 |
-
if val[0]:
|
23 |
-
messages.append({"role": "user", "content": val[0]})
|
24 |
-
if val[1]:
|
25 |
-
messages.append({"role": "assistant", "content": val[1]})
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
messages.append({"role": "user", "content": message})
|
28 |
|
29 |
response = ""
|
@@ -40,13 +40,52 @@ def respond(
|
|
40 |
response += token
|
41 |
yield response
|
42 |
|
|
|
43 |
"""
|
44 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
45 |
"""
|
46 |
-
demo = gr.ChatInterface(
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
|
|
|
|
|
|
|
|
50 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
51 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
52 |
gr.Slider(
|
@@ -57,8 +96,10 @@ demo = gr.ChatInterface(
|
|
57 |
label="Top-p (nucleus sampling)",
|
58 |
),
|
59 |
],
|
|
|
|
|
60 |
)
|
61 |
|
62 |
|
63 |
if __name__ == "__main__":
|
64 |
-
demo.launch()
|
|
|
7 |
"""
|
8 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
9 |
|
10 |
+
|
11 |
@spaces.GPU
|
12 |
def respond(
|
13 |
message,
|
14 |
+
task_type,
|
|
|
15 |
max_tokens,
|
16 |
temperature,
|
17 |
top_p,
|
18 |
):
|
19 |
+
# messages = [{"role": "system", "content": system_message}]
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
# for val in history:
|
22 |
+
# if val[0]:
|
23 |
+
# messages.append({"role": "user", "content": val[0]})
|
24 |
+
# if val[1]:
|
25 |
+
# messages.append({"role": "assistant", "content": val[1]})
|
26 |
+
messages = []
|
27 |
messages.append({"role": "user", "content": message})
|
28 |
|
29 |
response = ""
|
|
|
40 |
response += token
|
41 |
yield response
|
42 |
|
43 |
+
|
44 |
"""
|
45 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
46 |
"""
|
47 |
+
# demo = gr.ChatInterface(
|
48 |
+
# respond,
|
49 |
+
# additional_inputs=[
|
50 |
+
# gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
51 |
+
# gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
52 |
+
# gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
53 |
+
# gr.Slider(
|
54 |
+
# minimum=0.1,
|
55 |
+
# maximum=1.0,
|
56 |
+
# value=0.95,
|
57 |
+
# step=0.05,
|
58 |
+
# label="Top-p (nucleus sampling)",
|
59 |
+
# ),
|
60 |
+
# ],
|
61 |
+
# )
|
62 |
+
task_types = [
|
63 |
+
"extractive question answering",
|
64 |
+
"multiple-choice question answering",
|
65 |
+
"question generation",
|
66 |
+
"question answering without choices",
|
67 |
+
"yes-no question answering",
|
68 |
+
"coreference resolution",
|
69 |
+
"paraphrase generation",
|
70 |
+
"paraphrase identification",
|
71 |
+
"sentence completion",
|
72 |
+
"sentiment",
|
73 |
+
"summarization",
|
74 |
+
"text generation",
|
75 |
+
"topic classification",
|
76 |
+
"word sense disambiguation",
|
77 |
+
"textual entailment",
|
78 |
+
"natural language inference",
|
79 |
+
]
|
80 |
+
|
81 |
+
demo = gr.Interface(
|
82 |
+
fn=respond,
|
83 |
+
inputs=[
|
84 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
85 |
+
gr.Dropdown(task_types, label="Task type"),
|
86 |
+
],
|
87 |
+
outputs=gr.Textbox(label="Response"),
|
88 |
+
additional_inputs=[
|
89 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
90 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
91 |
gr.Slider(
|
|
|
96 |
label="Top-p (nucleus sampling)",
|
97 |
),
|
98 |
],
|
99 |
+
title="Zephyr Chatbot",
|
100 |
+
description="A chatbot that uses the Hugging Face Zephyr model.",
|
101 |
)
|
102 |
|
103 |
|
104 |
if __name__ == "__main__":
|
105 |
+
demo.launch()
|