Commit
路
937733b
1
Parent(s):
d1ff68f
Refactor chat history formatting in update_chatbot function
Browse files
app.py
CHANGED
@@ -79,14 +79,11 @@ with gr.Blocks() as demo:
|
|
79 |
|
80 |
def update_chatbot(message, chat_history):
|
81 |
print("Updating chatbot...")
|
82 |
-
# Inclui o prompt do sistema como a primeira mensagem, se necess谩rio
|
83 |
-
if not chat_history or (chat_history and chat_history[0]["content"] != BASE_SYSTEM_MESSAGE):
|
84 |
-
chat_history.insert(0, {"role": "system", "content": BASE_SYSTEM_MESSAGE})
|
85 |
if not chat_history or (chat_history and chat_history[-1]["role"] != "user"):
|
86 |
chat_history = user(message, chat_history)
|
87 |
chat_history, _ = chat(chat_history, BASE_SYSTEM_MESSAGE, max_tokens.value, temperature.value, top_p.value, 40, 1.1)
|
88 |
-
#
|
89 |
-
formatted_chat_history = [
|
90 |
return formatted_chat_history, chat_history, ""
|
91 |
|
92 |
submit.click(
|
|
|
79 |
|
80 |
def update_chatbot(message, chat_history):
|
81 |
print("Updating chatbot...")
|
|
|
|
|
|
|
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 |
+
# Ajusta a formata莽茫o do hist贸rico do chat para o formato esperado pelo gr.Chatbot
|
86 |
+
formatted_chat_history = [[msg["role"], msg["content"]] for msg in chat_history]
|
87 |
return formatted_chat_history, chat_history, ""
|
88 |
|
89 |
submit.click(
|