Spaces:
Sleeping
Sleeping
File size: 349 Bytes
9e7b1cc |
1 2 3 4 5 6 7 8 9 10 11 |
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) |