I created a simple app in streamlit which allows user to upload the document in pdf/txt file. The problem is I have to upload same file again and again. it will again convert into embeddings. when I ask question without uploading it gives me error.
I want without uploading I get what is in that specific namespace
Here is my pinecone code:
#for existing
pinecone.init(
api_key=pinecone_api_key, # find at app.pinecone.io
environment=pinecone_env # next to api key in console
)
index_name = “test”
namespaces =[‘docs’,‘docs1’]
selected_namespace = st.selectbox(“Select a namespace”, namespaces)
docs_chunks =
if len(uploaded_files) > 0:
for uploaded_file in uploaded_files:
print(‘File’,uploaded_files)
documents = process_file(uploaded_file)
print(‘Doc’,documents)
docs_chunks.append(documents)
all_documents_combined = combine_documents(docs_chunks)
docs_chunks = split_docs(all_documents_combined)
meta = [{'text': str(chunk.page_content)} for chunk in docs_chunks]
print('meta',meta)
# Upsert data into the selected namespace
# Create an index
index = pinecone.Index(index_name)
# Store the embeddings in the Pinecone index with metadata
to_upsert= [(f"doc-{i}", embeddings.embed_documents([chunk.page_content]), meta[i]) for i, chunk in enumerate(docs_chunks)]
index.upsert(vectors=to_upsert, namespace=selected_namespace)
index = Pinecone.from_documents(docs_chunks, embeddings, index_name=index_name,namespace=selected_namespace)
CAN YOU GUYS HELP?