Haste171 / langchain-chatbot

AI Chatbot for analyzing/extracting information from data in conversational format.
MIT License
401 stars 88 forks source link

chromadb.errors.NoIndexException #20

Closed ambbone closed 1 year ago

ambbone commented 1 year ago

i've defined env variables with openai and pinecone. when I run the following command receive an error

python chatbot.py

Do you want to use Pinecone? (Y/N): y Not using Pinecone or empty Pinecone API key provided. Using Chroma instead Do you want to ingest? (Y/N): y No method given, passing Using embedded DuckDB with persistence: data will be stored in: ./vectorstore Please enter your question (or type 'exit' to end): how is bitcoin used? Traceback (most recent call last): File "C:\Users\antho\projects\langchain-chatbot\chatbot.py", line 135, in chat_loop() File "C:\Users\antho\projects\langchain-chatbot\chatbot.py", line 89, in chat_loop result = process({"question": query, "chat_history": chat_history}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\langchain\chains\base.py", line 116, in call raise e File "C:\python\Lib\site-packages\langchain\chains\base.py", line 113, in call outputs = self._call(inputs) ^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\langchain\chains\conversational_retrieval\base.py", line 79, in _call docs = self._get_docs(new_question, inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\langchain\chains\conversational_retrieval\base.py", line 146, in _get_docs docs = self.retriever.get_relevant_documents(question) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\langchain\vectorstores\base.py", line 225, in get_relevant_documents docs = self.vectorstore.similarity_search(query, **self.search_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\langchain\vectorstores\chroma.py", line 138, in similarity_search docs_and_scores = self.similarity_search_with_score(query, k, filter=filter) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\langchain\vectorstores\chroma.py", line 184, in similarity_search_with_score results = self._collection.query( ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\chromadb\api\models\Collection.py", line 202, in query return self._client._query( ^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\chromadb\api\local.py", line 247, in _query uuids, distances = self._db.get_nearest_neighbors( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\chromadb\db\clickhouse.py", line 520, in get_nearest_neighbors uuids, distances = index.get_nearest_neighbors(embeddings, n_results, ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\python\Lib\site-packages\chromadb\db\index\hnswlib.py", line 223, in get_nearest_neighbors raise NoIndexException("Index not found, please create an instance before querying") chromadb.errors.NoIndexException: Index not found, please create an instance before querying

ambbone commented 1 year ago

I'm using python version 3.11.3. Maybe there is a compatibility issue... * chromadb currently does not support Python 3.11 because of pytorch https://docs.trychroma.com/getting-started

ambbone commented 1 year ago

I realized y|n is case sensitive...

Do you want to use Pinecone? (Y/N): N Not using Pinecone or empty Pinecone API key provided. Using Chroma instead Do you want to ingest? (Y/N): Y Using embedded DuckDB with persistence: data will be stored in: ./vectorstore Finished Ingesting, stored at ./vectorstore Using embedded DuckDB with persistence: data will be stored in: ./vectorstore Please enter your question (or type 'exit' to end): what is bitcoin used for? AI: Bitcoin is a digital currency that can be used for various purposes such as online purchases, money transfers, and investments. It is decentralized, meaning that it is not controlled by any central authority or financial institu tion. Instead, it works on a peer-to-peer network, allowing individuals to transact directly with each other without the need for a middleman. Additionally, Bitcoin can be used for international transactions as it is not tied to any specific country or currency. Furthermore, some merchants accept Bitcoin as payment for goods and services.

I had to import for following to ingest.py...

from langchain.document_loaders import DirectoryLoader, PyMuPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import Chroma

Answer Citations Source: docs\white_paper.pdf Page Number: 10 Source: docs\white_paper.pdf Page Number: 1 Source: docs\white_paper.pdf Page Number: 10 Source: docs\white_paper.pdf Page Number: 11 Please enter your question (or type 'exit' to end):

Haste171 commented 1 year ago

In choosing the methods to use it is case sensitive. You need to use a capital Y for yes and capital N for no