Update app.py
Browse files
app.py
CHANGED
|
@@ -119,6 +119,18 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 119 |
current_convo_id = gr.State(generate_conversation_id())
|
| 120 |
history_state = gr.State([])
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
with gr.Row():
|
| 123 |
with gr.Column(scale=1):
|
| 124 |
# INTRO TEXT MOVED HERE
|
|
@@ -198,17 +210,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 198 |
return cid, convo["messages"], convo["messages"]
|
| 199 |
return current_convo_id.value, history_state.value, history_state.value
|
| 200 |
|
| 201 |
-
def send_message(user_message, max_tokens, temperature, top_p, convo_id, history):
|
| 202 |
-
if convo_id not in conversations:
|
| 203 |
-
#title = user_message.strip().split("\n")[0][:40]
|
| 204 |
-
title = " ".join(user_message.strip().split()[:5])
|
| 205 |
-
conversations[convo_id] = {"title": title, "messages": history}
|
| 206 |
-
if conversations[convo_id]["title"].startswith("New Conversation"):
|
| 207 |
-
#conversations[convo_id]["title"] = user_message.strip().split("\n")[0][:40]
|
| 208 |
-
conversations[convo_id]["title"] = " ".join(user_message.strip().split()[:5])
|
| 209 |
-
for updated_history, new_history in generate_response(user_message, max_tokens, temperature, top_p, history):
|
| 210 |
-
conversations[convo_id]["messages"] = new_history
|
| 211 |
-
yield updated_history, new_history, gr.update(choices=update_conversation_list(), value=conversations[convo_id]["title"])
|
| 212 |
|
| 213 |
submit_button.click(
|
| 214 |
fn=send_message,
|
|
|
|
| 119 |
current_convo_id = gr.State(generate_conversation_id())
|
| 120 |
history_state = gr.State([])
|
| 121 |
|
| 122 |
+
def send_message(user_message, max_tokens, temperature, top_p, convo_id, history):
|
| 123 |
+
if convo_id not in conversations:
|
| 124 |
+
#title = user_message.strip().split("\n")[0][:40]
|
| 125 |
+
title = " ".join(user_message.strip().split()[:5])
|
| 126 |
+
conversations[convo_id] = {"title": title, "messages": history}
|
| 127 |
+
if conversations[convo_id]["title"].startswith("New Conversation"):
|
| 128 |
+
#conversations[convo_id]["title"] = user_message.strip().split("\n")[0][:40]
|
| 129 |
+
conversations[convo_id]["title"] = " ".join(user_message.strip().split()[:5])
|
| 130 |
+
for updated_history, new_history in generate_response(user_message, max_tokens, temperature, top_p, history):
|
| 131 |
+
conversations[convo_id]["messages"] = new_history
|
| 132 |
+
yield updated_history, new_history, gr.update(choices=update_conversation_list(), value=conversations[convo_id]["title"])
|
| 133 |
+
|
| 134 |
with gr.Row():
|
| 135 |
with gr.Column(scale=1):
|
| 136 |
# INTRO TEXT MOVED HERE
|
|
|
|
| 210 |
return cid, convo["messages"], convo["messages"]
|
| 211 |
return current_convo_id.value, history_state.value, history_state.value
|
| 212 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
submit_button.click(
|
| 215 |
fn=send_message,
|