from utlis.helper import * import sqlite3 import hashlib import io initialize_session_state() with st.sidebar: st.image("logo.png", width=170) st.title("Config Settings") # Get List of models st.session_state.genre = st.radio( "Choose option", [ "Select Service", "Add service"])#,"Delete service"]) if st.session_state.genre=="Add service": st.title('Add service') # Check service status # Get all available services add_new_service = st.checkbox("Add new service") if add_new_service: new_service = st.text_input("Enter service name") # Get list of Embedding models if new_service and st.button('Add'): add_service(st.session_state.token,new_service) data = {"token": st.session_state.token} json_data = json.dumps(data) headers = {'Content-Type': 'application/json'} services = requests.get(SERVICES_API,data=json_data, headers=headers) services =json.loads(services.text) if len(services)>0: st.session_state.service = st.selectbox("Choose Service",services) st.session_state.uploaded_files = st.file_uploader("Upload CVs", type=["pdf","doc"], accept_multiple_files=True) if st.session_state.uploaded_files: st.session_state.process = st.button('Process') if st.session_state.process: with st.spinner("Processing..."): add_document(st.session_state.token,st.session_state.service) elif st.session_state.genre=="Select Service": st.title('Choose Service') data = {"token": st.session_state.token} json_data = json.dumps(data) headers = {'Content-Type': 'application/json'} services = requests.get(SERVICES_API,data=json_data, headers=headers) services =json.loads(services.text) if len(services)>0: st.session_state.service_slected_to_chat = st.selectbox(" ",services) st.session_state.top_k=st.slider("Number of Candidates", min_value=1, max_value=10, value=3, step=1) # data = {"token": st.session_state.token, "servicename": st.session_state.service_slected_to_chat} # json_data = json.dumps(data) # headers = {'Content-Type': 'application/json'} # history_document = requests.get(DOCUMENT_API,data=json_data, headers=headers) # history_document =json.loads(history_document.text).get("documents",[]) # history_document = [doc["documentname"] for doc in history_document] # elif st.session_state.genre == "Delete service": # st.title('Delete Service') # data = {"token": st.session_state.token} # json_data = json.dumps(data) # headers = {'Content-Type': 'application/json'} # services = requests.get(SERVICES_API,data=json_data, headers=headers) # services =json.loads(services.text) # if len(services)>=2: # services.append("ALL") # # Get list of documents from histrory # if "ALL" in services: # service_slected = st.multiselect( # "",services ,default="ALL" # ) # elif len(services)==1: # service_slected = st.multiselect( # "",services,default=services[0] # ) # else: # service_slected = st.multiselect( # "",services # ) # if "ALL" in service_slected: # service_slected = services # service_slected.remove("ALL") # st.write("You selected:", service_slected) # if len(service_slected) > 0: # st.session_state.delete = st.button('Delete') # if st.session_state.delete: # delete_service(st.session_state.token ,service_slected) # elif st.session_state.genre == "Delete CV(s)": # st.title('Delete CV(s)') # data = {"token": st.session_state.token} # json_data = json.dumps(data) # headers = {'Content-Type': 'application/json'} # services = requests.get(SERVICES_API,data=json_data, headers=headers) # services =json.loads(services.text) # if len(services)>0: # service = st.selectbox("Choose Service",services) # data = {"token": st.session_state.token, "servicename": service} # json_data = json.dumps(data) # headers = {'Content-Type': 'application/json'} # st.write("You selected:", document_slected_to_delete) # if len(document_slected_to_delete) > 0: # st.session_state.delete = st.button('Delete') # if st.session_state.delete: # delete_document(st.session_state.token,st.session_state.service ,document_slected_to_delete) # css_style = """ # # """ # st.markdown(css_style, unsafe_allow_html=True) st.markdown(""" """, unsafe_allow_html=True) with st.container(): st.markdown('
Score: {round(item['score']*100, 3)}%
Document Name: {item['documentname'].replace('_pdf', ' ')}