elfsong
commited on
Commit
·
a236245
1
Parent(s):
ff147bb
refactor: Simplify chatbot configuration by removing redundant parameters and consolidating feedback logging functionality.
Browse files
app.py
CHANGED
|
@@ -116,40 +116,28 @@ with gr.Blocks() as demo:
|
|
| 116 |
# --- Model A ---
|
| 117 |
with gr.Column():
|
| 118 |
model_a_name = gr.Dropdown(MODELS, label="Model A", value=MODELS[0])
|
| 119 |
-
|
| 120 |
-
chatbot_a = gr.Chatbot(label="Model A Output", type="messages", like_user_message=True)
|
| 121 |
msg_a = gr.Textbox(placeholder="Send message to Model A...", label="Model A Input")
|
| 122 |
btn_a = gr.Button("Send to Model A")
|
| 123 |
|
| 124 |
# --- Model B ---
|
| 125 |
with gr.Column():
|
| 126 |
model_b_name = gr.Dropdown(MODELS, label="Model B", value=MODELS[1])
|
| 127 |
-
|
| 128 |
-
chatbot_b = gr.Chatbot(label="Model B Output", type="messages", like_user_message=True)
|
| 129 |
msg_b = gr.Textbox(placeholder="Send message to Model B...", label="Model B Input")
|
| 130 |
btn_b = gr.Button("Send to Model B")
|
| 131 |
-
|
| 132 |
-
chatbot_a.like(
|
| 133 |
-
fn=save_feedback,
|
| 134 |
-
inputs=[model_a_name, chatbot_a],
|
| 135 |
-
outputs=None
|
| 136 |
-
)
|
| 137 |
-
|
| 138 |
-
chatbot_b.like(
|
| 139 |
-
fn=save_feedback,
|
| 140 |
-
inputs=[model_b_name, chatbot_b],
|
| 141 |
-
outputs=None
|
| 142 |
-
)
|
| 143 |
|
| 144 |
# --- Bind Events ---
|
| 145 |
-
|
| 146 |
a_inputs = [msg_a, chatbot_a, model_a_name, system_msg, max_t, temp, top_p_val, local_endpoint]
|
| 147 |
msg_a.submit(bot_response, a_inputs, [chatbot_a, msg_a])
|
| 148 |
btn_a.click(bot_response, a_inputs, [chatbot_a, msg_a])
|
|
|
|
| 149 |
|
| 150 |
b_inputs = [msg_b, chatbot_b, model_b_name, system_msg, max_t, temp, top_p_val, local_endpoint]
|
| 151 |
msg_b.submit(bot_response, b_inputs, [chatbot_b, msg_b])
|
| 152 |
btn_b.click(bot_response, b_inputs, [chatbot_b, msg_b])
|
|
|
|
|
|
|
| 153 |
|
| 154 |
def clear_chats():
|
| 155 |
return [], []
|
|
|
|
| 116 |
# --- Model A ---
|
| 117 |
with gr.Column():
|
| 118 |
model_a_name = gr.Dropdown(MODELS, label="Model A", value=MODELS[0])
|
| 119 |
+
chatbot_a = gr.Chatbot(label="Model A Output", type="messages")
|
|
|
|
| 120 |
msg_a = gr.Textbox(placeholder="Send message to Model A...", label="Model A Input")
|
| 121 |
btn_a = gr.Button("Send to Model A")
|
| 122 |
|
| 123 |
# --- Model B ---
|
| 124 |
with gr.Column():
|
| 125 |
model_b_name = gr.Dropdown(MODELS, label="Model B", value=MODELS[1])
|
| 126 |
+
chatbot_b = gr.Chatbot(label="Model B Output", type="messages")
|
|
|
|
| 127 |
msg_b = gr.Textbox(placeholder="Send message to Model B...", label="Model B Input")
|
| 128 |
btn_b = gr.Button("Send to Model B")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
|
| 130 |
# --- Bind Events ---
|
|
|
|
| 131 |
a_inputs = [msg_a, chatbot_a, model_a_name, system_msg, max_t, temp, top_p_val, local_endpoint]
|
| 132 |
msg_a.submit(bot_response, a_inputs, [chatbot_a, msg_a])
|
| 133 |
btn_a.click(bot_response, a_inputs, [chatbot_a, msg_a])
|
| 134 |
+
chatbot_a.like(save_feedback, [model_a_name, chatbot_a], None)
|
| 135 |
|
| 136 |
b_inputs = [msg_b, chatbot_b, model_b_name, system_msg, max_t, temp, top_p_val, local_endpoint]
|
| 137 |
msg_b.submit(bot_response, b_inputs, [chatbot_b, msg_b])
|
| 138 |
btn_b.click(bot_response, b_inputs, [chatbot_b, msg_b])
|
| 139 |
+
chatbot_b.like(save_feedback, [model_b_name, chatbot_b], None)
|
| 140 |
+
|
| 141 |
|
| 142 |
def clear_chats():
|
| 143 |
return [], []
|