Streamlit app runs fine on local Windows PC from command line but produces errors on streamlit.io

Hi,

GitHub - scooter7/web runs fine locally on my windows PC from command line.

But, running on streamlit.io produces the following errors:

Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/app/web/webqaapp.py", line 118, in <module>
    response = chatbot(input_text)
               ^^^^^^^^^^^^^^^^^^^
  File "/app/web/webqaapp.py", line 75, in chatbot
    response = chain(prompt)
               ^^^^^^^^^^^^^
  File "/home/appuser/venv/lib/python3.11/site-packages/langchain/chains/base.py", line 140, in __call__
    raise e
  File "/home/appuser/venv/lib/python3.11/site-packages/langchain/chains/base.py", line 134, in __call__
    self._call(inputs, run_manager=run_manager)
  File "/home/appuser/venv/lib/python3.11/site-packages/langchain/chains/qa_with_sources/base.py", line 127, in _call
    docs = self._get_docs(inputs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/appuser/venv/lib/python3.11/site-packages/langchain/chains/qa_with_sources/vector_db.py", line 50, in _get_docs
    docs = self.vectorstore.similarity_search(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/appuser/venv/lib/python3.11/site-packages/langchain/vectorstores/faiss.py", line 226, in similarity_search
    docs_and_scores = self.similarity_search_with_score(query, k)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/appuser/venv/lib/python3.11/site-packages/langchain/vectorstores/faiss.py", line 196, in similarity_search_with_score
    docs = self.similarity_search_with_score_by_vector(embedding, k)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/appuser/venv/lib/python3.11/site-packages/langchain/vectorstores/faiss.py", line 170, in similarity_search_with_score_by_vector
    scores, indices = self.index.search(np.array([embedding], dtype=np.float32), k)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: IndexFlat.search() missing 3 required positional arguments: 'k', 'distances', and 'labels'

The streamlit app can be found at https://scooter7-web-webqaapp-z4qer5.streamlit.app/

It is bug in langchain of FAISS. See:

Solution is to recreate your embeddings in the environment you run you code.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.