Spaces:
Build error
Build error
Download streaming.py from Tammy/Chat_bot: direct link, hf CLI and curl.
- Browser
- Download file 350 Bytes
-
https://huggingface.co/spaces/Tammy/Chat_bot/resolve/main/streaming.py
- Command line
-
hf download hf://spaces/Tammy/Chat_bot/streaming.py
-
curl -L -o streaming.py https://huggingface.co/spaces/Tammy/Chat_bot/resolve/main/streaming.py
350 Bytes
| from langchain_core.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) |