Commit
·
b6754f9
1
Parent(s):
937733b
Adjust chat history formatting for Gradio Chatbot component
Browse files
app.py
CHANGED
@@ -82,10 +82,16 @@ with gr.Blocks() as demo:
|
|
82 |
if not chat_history or (chat_history and chat_history[-1]["role"] != "user"):
|
83 |
chat_history = user(message, chat_history)
|
84 |
chat_history, _ = chat(chat_history, BASE_SYSTEM_MESSAGE, max_tokens.value, temperature.value, top_p.value, 40, 1.1)
|
85 |
-
#
|
86 |
-
formatted_chat_history = [
|
|
|
|
|
|
|
|
|
|
|
87 |
return formatted_chat_history, chat_history, ""
|
88 |
|
|
|
89 |
submit.click(
|
90 |
fn=update_chatbot,
|
91 |
inputs=[message, chat_history_state],
|
|
|
82 |
if not chat_history or (chat_history and chat_history[-1]["role"] != "user"):
|
83 |
chat_history = user(message, chat_history)
|
84 |
chat_history, _ = chat(chat_history, BASE_SYSTEM_MESSAGE, max_tokens.value, temperature.value, top_p.value, 40, 1.1)
|
85 |
+
# Adjust the formatting of the chat history for the Gradio Chatbot component
|
86 |
+
formatted_chat_history = []
|
87 |
+
for msg in chat_history:
|
88 |
+
if msg["role"] == "user":
|
89 |
+
formatted_chat_history.append(["user", msg["content"]])
|
90 |
+
else:
|
91 |
+
formatted_chat_history.append(["bot", msg["content"]]) # Change 'assistant' to 'bot' for clarity in the UI
|
92 |
return formatted_chat_history, chat_history, ""
|
93 |
|
94 |
+
|
95 |
submit.click(
|
96 |
fn=update_chatbot,
|
97 |
inputs=[message, chat_history_state],
|