in sample_app/cerebral_genai/code/rag-on-edge-web/page_vector_search.py [0:0]
def query_retrieval():
global number_of_check
#st.title('Please input your question and press enter to search:')
with st.sidebar:
st.title("User Account")
st.write(f"**name:** user 1")
st.write(f"**role:** Plant manager")
st.write(f"**location:** Factory Monterrey")
st.write(f"Production line: 5")
st.title("FAQ")
for item in faq:
#st.markdown(f"**persona:** {item['persona']}")
st.write(f"**question:** {item['question']}")
with st.spinner(text="Loading..."):
col1.subheader('Chat history')
col2.subheader('User configurations')
# get the index names from the backend VDB module
index_names = requests.get('http://rag-vdb-service:8602/list_index_names').json()['index_names']
index_name = col2.selectbox('**Please select an index name:**',index_names)
col2.write('You selected:')
col2.write(index_name)
resp_timeout = col2.text_input('**Please input response timeout in seconds (default 100s):**', 100)
number_of_check = int(resp_timeout) if resp_timeout else 100
# Display chat messages from history on app rerun
for message in st.session_state.conversation_history:
with col1.chat_message(message["role"]):
col1.markdown(message["content"])
prompt = st.chat_input("Please input your question here:")#st.chat_input() can't be used inside an st.expander, st.form, st.tabs, st.columns, or st.sidebar
if prompt and index_name:
# Display user message in chat message container
with col1.chat_message("user"):
col1.markdown(prompt)
st.session_state.conversation_history.append({"role": "user", "content": prompt})
with st.spinner(text="Document Searching..."):
retrieval_prepped = retrieval_prompt.replace('SEARCH_QUERY_HERE',prompt)
#st.write(f"{retrieval_prepped}\n\n")
user_input_json = {'user_query': prompt, 'index_name': index_name}
publish_user_input(user_input_json)