-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearch.py
29 lines (25 loc) · 1.14 KB
/
search.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import streamlit as st
from utils import query_cortex_search_service
def show_search():
def search():
if "search" not in st.session_state:
st.session_state.search = ""
query = st.session_state.search
if query and len(query) > 0:
with st.spinner("Searching..."):
try:
_, results = query_cortex_search_service(query,
services=["CONVERSATION_SEARCH_SERVICE"],
limit=20)
_results = []
for r in results:
_results.append(r['CONVERSATION_ID'])
st.session_state.conversation_ids = list(set(_results))
except ValueError as e:
st.toast("Error occurred while searching. Please try again.")
else:
st.session_state.conversation_ids = []
st.text_input("Search",
key="search",
placeholder="Search (e.g. Nathan, DataOps, data security, pain points, etc.)",
on_change=search)