grammar, info, regenerate button
Browse files
app.py
CHANGED
@@ -30,6 +30,14 @@ def user(message, history):
|
|
30 |
return "", history
|
31 |
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
34 |
history = history or []
|
35 |
|
@@ -80,11 +88,15 @@ with gr.Blocks(css=CSS) as demo:
|
|
80 |
with gr.Row():
|
81 |
with gr.Column():
|
82 |
gr.Markdown(f"""
|
83 |
-
## This
|
84 |
-
|
|
|
85 |
""")
|
86 |
with gr.Row():
|
87 |
gr.Markdown("# π°π¦ Jackalope 7B Playground Space! π°π¦")
|
|
|
|
|
|
|
88 |
with gr.Row():
|
89 |
#chatbot = gr.Chatbot().style(height=500)
|
90 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
@@ -95,10 +107,11 @@ with gr.Blocks(css=CSS) as demo:
|
|
95 |
lines=3,
|
96 |
)
|
97 |
with gr.Row():
|
98 |
-
submit = gr.Button(value="Send message", variant="
|
99 |
clear = gr.Button(value="New topic", variant="secondary").style(full_width=False)
|
100 |
stop = gr.Button(value="Stop", variant="secondary").style(full_width=False)
|
101 |
-
|
|
|
102 |
with gr.Row():
|
103 |
with gr.Column():
|
104 |
max_tokens = gr.Slider(20, 2500, label="Max Tokens", step=20, value=500)
|
@@ -107,9 +120,6 @@ with gr.Blocks(css=CSS) as demo:
|
|
107 |
top_k = gr.Slider(1, 100, label="Top K", step=1, value=40)
|
108 |
repetition_penalty = gr.Slider(1.0, 2.0, label="Repetition Penalty", step=0.1, value=1.1)
|
109 |
|
110 |
-
system_msg = gr.Textbox(
|
111 |
-
start_message, label="System Message", interactive=True, visible=True, placeholder="System prompt. Provide instructions which you want the model to remember.", lines=5)
|
112 |
-
|
113 |
chat_history_state = gr.State()
|
114 |
clear.click(clear_chat, inputs=[chat_history_state, message], outputs=[chat_history_state, message], queue=False)
|
115 |
clear.click(lambda: None, None, chatbot, queue=False)
|
@@ -119,6 +129,11 @@ with gr.Blocks(css=CSS) as demo:
|
|
119 |
).then(
|
120 |
fn=chat, inputs=[chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty], outputs=[chatbot, chat_history_state, message], queue=True
|
121 |
)
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
demo.queue(max_size=128, concurrency_count=48).launch(debug=True, server_name="0.0.0.0", server_port=7860)
|
|
|
30 |
return "", history
|
31 |
|
32 |
|
33 |
+
def pop_last(history):
|
34 |
+
turn = history.pop()
|
35 |
+
# append the user's last message to the conversation history
|
36 |
+
history.append([turn[0], ""])
|
37 |
+
|
38 |
+
return history
|
39 |
+
|
40 |
+
|
41 |
def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetition_penalty):
|
42 |
history = history or []
|
43 |
|
|
|
88 |
with gr.Row():
|
89 |
with gr.Column():
|
90 |
gr.Markdown(f"""
|
91 |
+
## This PREVIEW demo is an un-quantized GPU chatbot of Jackalope 7B
|
92 |
+
Final model drops on Wednesday October 11th.
|
93 |
+
Brought to you by your friends at Open Access AI Collective, Alignment Lab AI, and OpenChat!
|
94 |
""")
|
95 |
with gr.Row():
|
96 |
gr.Markdown("# π°π¦ Jackalope 7B Playground Space! π°π¦")
|
97 |
+
with gr.Row():
|
98 |
+
system_msg = gr.Textbox(
|
99 |
+
start_message, label="System Message", interactive=True, visible=True, placeholder="System prompt. Provide instructions which you want the model to remember.", lines=5)
|
100 |
with gr.Row():
|
101 |
#chatbot = gr.Chatbot().style(height=500)
|
102 |
chatbot = gr.Chatbot(elem_id="chatbot")
|
|
|
107 |
lines=3,
|
108 |
)
|
109 |
with gr.Row():
|
110 |
+
submit = gr.Button(value="Send message", variant="primary").style(full_width=True)
|
111 |
clear = gr.Button(value="New topic", variant="secondary").style(full_width=False)
|
112 |
stop = gr.Button(value="Stop", variant="secondary").style(full_width=False)
|
113 |
+
regenerate = gr.Button(value="Regenerate", variant="secondary").style(full_width=False)
|
114 |
+
with gr.Accordion("Show Model Parameters", open=False):
|
115 |
with gr.Row():
|
116 |
with gr.Column():
|
117 |
max_tokens = gr.Slider(20, 2500, label="Max Tokens", step=20, value=500)
|
|
|
120 |
top_k = gr.Slider(1, 100, label="Top K", step=1, value=40)
|
121 |
repetition_penalty = gr.Slider(1.0, 2.0, label="Repetition Penalty", step=0.1, value=1.1)
|
122 |
|
|
|
|
|
|
|
123 |
chat_history_state = gr.State()
|
124 |
clear.click(clear_chat, inputs=[chat_history_state, message], outputs=[chat_history_state, message], queue=False)
|
125 |
clear.click(lambda: None, None, chatbot, queue=False)
|
|
|
129 |
).then(
|
130 |
fn=chat, inputs=[chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty], outputs=[chatbot, chat_history_state, message], queue=True
|
131 |
)
|
132 |
+
regenerate_click_event = regenerate.click(
|
133 |
+
fn=pop_last, inputs=[chat_history_state], outputs=[chat_history_state], queue=True
|
134 |
+
).then(
|
135 |
+
fn=chat, inputs=[chat_history_state, system_msg, max_tokens, temperature, top_p, top_k, repetition_penalty], outputs=[chatbot, chat_history_state, message], queue=True
|
136 |
+
)
|
137 |
+
stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event, regenerate_click_event], queue=False)
|
138 |
|
139 |
demo.queue(max_size=128, concurrency_count=48).launch(debug=True, server_name="0.0.0.0", server_port=7860)
|