浏览代码

feat: add count to get document count in vector db (#164)

cachho 2 年之前
父节点
当前提交
41a1dbab0e
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 8 0
      README.md
  2. 8 0
      embedchain/embedchain.py

+ 8 - 0
README.md

@@ -332,6 +332,14 @@ Resets the database and deletes all embeddings. Irreversible. Requires reinitial
 app.reset()
 ```
 
+### Count
+Counts the number of embeddings (chunks) in the database.
+
+```
+print(app.count())
+# returns: 481
+```
+
 # How does it work?
 
 Creating a chat bot over any dataset needs the following steps to happen

+ 8 - 0
embedchain/embedchain.py

@@ -298,6 +298,14 @@ class EmbedChain:
         prompt = self.generate_prompt(input_query, context)
         return prompt
 
+    def count(self):
+        """
+        Count the number of embeddings.
+
+        :return: The number of embeddings.
+        """
+        return self.collection.count()
+
 
     def reset(self):
         """