update webui: use history_len as pairs of conversation

This commit is contained in:
liunux4odoo 2023-08-09 14:11:10 +08:00
parent 4da7c04859
commit 25280e0cea
1 changed files with 9 additions and 2 deletions

View File

@ -19,8 +19,15 @@ def get_messages_history(history_len: int) -> List[Dict]:
"role": msg["role"],
"content": content[0] if content else "",
}
history = chat_box.filter_history(history_len, filter)
return history
history = chat_box.filter_history(100000, filter) # workaround before upgrading streamlit-chatbox.
user_count = 0
i = 1
for i in range(1, len(history) + 1):
if history[-i]["role"] == "user":
user_count += 1
if user_count >= history_len:
break
return history[-i:]
def dialogue_page(api: ApiRequest):