Hi,
in
async def adisplay_stream(rs, chat=None, mx=2000):
"Use IPython.display to markdown display the response stream, refreshing from `chat.full()` on `Refresh`."
try: from IPython.display import display, Markdown
except ModuleNotFoundError: raise ModuleNotFoundError("This function requires ipython. Please run `pip install ipython` to use.")
acc,h = StreamAccum(chat, mx=mx), display(Markdown(' '), display_id=True)
async for o in rs:
if acc(o) and acc.txt: h.update(Markdown(acc.txt))
return acc.txt
h is initialized before the stream starts, leading to an empty Markdown cell being displayed while waiting for the first token.
If desired, this could be circumvented for example by initializing h=None at first, and then only creating h in the first loop iteration.
Hi,
in
h is initialized before the stream starts, leading to an empty Markdown cell being displayed while waiting for the first token.
If desired, this could be circumvented for example by initializing
h=Noneat first, and then only creating h in the first loop iteration.