Update app.py
Browse files
app.py
CHANGED
|
@@ -42,6 +42,10 @@ def load_models(inp):
|
|
| 42 |
print(models[inp])
|
| 43 |
client_z.clear()
|
| 44 |
client_z.append(InferenceClient(models[inp]))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
return gr.update(label=models[inp])
|
| 46 |
|
| 47 |
def format_prompt(message, history):
|
|
@@ -61,7 +65,7 @@ agents =[
|
|
| 61 |
|
| 62 |
temperature=0.9
|
| 63 |
max_new_tokens=256
|
| 64 |
-
max_new_tokens2=
|
| 65 |
top_p=0.95
|
| 66 |
repetition_penalty=1.0,
|
| 67 |
|
|
@@ -77,7 +81,7 @@ def compress_history(formatted_prompt):
|
|
| 77 |
|
| 78 |
generate_kwargs = dict(
|
| 79 |
temperature=temperature,
|
| 80 |
-
max_new_tokens=
|
| 81 |
top_p=0.95,
|
| 82 |
repetition_penalty=1.0,
|
| 83 |
do_sample=True,
|
|
@@ -352,7 +356,9 @@ with gr.Blocks() as app:
|
|
| 352 |
submit_b = gr.Button()
|
| 353 |
stop_b = gr.Button("Stop")
|
| 354 |
clear = gr.ClearButton([msg, chatbot])
|
| 355 |
-
|
|
|
|
|
|
|
| 356 |
|
| 357 |
sumbox=gr.Textbox("Summary", max_lines=100)
|
| 358 |
with gr.Column():
|
|
@@ -363,8 +369,8 @@ with gr.Blocks() as app:
|
|
| 363 |
m_choice.change(load_models,m_choice,[chatbot])
|
| 364 |
app.load(load_models,m_choice,[chatbot]).then(load_html,None,html)
|
| 365 |
|
| 366 |
-
sub_b = submit_b.click(generate, [msg,chatbot],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
|
| 367 |
-
sub_e = msg.submit(generate, [msg, chatbot], [msg, chatbot,sumbox,sum_out_box,hist_out_box,html])
|
| 368 |
stop_b.click(None,None,None, cancels=[sub_b,sub_e])
|
| 369 |
|
| 370 |
app.queue(default_concurrency_limit=20).launch()
|
|
|
|
| 42 |
print(models[inp])
|
| 43 |
client_z.clear()
|
| 44 |
client_z.append(InferenceClient(models[inp]))
|
| 45 |
+
|
| 46 |
+
if "mistralai" in models[inp]:
|
| 47 |
+
|
| 48 |
+
|
| 49 |
return gr.update(label=models[inp])
|
| 50 |
|
| 51 |
def format_prompt(message, history):
|
|
|
|
| 65 |
|
| 66 |
temperature=0.9
|
| 67 |
max_new_tokens=256
|
| 68 |
+
max_new_tokens2=4000
|
| 69 |
top_p=0.95
|
| 70 |
repetition_penalty=1.0,
|
| 71 |
|
|
|
|
| 81 |
|
| 82 |
generate_kwargs = dict(
|
| 83 |
temperature=temperature,
|
| 84 |
+
max_new_tokens=1048,
|
| 85 |
top_p=0.95,
|
| 86 |
repetition_penalty=1.0,
|
| 87 |
do_sample=True,
|
|
|
|
| 356 |
submit_b = gr.Button()
|
| 357 |
stop_b = gr.Button("Stop")
|
| 358 |
clear = gr.ClearButton([msg, chatbot])
|
| 359 |
+
with gr.Row():
|
| 360 |
+
m_choice=gr.Dropdown(label="Models",type='index',choices=[c for c in models],value=models[0],interactive=True)
|
| 361 |
+
tokens = gr.Slider(label="Max new tokens",value=1600,minimum=0,maximum=8000,step=64,interactive=True, visible=True,info="The maximum number of tokens")
|
| 362 |
|
| 363 |
sumbox=gr.Textbox("Summary", max_lines=100)
|
| 364 |
with gr.Column():
|
|
|
|
| 369 |
m_choice.change(load_models,m_choice,[chatbot])
|
| 370 |
app.load(load_models,m_choice,[chatbot]).then(load_html,None,html)
|
| 371 |
|
| 372 |
+
sub_b = submit_b.click(generate, [msg,chatbot,tokens],[msg,chatbot,sumbox,sum_out_box,hist_out_box,html])
|
| 373 |
+
sub_e = msg.submit(generate, [msg, chatbot,tokens], [msg, chatbot,sumbox,sum_out_box,hist_out_box,html])
|
| 374 |
stop_b.click(None,None,None, cancels=[sub_b,sub_e])
|
| 375 |
|
| 376 |
app.queue(default_concurrency_limit=20).launch()
|