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

Missing necessary newline in st.chat_message #7978

Closed
3 of 4 tasks
ShaneTian opened this issue Jan 19, 2024 · 5 comments
Closed
3 of 4 tasks

Missing necessary newline in st.chat_message #7978

ShaneTian opened this issue Jan 19, 2024 · 5 comments
Labels
feature:markdown status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working

Comments

@ShaneTian
Copy link

ShaneTian commented Jan 19, 2024

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

When I use st.chat_message in LLM demo, I found the output message was missing some of the necessary line breaks.

The assistant message below is from GPT-4, so it is common phenomenon.

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st

message = "**Title: Leveraging Large-Scale Language Models for Enhancing Communication Technologies**\n\nI. Introduction\nA. Overview of the evolution of language models in artificial intelligence (AI)"
st.chat_message("assistant").write(message)

Steps To Reproduce

No response

Expected Behavior

image

Current Behavior

image

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.13.0
  • Python version: 3.9.16
  • Operating System: Linux
  • Browser: Chrome

Additional Information

No response

@ShaneTian ShaneTian added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Jan 19, 2024
Copy link

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@lukasmasuch lukasmasuch added feature:markdown status:confirmed Bug has been confirmed by the Streamlit team and removed status:needs-triage Has not been triaged by the Streamlit team labels Jan 22, 2024
@lukasmasuch
Copy link
Collaborator

@ShaneTian Thanks for reporting this issue. I was able to reproduce this here. The problem comes from markdown rendering (st.write with text uses st.markdown), which is already tracked here. Please upvote the linked markdown issue, and potentially add your example to the thread.

@lukasmasuch
Copy link
Collaborator

Btw. a workaround is to add spaces before all-new line symbols. E.g. via a string replacement on the message.

@ShaneTian
Copy link
Author

Btw. a workaround is to add spaces before all-new line symbols. E.g. via a string replacement on the message.

Yes, it is a solution, but is is not a permanent one.

@principalideal0
Copy link

principalideal0 commented Apr 23, 2024

There are 62 likes on a linked issue and multiple posts about this - when you ask for likes, do likes thread through from linked discussions in your analytics? You may be underestimating the importance if not. I think anyone dealing with generated output is going to find this to be a gigantic headache ... not a trivial problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:markdown status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants