Fix chatbot newline issue (#3717)

* changes

* changes

* changes

* changelog

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
aliabid94 2023-03-31 05:46:27 -07:00 committed by GitHub
parent 13682c7bbc
commit 759fb3b1f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 3 deletions

View File

@ -29,6 +29,37 @@ No changes to highlight.
No changes to highlight.
# Version 3.24.1
## New Features:
No changes to highlight.
## Bug Fixes:
- Fixes Chatbot issue where new lines were being created every time a message was sent back and forth by [@aliabid94](https://github.com/aliabid94) in [PR 3717](https://github.com/gradio-app/gradio/pull/3717).
## Documentation Changes:
No changes to highlight.
## Testing and Infrastructure Changes:
No changes to highlight.
## Breaking Changes:
No changes to highlight.
## Full Changelog:
No changes to highlight.
## Contributors Shoutout:
No changes to highlight.
# Version 3.24.0

View File

@ -4302,6 +4302,7 @@ class Chatbot(Changeable, Selectable, IOComponent, JSONSerializable):
"is_file": True,
}
elif isinstance(chat_message, str):
chat_message = chat_message.replace("\n", "<br>")
return self.md.renderInline(chat_message)
else:
raise ValueError(f"Invalid message for Chatbot component: {chat_message}")

View File

@ -1 +1 @@
3.24.0
3.24.1

View File

@ -1700,8 +1700,8 @@ class TestChatbot:
Postprocess, get_config
"""
chatbot = gr.Chatbot()
assert chatbot.postprocess([["You are **cool**", "so are *you*"]]) == [
["You are <strong>cool</strong>", "so are <em>you</em>"]
assert chatbot.postprocess([["You are **cool**\nand fun", "so are *you*"]]) == [
["You are <strong>cool</strong><br>and fun", "so are <em>you</em>"]
]
multimodal_msg = [