My application takes a query, runs it through the model and answers the query. I want to add an option where the user can see suggestion from a dropdown and if selected directly outputs the answer, but if a user doesnt select from the dropdown, they can type their own query which will run through the model
The drop down suggestion will be coming from this csv file, column = “question”
2 Likes
Hi @Hiba_Fatima , and welcome to the Streamlit community!
Auto completion wouldn’t be possible, however you can pass a list of values from your csv, as follows:
df = pd.read_csv('data.csv')
col_one_list = df['one'].tolist()
selectbox_01 = st.selectbox('Select', col_one_list)
Would that be ok for your use case?
Best,
Charly
1 Like
hey @Charly_Wargnier
What I am hoping too achieve is, that it also allows a user to input a question, if not selected from the dropdown/list
2 Likes
Sure @Hiba_Fatima
For text inputs, you can use:
st.text_input('Enter some text')
Let us know how it goes!
Thanks,
Charly
1 Like
@Charly_Wargnier st.text_input, is what I used initially,
What I need is:
user would like a pre-canned list, but the option to enter anything custom (a question that wasnt there in the list).
It would be great if the selectbox can be also used as text_input
is there a way around this?
3 Likes
@Charly_Wargnier
I was hoping something along these line, where you can choose a query from the dropdown list, but if you dont find your query in the dropdown, you can go ahead and enter your own query.
Wherein (text_input) only lets you input a query, and st.selectbox only lets you pick the query from a given list.
I did go through streamlit tags, doesnt apply to my use case!
Kind Regards
As I said above, auto-complete is not yet available in Streamlit.
I’ll pass your suggestion to the Devs
Best,
Charly
1 Like
@Hiba_Fatima
Streamlit tags does offer a different style of auto-complete check it
3 Likes
Wow! This is amazing!
Is the auto completion based on a pre defined list?
Yes, we can define it based on a predefined list:
def st_tags(value: list,
suggestions: list,
label: str,
text: str,
maxtags: int,
key=None) -> list:
'''
:param maxtags: Maximum number of tags allowed maxtags = -1 for unlimited entries
:param suggestions: (List) List of possible suggestions (optional)
:param label: (Str) Label of the Function
:param text: (Str) Instructions for entry
:param value: (List) Initial Value (optional)
:param key: (Str)
An optional string to use as the unique key for the widget.
Assign a key so the component is not remount every time the script is rerun.
:return: (List) Tags
Note: usage also supports keywords = st_tags()```
3 Likes
This is great!
thanks for creating this Gagan!
1 Like
Streamlit_tags has not got a lot reach so far
Thank you @Charly_Wargnier for sharing about it here!
1 Like
You’re very welcome! Well deserved!
Streamlit_tags is a great component though, I still think it should be officially incorporated into Streamlit
1 Like
Lisa
January 27, 2024, 9:58am
16
Is there any update on a native implementation for this feature?
1 Like
I am also very interested in this feature
Make sure you vote on the open issues so the devs can track popularity of feature requests:
opened 07:43PM - 13 Sep 22 UTC
type:enhancement
feature:st.multiselect
status:likely
### Problem
I'm building a small CRUD application with database behind it. Ab… solutely love how Streamlit works and allows to use Python everywhere, but once it comes to the ability to enter new information - currently available components are lacking.
One of use cases is tag-like fields. I need user to be able to select multiple existing tags with autocompletion - and multiselect is awesome there. But once user needs to add a new tag - basically there are only 2 ways: either to have a 2nd text field nearby (looks ugly), or to have a separate subpage for tags addition (even worse, as user has to navigate off his work).
### Solution
**MVP:** I'd llike to propose a minimal change - an option for multiselect to **allow new input from user**, which is not on options, confirmed with enter. With this option enabled - return new value as part of results. Dev checks if there are any items returned, which were not on original list of options - and then decides what to do with that. I believe this will require minimal changes, but this will greatly expand Streamlit use cases.
**Preferred solution:** It would be great to expand other means to enter information too. Streamlit has gone a long way from Jupyter replacement to nearly full-featured web app framework. Ideally I'd love to see better user input support, including editable / clickable / selectable tables, and options to allow new input for other components, like selectbox (or maybe just an option to **limit number** of inputs on multiselect - with max=1 that could be a replacement for selectbox, which also allows no selection and new user input, as described above).
### Additional context
There's a 3rd party streamlit-tags component, but it really lacks the polish, lacks proper suggestions by partial match, it has different theming.
### Voting for feature requests
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
**If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.**
opened 08:34AM - 25 Jul 23 UTC
type:enhancement
feature:st.chat_input
### Problem
The new `chat_input` element is great for chatbot apps. It would … be very useful if it can give user suggestions when inputting.
Some feature requests (#6604, #5602) were submitted for the `text_input` element. And then they were suggested to use `streamlit-searchbox` as alternative.
Since official `chat_input` has been shinny released, I think it's good timing to bring the autocomplete feature to it.
Thanks.
---
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
**If you'd like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.**
Also, for anyone late to the party, there is a related custom component: New Component: Searchbox
Hello @Hiba_Fatima , did you find a solution for this?
Kind Regards