Skip to content

Commit

Permalink
Avoid empty chat message (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
trducng authored May 20, 2024
1 parent b2296cf commit 5ca3c25
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libs/ktem/ktem/pages/chat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5ca3c25

Please sign in to comment.