Closed sergerdn closed 1 year ago
I tested the query with the client
, but I received the same error.
def query_chromadb_direct():
client_settings = chromadb.config.Settings(
chroma_db_impl="duckdb+parquet",
persist_directory=DB_DIR,
anonymized_telemetry=False
)
client = chromadb.Client(settings=client_settings)
collection = client.get_collection("langchain_store")
embeddings = OpenAIEmbeddings()
results = collection.query(
query_embeddings=embeddings.embed_query("FREDERICK"),
n_results=2,
)
print(results)
C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\chatpine-dataloader-GLxZdGXB-py3.10\Scripts\python.exe D:\Projects\ChatPine\ChatPine-DataLoader\main_chromadb.py
INFO:chromadb:Running Chroma using direct local API.
WARNING:chromadb:Using embedded DuckDB with persistence: data will be stored in: D:\Projects\ChatPine\ChatPine-DataLoader\db
INFO:clickhouse_connect.driver.ctypes:Successfully imported ClickHouse Connect C data optimizations
INFO:clickhouse_connect.driver.ctypes:Successfully import ClickHouse Connect C/Numpy optimizations
INFO:clickhouse_connect.json_impl:Using python library for writing JSON byte strings
INFO:chromadb.db.duckdb:loaded in 56 embeddings
INFO:chromadb.db.duckdb:loaded in 1 collections
WARNING:chromadb.api.models.Collection:No embedding_function provided, using default embedding function: SentenceTransformerEmbeddingFunction
INFO:sentence_transformers.SentenceTransformer:Load pretrained SentenceTransformer: all-MiniLM-L6-v2
INFO:sentence_transformers.SentenceTransformer:Use pytorch device: cpu
DEBUG:openai:message='Request to OpenAI API' method=post path=https://api.openai.com/v1/engines/text-embedding-ada-002/embeddings
DEBUG:openai:api_version=None data='{"input": ["FREDERICK"], "encoding_format": "base64"}' message='Post details'
DEBUG:openai:message='OpenAI API response' path=https://api.openai.com/v1/engines/text-embedding-ada-002/embeddings processing_ms=15 request_id=efcbef269f83499e492a4093cffee704 response_code=200
DEBUG:chromadb.db.index.hnswlib:time to pre process our knn query: 0.0
DEBUG:chromadb.db.index.hnswlib:time to run knn query: 0.0
Traceback (most recent call last):
File "D:\Projects\ChatPine\ChatPine-DataLoader\main_chromadb.py", line 89, in <module>
main()
File "D:\Projects\ChatPine\ChatPine-DataLoader\main_chromadb.py", line 85, in main
query_chromadb_direct()
File "D:\Projects\ChatPine\ChatPine-DataLoader\main_chromadb.py", line 74, in query_chromadb_direct
results = collection.query(
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\chatpine-dataloader-GLxZdGXB-py3.10\lib\site-packages\chromadb\api\models\Collection.py", line 203, in query
return self._client._query(
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\chatpine-dataloader-GLxZdGXB-py3.10\lib\site-packages\chromadb\api\local.py", line 247, in _query
uuids, distances = self._db.get_nearest_neighbors(
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\chatpine-dataloader-GLxZdGXB-py3.10\lib\site-packages\chromadb\db\clickhouse.py", line 521, in get_nearest_neighbors
uuids, distances = index.get_nearest_neighbors(embeddings, n_results, ids)
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\chatpine-dataloader-GLxZdGXB-py3.10\lib\site-packages\chromadb\db\index\hnswlib.py", line 250, in get_nearest_neighbors
ids = [[self._label_to_id[label] for label in labels] for labels in database_labels]
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\chatpine-dataloader-GLxZdGXB-py3.10\lib\site-packages\chromadb\db\index\hnswlib.py", line 250, in <listcomp>
ids = [[self._label_to_id[label] for label in labels] for labels in database_labels]
File "C:\Users\Administrator\AppData\Local\pypoetry\Cache\virtualenvs\chatpine-dataloader-GLxZdGXB-py3.10\lib\site-packages\chromadb\db\index\hnswlib.py", line 250, in <listcomp>
ids = [[self._label_to_id[label] for label in labels] for labels in database_labels]
KeyError: 8
INFO:chromadb.db.duckdb:PersistentDuckDB del, about to run persist
INFO:chromadb.db.duckdb:Persisting DB to disk, putting it in the save folder: D:\Projects\ChatPine\ChatPine-DataLoader\db
Process finished with exit code 1
I ran poetry update
to update the package from Git to the latest version, and it appears to have fixed my code.
I think that some of your latest commit, fixed my code.
What am I missing here? I'm not sure if I posted it in the right project, it might be a bug on the LangChain side.