Skip to content

Commit

Permalink
change layout: suggestions after info text
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusschiesser committed Sep 18, 2023
1 parent c91422a commit d6166e6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions streamlit_examples/wiki_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,31 @@ def render_suggestions():
st.button(suggestions[i], on_click=set_query, args=[suggestions[i]])


st.title("Search Wikipedia")
def render_query():
user_query = st.chat_input(placeholder="Backpacking in Asia")
if user_query:
st.session_state.user_query = user_query

render_suggestions()
user_query = st.chat_input(placeholder="Backpacking in Asia")
if user_query:
st.session_state.user_query = user_query

user_query = st.session_state.user_query
if not user_query:
st.title("Search Wikipedia")

if not st.session_state.user_query:
st.info(
"Search Wikipedia and summarize the results. Type a query to start or pick one of the suggestions."
"Search Wikipedia and summarize the results. Type a query to start or pick one of these suggestions:"
)
render_suggestions()
render_query()

if not st.session_state.user_query:
st.stop()

root = st.empty()
with root.status("Querying vector store..."):
items = search_wikipedia(user_query, limit=10)
items = search_wikipedia(st.session_state.user_query, limit=10)
# aggregate items with same url (as vector DB might return multiple items for same url)
items = aggregate(items)[0:3]
container = root.container()
container.write(f"That's what I found about: _{user_query}_")
container.write(f"That's what I found about: _{st.session_state.user_query}_")

placeholders = []
for i, item in enumerate(items):
Expand Down

0 comments on commit d6166e6

Please sign in to comment.