|
import streamlit as st |
|
import utils.admin_utils as au |
|
|
|
def main(): |
|
|
|
if 'PINECONE_API_KEY' not in st.session_state: |
|
st.session_state['PINECONE_API_KEY'] = '' |
|
|
|
st.set_page_config("Dump PDF to Pinecone - Vector Store") |
|
st.title("Please upload your files...📁") |
|
|
|
st.sidebar.title("😎🗝️") |
|
st.session_state['PINECONE_API_KEY' ]= st.sidebar.text_input("What's your Pinecone API key?",type="password") |
|
|
|
pdf = st.file_uploader("Only PDF files allowed...", type=['pdf']) |
|
|
|
if pdf and st.session_state['PINECONE_API_KEY']: |
|
with st.spinner("Wait...."): |
|
|
|
text = au.read_pdf(pdf) |
|
st.write("👉Reading PDF done") |
|
chunks = au.split_data(text) |
|
st.write("👉Splitting data into chunks done") |
|
embedder = au.initiate_embedder() |
|
st.write("👉Creating embeddings instance done") |
|
|
|
au.push_to_pinecone(st.session_state['PINECONE_API_KEY'], 'tickets', embedder, chunks) |
|
st.success("Successfully pushed the embeddings to Pinecone") |
|
else: |
|
if not st.session_state['PINECONE_API_KEY']: |
|
st.error("Please provide pinecone API key") |
|
else: |
|
st.error("Please provide a PDF file") |
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
main() |