admin管理员组文章数量:1277910
The context is that I'm streaming LLM tokens from a model, and they're in Markdown, so I want to repeatedly append to the rendered Markdown.
This is roughly the code I'm using with bare text:
async for chunk in response.receive():
print(chunk.text, end='')
Which outputs:
# Document heading
Intro text
* A bullet point
* Another bullet point
But I want to render the markdown:
from IPython import display, Markdown
async for chunk in response.receive():
display(Markdown(chunk.text))
Since this outputs a markdown block with each call, there are breaks between each chunk (but with occasional formatting):
Document
heading
Intro
text
*
A
bullet point
*
Another
bullet point
Is there a way to do this naturally with the IPython
or other library? Or do I need to manually buffer and re-render the response?
本文标签: pythonRendering streamed Markdown chunks in IPythonJupyterStack Overflow
版权声明:本文标题:python - Rendering streamed Markdown chunks in IPythonJupyter - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741223535a2361428.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论