0

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?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.