|
import streamlit as st |
|
|
|
|
|
|
|
if not 'model' in st.session_state: |
|
st.session_state.model = SearchEngine() |
|
st.title('Search ') |
|
|
|
|
|
st.write('---') |
|
st.subheader('Indexed Prompts:') |
|
if len(st.session_state.model.prompts) > 0: |
|
for id, prompt in enumerate(st.session_state.model.prompts, 1): |
|
st.info(f'{id}. {prompt}') |
|
else: |
|
st.write('No prompts yet.') |
|
|
|
|
|
|
|
st.write('---') |
|
st.subheader('Input Prompt:') |
|
input_prompt = st.text_area('Enter a prompt to save or match:', height=150) |
|
|
|
|
|
|
|
col1, col2 = st.columns(2) |
|
|
|
with col1: |
|
if st.button('Save', use_container_width=True): |
|
st.session_state.model.add(input_prompt) |
|
st.success('Saved successfully!') |
|
st.rerun() |
|
|
|
with col2: |
|
if st.button('Match', use_container_width=True): |
|
if len(st.session_state.model.vectors) > 0: |
|
match = st.session_state.model.search(input_prompt) |
|
st.success(f'Result: {match}') |
|
else: |
|
st.warning('Nothing to match against.') |
|
|