From 41a1dbab0ec8fafb1e87c8efdd67efd9e7f80d10 Mon Sep 17 00:00:00 2001 From: cachho Date: Fri, 7 Jul 2023 11:01:14 +0200 Subject: [PATCH] feat: add count to get document count in vector db (#164) --- README.md | 8 ++++++++ embedchain/embedchain.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 4636f841..d9d7c7da 100644 --- a/README.md +++ b/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 diff --git a/embedchain/embedchain.py b/embedchain/embedchain.py index 2835171e..d3cf0ae4 100644 --- a/embedchain/embedchain.py +++ b/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): """