While using ObjectBox as a Vectorstore I got this error: “CoreException: 10001 (ILLEGAL_STATE) – Cannot open store” What should I do?

  Kiến thức lập trình

I was trying to make a simple Q/A app with RAG with ObjectBox as the vector store.
I have
This is the code I was using:

import streamlit as st
import os
from langchain_groq import ChatGroq
from langchain_community.document_loaders import PyPDFDirectoryLoader
from langchain_community.embeddings import OllamaEmbeddings
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.chains.combine_documents import create_stuff_documents_chain
from langchain_core.prompts import ChatPromptTemplate
from langchain.chains import create_retrieval_chain
from langchain_objectbox.vectorstores import ObjectBox
import time

groq_api_key = "The Groq API Key"

st.title("Objectbox VectorsstoreDB with Llama3")

llm = ChatGroq(groq_api_key=groq_api_key, model_name="Llama3-8b-8192")

prompt = ChatPromptTemplate.from_template(
    """
    Answer the questions based on the provided context only.
    Please provide te most accurate response based on the question
    <<context>>
    {context}
    <<context>>
    Questions: {input}
"""
)

if "vector" not in st.session_state:
        st.session_state.embeddings=OllamaEmbeddings()
        st.session_state.loader = PyPDFDirectoryLoader("./us_census") # Data Ingestion
        st.session_state.docs = st.session_state.loader.load() # Document loading
        st.session_state.text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000,chunk_overlap=200) # Chunk Creation
        st.session_state.final_documents = st.session_state.text_splitter.split_documents(st.session_state.docs[:20]) # Splitting
        st.session_state.vectors = ObjectBox.from_documents(st.session_state.final_documents,st.session_state.embeddings,embedding_dimensions=768) # Vector Ollama embeddings
        print("hi")

input_prompt = st.text_input("Input Prompt")

if st.button("Documents Embedding"):
    #vector_embedding()
    st.write("Vector Store DB is Ready")

if input_prompt:
    document_chain = create_stuff_documents_chain(llm,prompt)
    retriever = st.session_state.vectors.as_retriever()
    retrieval_chain = create_retrieval_chain(retriever,document_chain)
    start = time.process_time()
    response = retrieval_chain.invoke({"input":input_prompt})
    print("Response time:",time.process_time()-start)
    st.write(response['answer'])

    # Streamlit expander
    with st.expander("Doc similarity search"):
        # finding relevant chunks
        for i, doc in enumerate(response["context"]):
            st.write(doc.page_content)
            st.write("-------------------------")

Error Message

After I entered an input through the streamlit input text box, This is the error I got:

CoreException: 10001 (ILLEGAL_STATE) – Cannot open store: another store is still open using the same path: “C:UsersRISHAV BHATTACHARJEEDesktopRB WorkbaseGenerative-AILangchainObjectBoxobjectbox”
Traceback:
File “C:UsersRISHAV BHATTACHARJEEanaconda3Libsite-packagesstreamlitruntimescriptrunnerscript_runner.py”, line 584, in _run_script
exec(code, module.dict)
File “C:UsersRISHAV BHATTACHARJEEDesktopRB WorkbaseGenerative-AILangchainObjectBoxapp.py”, line 38, in
st.session_state.vectors = ObjectBox.from_documents(st.session_state.final_documents,st.session_state.embeddings,embedding_dimensions=768) # Vector Ollama embeddings
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersRISHAV BHATTACHARJEEanaconda3Libsite-packageslangchain_corevectorstores.py”, line 550, in from_documents
return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersRISHAV BHATTACHARJEEanaconda3Libsite-packageslangchain_objectboxvectorstores.py”, line 215, in from_texts
ob = cls(embedding, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersRISHAV BHATTACHARJEEanaconda3Libsite-packageslangchain_objectboxvectorstores.py”, line 52, in init
self._db = self._create_objectbox_db()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersRISHAV BHATTACHARJEEanaconda3Libsite-packageslangchain_objectboxvectorstores.py”, line 252, in _create_objectbox_db
return objectbox.Store(model=model,directory=db_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersRISHAV BHATTACHARJEEanaconda3Libsite-packagesobjectboxstore.py”, line 168, in init
self._c_store = c.obx_store_open(options._c_handle)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:UsersRISHAV BHATTACHARJEEanaconda3Libsite-packagesobjectboxc.py”, line 295, in check_result
raise CoreException(C.obx_last_error_code())

New contributor

Rishav Bhattacharjee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT