Spaces:
Runtime error
Runtime error
aixsatoshi
commited on
Commit
•
5c36e32
1
Parent(s):
f3e02f2
Update app.py
Browse files
app.py
CHANGED
@@ -139,37 +139,59 @@ templates = [
|
|
139 |
|
140 |
with gr.Blocks() as demo:
|
141 |
gr.Markdown(description)
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
chat_interface = gr.ChatInterface(
|
161 |
-
fn=respond,
|
162 |
-
additional_inputs=[
|
163 |
-
gr.Textbox(value="You are a helpful assistant.", label="System message"),
|
164 |
-
model_dropdown,
|
165 |
-
template_dropdown,
|
166 |
-
gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max tokens"),
|
167 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
168 |
-
gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p"),
|
169 |
-
gr.Slider(minimum=0, maximum=100, value=40, step=1, label="Top-k"),
|
170 |
-
gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty"),
|
171 |
-
gr.Chatbot(scale=1, likeable=False, show_copy_button=True)
|
172 |
-
]
|
173 |
-
)
|
174 |
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
with gr.Blocks() as demo:
|
141 |
gr.Markdown(description)
|
142 |
+
with gr.Row():
|
143 |
+
model_dropdown = gr.Dropdown(
|
144 |
+
choices=[
|
145 |
+
'Oumuamua-7b-RP_Q4_K_M.gguf',
|
146 |
+
'Oumuamua-7b-instruct-v2-Q4_K_M.gguf',
|
147 |
+
'umiyuki-Umievo-itr012-Gleipnir-7B-Q4_K_M.gguf',
|
148 |
+
'Ninja-V3-Q4_K_M.gguf',
|
149 |
+
'kagemusya-7b-v1Q8_0.gguf',
|
150 |
+
'Llama-3-ELYZA-JP-8B-q4_k_m.gguf'
|
151 |
+
],
|
152 |
+
value="Oumuamua-7b-RP_Q4_K_M.gguf",
|
153 |
+
label="Model"
|
154 |
+
)
|
155 |
+
template_dropdown = gr.Dropdown(
|
156 |
+
choices=templates,
|
157 |
+
value="LLAMA_3",
|
158 |
+
label="Template"
|
159 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
chatbot = gr.Chatbot()
|
162 |
+
with gr.Row():
|
163 |
+
system_message = gr.Textbox(value="You are a helpful assistant.", label="System message")
|
164 |
+
with gr.Row():
|
165 |
+
max_tokens = gr.Slider(minimum=1, maximum=4096, value=2048, step=1, label="Max tokens")
|
166 |
+
temperature = gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature")
|
167 |
+
with gr.Row():
|
168 |
+
top_p = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p")
|
169 |
+
top_k = gr.Slider(minimum=0, maximum=100, value=40, step=1, label="Top-k")
|
170 |
+
with gr.Row():
|
171 |
+
repeat_penalty = gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty")
|
172 |
+
|
173 |
+
submit_btn = gr.Button("Send")
|
174 |
+
clear_btn = gr.Button("Clear")
|
175 |
+
undo_btn = gr.Button("Undo")
|
176 |
+
retry_btn = gr.Button("Retry")
|
177 |
+
|
178 |
+
def handle_response(message, history):
|
179 |
+
return list(respond(
|
180 |
+
message,
|
181 |
+
history,
|
182 |
+
model_dropdown.value,
|
183 |
+
system_message.value,
|
184 |
+
max_tokens.value,
|
185 |
+
temperature.value,
|
186 |
+
top_p.value,
|
187 |
+
top_k.value,
|
188 |
+
repeat_penalty.value,
|
189 |
+
template_dropdown.value
|
190 |
+
))
|
191 |
+
|
192 |
+
submit_btn.click(fn=handle_response, inputs=[chatbot.input, chatbot.history], outputs=chatbot)
|
193 |
+
clear_btn.click(lambda: None, None, chatbot)
|
194 |
+
undo_btn.click(lambda x: x[:-1] if x else None, chatbot, chatbot)
|
195 |
+
retry_btn.click(lambda x: x[:-1] if x else None, chatbot, chatbot)
|
196 |
+
|
197 |
+
demo.launch()
|