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

Add Streamlit Chat Migration Guide #5642

Closed
wants to merge 21 commits into from

Conversation

MarcSkovMadsen
Copy link
Collaborator

@MarcSkovMadsen MarcSkovMadsen commented Oct 16, 2023

Builds on top of #5633.

This PR adds a Streamlit Chat Migration Guide. It will

Preview the guide here

FYI. @ahuang11

Questions

  • Should we rename ChatEntry to ChatMessage. Both Streamlit and LangChain use the term message. For example st.chat_message. The ChatEntry name could also mistakingly be interpreted as a chat_input like component?
  • Should we provide a ChatInput component similar to Streamlits chat_input?
  • Should we provide a Status component similar to Streamlits status?

Todo:

  • Merge with main and rename ChatEntry to ChatMessage. Rename ChatMessage.value to .object and ChatFeed.value to .objects.
  • Philipp should upload the assets and replace the links.

@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

Merging #5642 (872b744) into main (db1e9fe) will decrease coverage by 0.05%.
Report is 2 commits behind head on main.
The diff coverage is 91.23%.

@@            Coverage Diff             @@
##             main    #5642      +/-   ##
==========================================
- Coverage   83.65%   83.61%   -0.05%     
==========================================
  Files         280      288       +8     
  Lines       41580    41678      +98     
==========================================
+ Hits        34782    34847      +65     
- Misses       6798     6831      +33     
Flag Coverage Δ
ui-tests 39.63% <28.09%> (+0.05%) ⬆️
unitexamples-tests 73.72% <91.23%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
panel/__init__.py 100.00% <100.00%> (ø)
panel/chat/__init__.py 100.00% <100.00%> (ø)
panel/tests/chat/test_entry.py 100.00% <100.00%> (ø)
panel/tests/chat/test_feed.py 100.00% <100.00%> (ø)
panel/tests/chat/test_icon.py 100.00% <100.00%> (ø)
panel/tests/chat/test_interface.py 100.00% <100.00%> (ø)
panel/widgets/__init__.py 100.00% <ø> (ø)
panel/chat/icon.py 92.64% <92.64%> (ø)
panel/chat/interface.py 95.45% <95.45%> (ø)
panel/chat/feed.py 95.06% <95.06%> (ø)
... and 3 more

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more


Below we will show you how to build a custom `ChatInput` widget.

```python
Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a component like this to Panels chat components @ahuang11 and @philippjfr ?


Below we will show you how to build a custom `ChatInput` widget.

```python
Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This custom Viewer component also shows some of the challenges it has.

  • The component is not and cannot be used as a widget. I.e. you need to pn.bind to and pn.depends on chat_input.param.value not chat_input. There is no .from_param method etc.
  • It takes a lot of boiler plate code to separate the viewer params from the _layout params. And getting sizing_mode, width, ... properly linked up to the _layout is almost impossible.

I.e. you can make custom components using Viewer. But I can't see how you can create something that Panel would be willing to include as a proper widget without really a lot of code.

@@ -0,0 +1,145 @@
# Create Chat Interfaces
Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asset for upload

streamlit-status

panel-status

Below we will show you how to build a custom `Status` indicator.

```python
import time
Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a Status component like this to Panel?

If yes, we should consider How we want to show this status if we have not yet started a run. Should it be disabled, not visible or have some custom look?

The current implementation accepts str steps only. That is probably not what we want if we add it to Panel. It should probably accept as a minimum Markdown and at best any Panel component.

The steps should probably not be constant.

Copy link
Collaborator Author

@MarcSkovMadsen MarcSkovMadsen Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe object and objects would be more in line with Panels naming convention than step and steps?

@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Oct 16, 2023

I will be on holiday for the next 3 days. I believe what is here is self contained and ready to include if you decide to release the Chat components within the next 3 days.

I plan to add more examples like CallbackHandler when I get back from holiday.

@MarcSkovMadsen MarcSkovMadsen mentioned this pull request Oct 17, 2023
37 tasks
@philippjfr
Copy link
Member

Superseded by #5670

@philippjfr philippjfr closed this Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants