The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
[Bug Fix] fix chromadb where clause for query and delete (#937)
Deven Pateldeaa7f50f84b
diff --git a/embedchain/apps/app.py b/embedchain/apps/app.pyindex 63a44f370..38cfdd86d 100644--- a/embedchain/apps/app.py+++ b/embedchain/apps/app.py@@ -3,7 +3,8 @@ from typing import Optionalimport yamlfrom embedchain.client import Client-from embedchain.config import AppConfig, BaseEmbedderConfig, BaseLlmConfig, ChunkerConfig+from embedchain.config import (AppConfig, BaseEmbedderConfig, BaseLlmConfig,+ ChunkerConfig)from embedchain.config.vectordb.base import BaseVectorDbConfigfrom embedchain.embedchain import EmbedChainfrom embedchain.embedder.base import BaseEmbedderdiff --git a/embedchain/bots/base.py b/embedchain/bots/base.pyindex db3bd4339..a804b71b0 100644--- a/embedchain/bots/base.py+++ b/embedchain/bots/base.py@@ -1,9 +1,10 @@from typing import Anyfrom embedchain import Pipeline as App-from embedchain.config import AddConfig, PipelineConfig, BaseLlmConfig+from embedchain.config import AddConfig, BaseLlmConfig, PipelineConfigfrom embedchain.embedder.openai import OpenAIEmbedder-from embedchain.helper.json_serializable import JSONSerializable, register_deserializable+from embedchain.helper.json_serializable import (JSONSerializable,+ register_deserializable)from embedchain.llm.openai import OpenAILlmfrom embedchain.vectordb.chroma import ChromaDBdiff --git a/embedchain/embedchain.py b/embedchain/embedchain.pyindex 84ac5ff74..a764d13f9 100644--- a/embedchain/embedchain.py+++ b/embedchain/embedchain.py@@ -478,13 +478,13 @@ class EmbedChain(JSONSerializable):query_config = config or self.llm.configif where is not None:where = where- elif query_config is not None and query_config.where is not None:- where = query_config.whereelse:where = {}-- if self.config.id is not None:- where.update({"app_id": self.config.id})+ if query_config is not None and query_config.where is not None:+ where = query_config.where++ if self.config.id is not None:+ where.update({"app_id": self.config.id})# We cannot query the database with the input query in case of an image search. This is because we need# to bring down both the image and text to the same dimension to be able to compare them.diff --git a/embedchain/vectordb/chroma.py b/embedchain/vectordb/chroma.pyindex e86651f36..120b7170d 100644--- a/embedchain/vectordb/chroma.py+++ b/embedchain/vectordb/chroma.py@@ -77,7 +77,7 @@ class ChromaDB(BaseVectorDB):def _generate_where_clause(self, where: Dict[str, any]) -> str:# If only one filter is supplied, return it as is# (no need to wrap in $and based on chroma docs)- if len(where.keys()) == 1:+ if len(where.keys()) <= 1:return wherewhere_filters = []for k, v in where.items():@@ -224,7 +224,7 @@ class ChromaDB(BaseVectorDB):input_query,],n_results=n_results,- where=where,+ where=self._generate_where_clause(where),)else:result = self.collection.query(@@ -232,7 +232,7 @@ class ChromaDB(BaseVectorDB):input_query,],n_results=n_results,- where=where,+ where=self._generate_where_clause(where),)except InvalidDimensionException as e:raise InvalidDimensionException(@@ -275,7 +275,7 @@ class ChromaDB(BaseVectorDB):return self.collection.count()def delete(self, where):- return self.collection.delete(where=where)+ return self.collection.delete(where=self._generate_where_clause(where))def reset(self):"""diff --git a/pyproject.toml b/pyproject.tomlindex d876fc84e..6b6b391f3 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "embedchain"-version = "0.1.5"+version = "0.1.6"description = "Data platform for LLMs - Load, index, retrieve and sync any unstructured data"authors = ["Taranjeet Singh <[email protected]>",