Commit
路
f2bf349
1
Parent(s):
9a75ed0
Refactor chat history formatting in app.py
Browse files
app.py
CHANGED
@@ -82,10 +82,12 @@ 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, system_msg.value, max_tokens.value, temperature.value, top_p.value, 40, 1.1)
|
85 |
-
|
|
|
86 |
return formatted_chat_history, chat_history, ""
|
87 |
|
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, system_msg.value, max_tokens.value, temperature.value, top_p.value, 40, 1.1)
|
85 |
+
# Formata o 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 |
|
90 |
+
|
91 |
submit.click(
|
92 |
fn=update_chatbot,
|
93 |
inputs=[message, chat_history_state],
|