Spaces:
Sleeping
Sleeping
Tobias Geisler commited on
Commit ·
43f3a3c
1
Parent(s): ab638cf
fix chat history display
Browse files29 unmodified lines30313233343536373839404129 unmodified lineshistory.append({"role": "assistant", "content": assistant_message})# Convert history to the format expected by gr.Chatbot# Note: Gradio Chatbot automatically aligns user messages to the right and assistant messages to the leftformatted_history = [(msg["content"], "user" if msg["role"] == "user" else "assistant") for msg in history]return formatted_history, historydef reset_history(system_message):# Return an empty conversation historyreturn [], []29 unmodified lines303132333435363738394041424344454629 unmodified lineshistory.append({"role": "assistant", "content": assistant_message})# Convert history to the format expected by gr.Chatbotformatted_history = []for msg in history:if msg["role"] == "user":formatted_history.append([msg["content"], None])else: # msg["role"] == "assistant"formatted_history.append([None, msg["content"]])return formatted_history, historydef reset_history(system_message):# Return an empty conversation historyreturn [], []
app.py+7-2