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

Allow inline usage of st.chat_input #7896

Merged
merged 39 commits into from Jan 22, 2024
Merged

Conversation

LukasMasuch
Copy link
Collaborator

@LukasMasuch LukasMasuch commented Jan 3, 2024

Describe your changes

This PR enables st.chat_input to be used inline in addition to the usage pinned to the bottom of the app. This is activated if the chat_input is nested with any other layout container (e.g. st.container, st.columns, st.expander, st.sidebar):

with st.container():
    st.chat_input("Whats up?")

Demo: https://inline-chat-input-demo.streamlit.app/

GitHub Issue Link (if applicable)

Testing Plan

  • Updated unit tests
  • Migrate cypress e2e tests to playwright

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

lib/streamlit/__init__.py Dismissed Show dismissed Hide dismissed
@LukasMasuch LukasMasuch marked this pull request as ready for review January 5, 2024 17:46
@sfc-gh-wihuang sfc-gh-wihuang self-assigned this Jan 5, 2024
Copy link
Collaborator

@vdonato vdonato left a comment

Choose a reason for hiding this comment

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

Proto changes LGTM

@LukasMasuch LukasMasuch changed the title Allow inline usage of chat input Allow inline usage of st.chat_input Jan 18, 2024
@LukasMasuch LukasMasuch merged commit fd38b18 into develop Jan 22, 2024
40 checks passed
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
* Add initial version of inline chat input

* Adapt python test

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Remove unused import

* Remove e2e tests

* Fix test id names

* Improve playwright conftest

* Format conftest

* Update tests

* Fix unembedded iframe

* Update snapshots

* Add e2e test script

* Add e2e tests

* Add updated snapshots

* Finalize test

* Revert toast change

* Fixes and improvements

* Add missing snapshots

* Update snapshots

* Fix observer effect

* Fix flickering effects

* Fix typo

* Fix comments

* Fix test

* Remove position parameter from API

* Update example

* Fix unit tests
@karthickk17
Copy link

Is it possible to share the source code of the demo file? It will be really useful for reference. I am trying to add a chat_input() within tabs and the chat_input() keeps moving up.

@LukasMasuch
Copy link
Collaborator Author

You need to put the new messages into a container that is above the chat_input, e.g.:

import streamlit as st

with st.sidebar:
    messages = st.container(height=300)
    if prompt := st.chat_input("Say something"):
        messages.chat_message("user").write(prompt)
        messages.chat_message("assistant").write(f"Echo: {prompt}")

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.

Allow st.chat_input to be inside a container (i.e. have it above other elements)
4 participants