Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ system_prompt = """Your system prompt here"""
|
|
8 |
def format_prompt(history):
|
9 |
return system_prompt + "\n\n" + "\n".join([f"User: {h[0]}\nAssistant: {h[1]}" for h in history])
|
10 |
|
11 |
-
def predict(inputs, history, temperature, max_new_tokens, top_p, repetition_penalty):
|
12 |
prompt = format_prompt(history + [[inputs, ""]])
|
13 |
response = inference.text_generation(prompt, temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty)
|
14 |
history.append([inputs, response])
|
@@ -35,6 +35,9 @@ body {
|
|
35 |
.gr-button:hover {
|
36 |
background-color: #d81b60;
|
37 |
}
|
|
|
|
|
|
|
38 |
"""
|
39 |
|
40 |
with gr.Blocks(css=css) as demo:
|
@@ -44,13 +47,8 @@ with gr.Blocks(css=css) as demo:
|
|
44 |
with gr.Row():
|
45 |
txt = gr.Textbox(show_label=False, placeholder="Type a message...")
|
46 |
submit_btn = gr.Button("Submit")
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
top_p = gr.Slider(0, 1, value=0.9, step=0.1, label="Top P")
|
51 |
-
repetition_penalty = gr.Slider(1, 2, value=1.0, step=0.1, label="Repetition Penalty")
|
52 |
-
|
53 |
-
submit_btn.click(predict, [txt, chatbot, temperature, max_new_tokens, top_p, repetition_penalty], [chatbot, chatbot])
|
54 |
-
txt.submit(predict, [txt, chatbot, temperature, max_new_tokens, top_p, repetition_penalty], [chatbot, chatbot])
|
55 |
|
56 |
demo.launch()
|
|
|
8 |
def format_prompt(history):
|
9 |
return system_prompt + "\n\n" + "\n".join([f"User: {h[0]}\nAssistant: {h[1]}" for h in history])
|
10 |
|
11 |
+
def predict(inputs, history, temperature=0.9, max_new_tokens=256, top_p=0.9, repetition_penalty=1.0):
|
12 |
prompt = format_prompt(history + [[inputs, ""]])
|
13 |
response = inference.text_generation(prompt, temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty)
|
14 |
history.append([inputs, response])
|
|
|
35 |
.gr-button:hover {
|
36 |
background-color: #d81b60;
|
37 |
}
|
38 |
+
footer {
|
39 |
+
display: none;
|
40 |
+
}
|
41 |
"""
|
42 |
|
43 |
with gr.Blocks(css=css) as demo:
|
|
|
47 |
with gr.Row():
|
48 |
txt = gr.Textbox(show_label=False, placeholder="Type a message...")
|
49 |
submit_btn = gr.Button("Submit")
|
50 |
+
|
51 |
+
submit_btn.click(predict, [txt, chatbot], [chatbot, chatbot])
|
52 |
+
txt.submit(predict, [txt, chatbot], [chatbot, chatbot])
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
demo.launch()
|