Skip to content

Empty markdown cell during time to first token in adisplay_stream #104

Description

@adrische

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions