Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't have to simulate typewriter effect in streamlit_app.py #8

Open
jliu015 opened this issue Feb 24, 2024 · 0 comments
Open

Don't have to simulate typewriter effect in streamlit_app.py #8

jliu015 opened this issue Feb 24, 2024 · 0 comments

Comments

@jliu015
Copy link

jliu015 commented Feb 24, 2024

In streamlit_app.py, typewriter effect is simulated by the following code.
response = generate_llama2_response(prompt)
placeholder = st.empty()
full_response = ''
for item in response:
full_response += item
placeholder.markdown(full_response)
placeholder.markdown(full_response)

That's NOT a neat implementation because you can't display the partial response until the full response is received, esp. for the long response. The good example is available on replicate website. https://replicate.com/docs/get-started/python.

Some models stream output as the model is running. They will return an iterator, and you can iterate over that output

iterator = replicate.run(
"mistralai/mixtral-8x7b-instruct-v0.1",
input={"prompt": "Who was Dolly the sheep?"},
)
for text in iterator:
print(text)

Hopefully llama2 can return an iterator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant