Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,7 @@ def format_math(text):
|
|
| 16 |
text = text.replace(r"\(", "$").replace(r"\)", "$")
|
| 17 |
return text
|
| 18 |
|
| 19 |
-
|
| 20 |
def generate_response(user_message, max_tokens, temperature, top_p, history_state):
|
| 21 |
if not user_message.strip():
|
| 22 |
return history_state, history_state
|
|
@@ -45,9 +45,9 @@ def generate_response(user_message, max_tokens, temperature, top_p, history_stat
|
|
| 45 |
"max_new_tokens": int(max_tokens),
|
| 46 |
"do_sample": True,
|
| 47 |
"temperature": temperature,
|
| 48 |
-
"top_k": 50,
|
| 49 |
"top_p": top_p,
|
| 50 |
-
"repetition_penalty": 1.0,
|
| 51 |
"pad_token_id": tokenizer.eos_token_id,
|
| 52 |
"streamer": streamer,
|
| 53 |
}
|
|
@@ -102,37 +102,22 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 102 |
with gr.Row():
|
| 103 |
with gr.Column(scale=1):
|
| 104 |
gr.Markdown("### Settings")
|
| 105 |
-
max_tokens_slider = gr.Slider(
|
| 106 |
-
minimum=6144,
|
| 107 |
-
maximum=32768,
|
| 108 |
-
step=1024,
|
| 109 |
-
value=16384,
|
| 110 |
-
label="Max Tokens"
|
| 111 |
-
)
|
| 112 |
with gr.Accordion("Advanced Settings", open=False):
|
| 113 |
-
temperature_slider = gr.Slider(
|
| 114 |
-
|
| 115 |
-
maximum=2.0,
|
| 116 |
-
value=0.6,
|
| 117 |
-
label="Temperature"
|
| 118 |
-
)
|
| 119 |
-
top_p_slider = gr.Slider(
|
| 120 |
-
minimum=0.1,
|
| 121 |
-
maximum=1.0,
|
| 122 |
-
value=0.95,
|
| 123 |
-
label="Top-p"
|
| 124 |
-
)
|
| 125 |
|
| 126 |
with gr.Column(scale=4):
|
| 127 |
chatbot = gr.Chatbot(label="Chat", type="messages")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
with gr.Row():
|
| 129 |
-
user_input = gr.Textbox(
|
| 130 |
-
label="User Input",
|
| 131 |
-
placeholder="Type your question here...",
|
| 132 |
-
scale=3
|
| 133 |
-
)
|
| 134 |
submit_button = gr.Button("Send", variant="primary", scale=1)
|
| 135 |
-
#stop_button = gr.Button("Stop", variant="stop", scale=1, interactive=True)
|
| 136 |
clear_button = gr.Button("Clear", scale=1)
|
| 137 |
gr.Markdown("**Try these examples:**")
|
| 138 |
with gr.Row():
|
|
@@ -172,4 +157,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 172 |
outputs=user_input
|
| 173 |
)
|
| 174 |
|
| 175 |
-
demo.launch(share=True, ssr_mode=False)
|
|
|
|
| 16 |
text = text.replace(r"\(", "$").replace(r"\)", "$")
|
| 17 |
return text
|
| 18 |
|
| 19 |
+
#@spaces.GPU(duration=60)
|
| 20 |
def generate_response(user_message, max_tokens, temperature, top_p, history_state):
|
| 21 |
if not user_message.strip():
|
| 22 |
return history_state, history_state
|
|
|
|
| 45 |
"max_new_tokens": int(max_tokens),
|
| 46 |
"do_sample": True,
|
| 47 |
"temperature": temperature,
|
| 48 |
+
"top_k": 50,
|
| 49 |
"top_p": top_p,
|
| 50 |
+
"repetition_penalty": 1.0,
|
| 51 |
"pad_token_id": tokenizer.eos_token_id,
|
| 52 |
"streamer": streamer,
|
| 53 |
}
|
|
|
|
| 102 |
with gr.Row():
|
| 103 |
with gr.Column(scale=1):
|
| 104 |
gr.Markdown("### Settings")
|
| 105 |
+
max_tokens_slider = gr.Slider(minimum=6144, maximum=32768, step=1024, value=16384, label="Max Tokens")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
with gr.Accordion("Advanced Settings", open=False):
|
| 107 |
+
temperature_slider = gr.Slider(minimum=0.1, maximum=2.0, value=0.6, label="Temperature")
|
| 108 |
+
top_p_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, label="Top-p")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
with gr.Column(scale=4):
|
| 111 |
chatbot = gr.Chatbot(label="Chat", type="messages")
|
| 112 |
+
user_input = gr.Textbox(
|
| 113 |
+
label="User Input",
|
| 114 |
+
placeholder="Type your question here...",
|
| 115 |
+
lines=2,
|
| 116 |
+
scale=1,
|
| 117 |
+
full_width=True
|
| 118 |
+
)
|
| 119 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
submit_button = gr.Button("Send", variant="primary", scale=1)
|
|
|
|
| 121 |
clear_button = gr.Button("Clear", scale=1)
|
| 122 |
gr.Markdown("**Try these examples:**")
|
| 123 |
with gr.Row():
|
|
|
|
| 157 |
outputs=user_input
|
| 158 |
)
|
| 159 |
|
| 160 |
+
demo.launch(share=True, ssr_mode=False)
|