I would like users to be able to enter their own search string and not take the default. Ideally, the flow would be like google ...
User enters string
They start seeing default options
They decide they want their query to do the search
They hit enter
The suggestion should go away and their search term should stay in the search box
However, I can't get this to work. Here is the code ...
def search(query):
results = agent_client.search(query, data_sources=["GAO"])
titles = []
for result in results:
titles.append(result['title'])
titles = titles[0:4]
return titles
# Capture the suggestion or direct input
query = st_searchbox(
search_function=search,
default_use_searchterm=True,
placeholder="Type to search or press Enter to search for your input...",
min_execution_time=2,
label="search",
)
# Handling the free text search
if query:
# Check if query was typed without selecting suggestion
# Here you process the custom input
st.write(f"Searching for: {query}")
results = search(query) # If you need to search again with the entered text
st.write("Results:", results)
When the user hits enter, it automatically takes the first suggestion.
Is there a way to allow the user to use their own search query without defaulting to the first default when they hit enter?
I would like users to be able to enter their own search string and not take the default. Ideally, the flow would be like google ...
However, I can't get this to work. Here is the code ...
When the user hits enter, it automatically takes the first suggestion.
Is there a way to allow the user to use their own search query without defaulting to the first default when they hit enter?
Thanks!