From 5ca3c25404b36262684bc39808032b5d4e2d0bfc Mon Sep 17 00:00:00 2001 From: "trducng (john)" Date: Mon, 20 May 2024 16:20:50 +0700 Subject: [PATCH] Avoid empty chat message (#78) --- libs/ktem/ktem/pages/chat/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/ktem/ktem/pages/chat/__init__.py b/libs/ktem/ktem/pages/chat/__init__.py index fe541d7ad..b21e85575 100644 --- a/libs/ktem/ktem/pages/chat/__init__.py +++ b/libs/ktem/ktem/pages/chat/__init__.py @@ -445,6 +445,13 @@ def chat_fn(self, conversation_id, chat_history, settings, state, *selecteds): state[pipeline.get_info()["id"]] = reasoning_state["pipeline"] yield chat_history + [(chat_input, text or msg_placeholder)], refs, state + if not text: + empty_msg = getattr( + flowsettings, "KH_CHAT_EMPTY_MSG_PLACEHOLDER", "(Sorry, I don't know)" + ) + print(f"Generate nothing: {empty_msg}") + yield chat_history + [(chat_input, text or empty_msg)], refs, state + def regen_fn(self, conversation_id, chat_history, settings, state, *selecteds): """Regen function""" if not chat_history: