Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,6 @@ def respond(message, chat_history, system_message, max_tokens, temperature, top_
|
|
35 |
|
36 |
# Update chat history
|
37 |
chat_history.append((message, response))
|
38 |
-
|
39 |
return chat_history
|
40 |
|
41 |
with gr.Blocks() as demo:
|
@@ -44,19 +43,28 @@ with gr.Blocks() as demo:
|
|
44 |
with gr.Row():
|
45 |
with gr.Column():
|
46 |
system_msg = gr.Textbox("You are Arsh, a helpful assistant by Arshia Afshani. You should answer the user carefully.",
|
47 |
-
label="System Message"
|
48 |
max_tokens = gr.Slider(1, 4096, value=2048, step=1, label="Max Tokens")
|
49 |
temperature = gr.Slider(0.1, 4.0, value=0.7, step=0.1, label="Temperature")
|
50 |
top_p = gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p")
|
51 |
top_k = gr.Slider(0, 100, value=40, step=1, label="Top-k")
|
52 |
repeat_penalty = gr.Slider(0.0, 2.0, value=1.1, step=0.1, label="Repetition Penalty")
|
53 |
|
54 |
-
chatbot = gr.Chatbot(
|
55 |
msg = gr.Textbox(label="Your Message")
|
56 |
clear = gr.Button("Clear")
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
clear.click(lambda: None, None, chatbot, queue=False)
|
60 |
|
61 |
if __name__ == "__main__":
|
62 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
35 |
|
36 |
# Update chat history
|
37 |
chat_history.append((message, response))
|
|
|
38 |
return chat_history
|
39 |
|
40 |
with gr.Blocks() as demo:
|
|
|
43 |
with gr.Row():
|
44 |
with gr.Column():
|
45 |
system_msg = gr.Textbox("You are Arsh, a helpful assistant by Arshia Afshani. You should answer the user carefully.",
|
46 |
+
label="System Message")
|
47 |
max_tokens = gr.Slider(1, 4096, value=2048, step=1, label="Max Tokens")
|
48 |
temperature = gr.Slider(0.1, 4.0, value=0.7, step=0.1, label="Temperature")
|
49 |
top_p = gr.Slider(0.1, 1.0, value=0.95, step=0.05, label="Top-p")
|
50 |
top_k = gr.Slider(0, 100, value=40, step=1, label="Top-k")
|
51 |
repeat_penalty = gr.Slider(0.0, 2.0, value=1.1, step=0.1, label="Repetition Penalty")
|
52 |
|
53 |
+
chatbot = gr.Chatbot(height=500)
|
54 |
msg = gr.Textbox(label="Your Message")
|
55 |
clear = gr.Button("Clear")
|
56 |
|
57 |
+
def submit_message(message, chat_history, system_message, max_tokens, temperature, top_p, top_k, repeat_penalty):
|
58 |
+
chat_history = chat_history or []
|
59 |
+
response = respond(message, chat_history, system_message, max_tokens, temperature, top_p, top_k, repeat_penalty)
|
60 |
+
return "", response
|
61 |
+
|
62 |
+
msg.submit(
|
63 |
+
submit_message,
|
64 |
+
[msg, chatbot, system_msg, max_tokens, temperature, top_p, top_k, repeat_penalty],
|
65 |
+
[msg, chatbot]
|
66 |
+
)
|
67 |
clear.click(lambda: None, None, chatbot, queue=False)
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|