Skip to content

Commit

Permalink
suppress chainlit blinking cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Q committed Jun 21, 2024
1 parent a188b96 commit 8ff74e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions playground/UI/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class ChainLitMessageUpdater(SessionEventHandlerBase):
def __init__(self, root_step: cl.Step):
self.root_step = root_step
self.reset_cur_step()
self.suppress_blinking_cursor()

def reset_cur_step(self):
self.cur_step: Optional[cl.Step] = None
Expand All @@ -140,6 +141,11 @@ def reset_cur_step(self):
self.cur_message_is_end: bool = False
self.cur_message_sent: bool = False

def suppress_blinking_cursor(self):
cl.run_sync(self.root_step.stream_token(""))
if self.cur_step is not None:
cl.run_sync(self.cur_step.stream_token(""))

def handle_round(
self,
type: RoundEventType,
Expand Down Expand Up @@ -209,6 +215,7 @@ def handle_post(
),
]
cl.run_sync(self.cur_step.update())
self.suppress_blinking_cursor()

def get_message_from_user(self, prompt: str, timeout: int = 120) -> Optional[str]:
ask_user_msg = cl.AskUserMessage(content=prompt, author=" ", timeout=timeout)
Expand Down

0 comments on commit 8ff74e7

Please sign in to comment.