Commit 2f7bd07b authored by Stergios Papadopoulos's avatar Stergios Papadopoulos
Browse files

- Added collection_exists at embedder class

- Future work: only save at collection the user question not the relevant context to save context window.
parent 76b99c23
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -388,6 +388,14 @@ class Embedder(Consts):

            fig.show()

    def collection_exists(self, collection_name):
        """
        Checks if a collection exists.
        :param collection_name: The name of the collection to check.
        :return: True if the collection exists, False otherwise.
        """
        return True if self._get_collection(collection_name) else False


embedder = Embedder()
# embedder.load_docs(directory="aiani dedomena/*", chunking_type=Embedder.ByChar)
+7 −2
Original line number Diff line number Diff line
@@ -139,12 +139,17 @@ class Generator:
    def get_conversation(self):
        pass


embedder = Embedder()
embedder.load_docs(directory="aiani dedomena/*", chunking_type=Embedder.ByChar)

if not embedder.collection_exists("Mycollection"):
    embedder.add_data("Mycollection")

gen = Generator(embedder=embedder, collection_name="Mycollection", n_results=5)

while True:
    gen.generate_answer(input("Ask a question: "), model="gpt-4o-mini")
    print("\n")


# embedder.visualize("Mycollection", dimensions=["2d", "3d"])