ciorant commited on
Commit
73a52fa
·
verified ·
1 Parent(s): 985eea4

Update src/chatbot.py

Browse files
Files changed (1) hide show
  1. src/chatbot.py +3 -4
src/chatbot.py CHANGED
@@ -17,20 +17,19 @@ logger = logging.getLogger(__name__)
17
  from langchain.callbacks.base import BaseCallbackHandler
18
 
19
  class StreamHandler(BaseCallbackHandler):
20
- def __init__(self, placeholder):
21
  self.current_text = ""
22
  self.placeholder = placeholder
23
 
24
  def on_llm_new_token(self, token: str, **kwargs):
25
  self.current_text += token
26
- # Update Streamlit UI live
27
- self.placeholder.markdown(self.current_text + "▌")
28
 
29
  def get_text(self):
30
  return self.current_text
31
 
32
 
33
-
34
  class BioethicsChatbot:
35
  def __init__(self, data_dir: str="data/sample_papers"):
36
  self.processor = DocumentProcessor()
 
17
  from langchain.callbacks.base import BaseCallbackHandler
18
 
19
  class StreamHandler(BaseCallbackHandler):
20
+ def __init__(self, placeholder=None):
21
  self.current_text = ""
22
  self.placeholder = placeholder
23
 
24
  def on_llm_new_token(self, token: str, **kwargs):
25
  self.current_text += token
26
+ if self.placeholder:
27
+ self.placeholder.markdown(self.current_text + "▌")
28
 
29
  def get_text(self):
30
  return self.current_text
31
 
32
 
 
33
  class BioethicsChatbot:
34
  def __init__(self, data_dir: str="data/sample_papers"):
35
  self.processor = DocumentProcessor()