artificialguybr commited on
Commit
f7c578d
β€’
1 Parent(s): ee05341

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -13
app.py CHANGED
@@ -48,29 +48,49 @@ def chat(history, system_message, max_tokens, temperature, top_p, top_k, repetit
48
  history[-1][1] += answer
49
  yield history, history, ""
50
 
51
- with gr.Blocks() as demo:
52
  with gr.Row():
53
  with gr.Column():
54
- gr.Markdown(f"""## Mistral-7B-OpenOrca Playground Space!""")
 
 
 
55
  with gr.Row():
 
 
 
56
  chatbot = gr.Chatbot(elem_id="chatbot")
57
  with gr.Row():
58
- message = gr.Textbox(label="What do you want to chat about?", placeholder="Ask me anything.", lines=3)
 
 
 
 
59
  with gr.Row():
60
- submit = gr.Button(value="Send message", variant="secondary")
61
- clear = gr.Button(value="New topic", variant="secondary")
 
62
  with gr.Accordion("Show Model Parameters", open=False):
63
  with gr.Row():
64
  with gr.Column():
65
- max_tokens = gr.Slider(20, 2500, step=20, value=500)
66
- temperature = gr.Slider(0.0, 2.0, step=0.1, value=0.4)
67
- top_p = gr.Slider(0.0, 1.0, step=0.05, value=0.95)
68
- top_k = gr.Slider(1, 100, step=1, value=40)
69
- repetition_penalty = gr.Slider(1.0, 2.0, step=0.1, value=1.1)
70
- system_msg = gr.Textbox(BASE_SYSTEM_MESSAGE, lines=5)
 
 
71
 
72
  chat_history_state = gr.State()
73
  clear.click(clear_chat, inputs=[chat_history_state, message], outputs=[chat_history_state, message], queue=False)
74
  clear.click(lambda: None, None, chatbot, queue=False)
75
- submit_click_event = submit.click(fn=user, inputs=[message, chat_history_state], outputs=[message, chat_history_state], queue=True).then(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)
76
- demo.queue(max_size=128, concurrency_count=48)
 
 
 
 
 
 
 
 
48
  history[-1][1] += answer
49
  yield history, history, ""
50
 
51
+ with gr.Blocks(css=CSS) as demo:
52
  with gr.Row():
53
  with gr.Column():
54
+ gr.Markdown(f"""
55
+ ## This demo is an unquantized GPU chatbot of [Mistral-7B-OpenOrca](https://huggingface.co/Open-Orca/Mistral-7B-OpenOrca)
56
+ Brought to you by your friends at Alignment Lab AI, OpenChat, and Open Access AI Collective!
57
+ """)
58
  with gr.Row():
59
+ gr.Markdown("# πŸ‹ Mistral-7B-OpenOrca Playground Space! πŸ‹")
60
+ with gr.Row():
61
+ #chatbot = gr.Chatbot().style(height=500)
62
  chatbot = gr.Chatbot(elem_id="chatbot")
63
  with gr.Row():
64
+ message = gr.Textbox(
65
+ label="What do you want to chat about?",
66
+ placeholder="Ask me anything.",
67
+ lines=3,
68
+ )
69
  with gr.Row():
70
+ submit = gr.Button(value="Send message", variant="secondary").style(full_width=True)
71
+ clear = gr.Button(value="New topic", variant="secondary").style(full_width=False)
72
+ stop = gr.Button(value="Stop", variant="secondary").style(full_width=False)
73
  with gr.Accordion("Show Model Parameters", open=False):
74
  with gr.Row():
75
  with gr.Column():
76
+ max_tokens = gr.Slider(20, 2500, label="Max Tokens", step=20, value=500)
77
+ temperature = gr.Slider(0.0, 2.0, label="Temperature", step=0.1, value=0.4)
78
+ top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.95)
79
+ top_k = gr.Slider(1, 100, label="Top K", step=1, value=40)
80
+ repetition_penalty = gr.Slider(1.0, 2.0, label="Repetition Penalty", step=0.1, value=1.1)
81
+
82
+ system_msg = gr.Textbox(
83
+ start_message, label="System Message", interactive=True, visible=True, placeholder="System prompt. Provide instructions which you want the model to remember.", lines=5)
84
 
85
  chat_history_state = gr.State()
86
  clear.click(clear_chat, inputs=[chat_history_state, message], outputs=[chat_history_state, message], queue=False)
87
  clear.click(lambda: None, None, chatbot, queue=False)
88
+
89
+ submit_click_event = submit.click(
90
+ fn=user, inputs=[message, chat_history_state], outputs=[message, chat_history_state], queue=True
91
+ ).then(
92
+ 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
93
+ )
94
+ stop.click(fn=None, inputs=None, outputs=None, cancels=[submit_click_event], queue=False)
95
+
96
+ demo.queue(max_size=128, concurrency_count=48).launch(debug=True, server_name="0.0.0.0", server_port=7860)