aeo_chat_bot / streaming.py
ibibek's picture
Upload 4 files
9e7b1cc
raw
history blame contribute delete
349 Bytes
from langchain.callbacks.base import BaseCallbackHandler
class StreamHandler(BaseCallbackHandler):
def __init__(self, container, initial_text=""):
self.container = container
self.text = initial_text
def on_llm_new_token(self, token: str, **kwargs):
self.text += token
self.container.markdown(self.text)