Update app.py
Browse files
app.py
CHANGED
@@ -6,35 +6,15 @@ api_key=os.environ.get('qwen_API_KEY')
|
|
6 |
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
|
7 |
"""
|
8 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct",token=api_key)
|
9 |
-
latex_delimiters = [
|
10 |
-
"left": "\\(",
|
11 |
-
"right": "\\
|
12 |
-
"display": True
|
13 |
-
}, {
|
14 |
-
"left": "\\begin
|
15 |
-
"right": "\\end
|
16 |
-
"display": True
|
17 |
-
|
18 |
-
"left": "\\begin\{align\}",
|
19 |
-
"right": "\\end\{align\}",
|
20 |
-
"display": True
|
21 |
-
}, {
|
22 |
-
"left": "\\begin\{alignat\}",
|
23 |
-
"right": "\\end\{alignat\}",
|
24 |
-
"display": True
|
25 |
-
}, {
|
26 |
-
"left": "\\begin\{gather\}",
|
27 |
-
"right": "\\end\{gather\}",
|
28 |
-
"display": True
|
29 |
-
}, {
|
30 |
-
"left": "\\begin\{CD\}",
|
31 |
-
"right": "\\end\{CD\}",
|
32 |
-
"display": True
|
33 |
-
}, {
|
34 |
-
"left": "\\[",
|
35 |
-
"right": "\\]",
|
36 |
-
"display": True
|
37 |
-
}]
|
38 |
|
39 |
def respond(
|
40 |
message,
|
@@ -73,7 +53,7 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
73 |
"""
|
74 |
demo = gr.ChatInterface(
|
75 |
respond,
|
76 |
-
examples=[["你好,你是谁?"],["你是谁开发的?"]],
|
77 |
cache_examples=False,
|
78 |
title="千问2.5-72B",
|
79 |
description="千问2.5-72B聊天机器人",
|
@@ -81,16 +61,10 @@ demo = gr.ChatInterface(
|
|
81 |
gr.Textbox(value="You are Qwen, created by Alibaba Cloud. You are a helpful assistant.", label="System message"),
|
82 |
gr.Slider(minimum=1, maximum=8888, value=2048, 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 |
)
|
93 |
|
94 |
-
|
95 |
if __name__ == "__main__":
|
96 |
demo.launch()
|
|
|
6 |
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
|
7 |
"""
|
8 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct",token=api_key)
|
9 |
+
latex_delimiters = [
|
10 |
+
{"left": "\\(", "right": "\\)", "display": False},
|
11 |
+
{"left": "\\[", "right": "\\]", "display": True},
|
12 |
+
{"left": "\\begin{equation}", "right": "\\end{equation}", "display": True},
|
13 |
+
{"left": "\\begin{align}", "right": "\\end{align}", "display": True},
|
14 |
+
{"left": "\\begin{alignat}", "right": "\\end{alignat}", "display": True},
|
15 |
+
{"left": "\\begin{gather}", "right": "\\end{gather}", "display": True},
|
16 |
+
{"left": "\\begin{CD}", "right": "\\end{CD}", "display": True},
|
17 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
def respond(
|
20 |
message,
|
|
|
53 |
"""
|
54 |
demo = gr.ChatInterface(
|
55 |
respond,
|
56 |
+
examples=[["你好,你是谁?"], ["你是谁开发的?"]],
|
57 |
cache_examples=False,
|
58 |
title="千问2.5-72B",
|
59 |
description="千问2.5-72B聊天机器人",
|
|
|
61 |
gr.Textbox(value="You are Qwen, created by Alibaba Cloud. You are a helpful assistant.", label="System message"),
|
62 |
gr.Slider(minimum=1, maximum=8888, value=2048, step=1, label="Max new tokens"),
|
63 |
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
64 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)"),
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
],
|
66 |
+
chatbot=gr.HTML("<script src='https://polyfill.io/v3/polyfill.min.js?features=es6'></script><script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'></script>")
|
67 |
)
|
68 |
|
|
|
69 |
if __name__ == "__main__":
|
70 |
demo.launch()
|