From d68c0320abae49096a37342428b6e31ca69f7054 Mon Sep 17 00:00:00 2001 From: Koala Yeung Date: Tue, 26 Nov 2024 19:06:24 +0800 Subject: [PATCH 1/4] Fix requirements.txt --- 2024-09-10-buildrag/python/requirements.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/2024-09-10-buildrag/python/requirements.txt b/2024-09-10-buildrag/python/requirements.txt index e2b6b07..5e16609 100644 --- a/2024-09-10-buildrag/python/requirements.txt +++ b/2024-09-10-buildrag/python/requirements.txt @@ -1,3 +1,2 @@ -chromadb -os -re \ No newline at end of file +ollama>=0.4.1 +chromadb>=0.5.20 From 9a66ff920407106a553ca1a5a1125c7938f8514a Mon Sep 17 00:00:00 2001 From: Koala Yeung Date: Tue, 26 Nov 2024 19:07:10 +0800 Subject: [PATCH 2/4] Ignore some python related folders --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index c93114e..0bcd514 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,9 @@ node_modules *.bin *.sqlite3 chroma.log + +# Python temporary files and folders +__pycache__/ + +# Python venv folders +.venv/ From 8f0f6da2b4f7be802a1b3bf097d6100dcdbef08a Mon Sep 17 00:00:00 2001 From: Koala Yeung Date: Tue, 26 Nov 2024 19:09:32 +0800 Subject: [PATCH 3/4] Add editorconfig file for file formatting --- .editorconfig | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c0610d3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*.py] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 From 34e6b913c65a12e847b4982461f406ee21a66123 Mon Sep 17 00:00:00 2001 From: Koala Yeung Date: Tue, 26 Nov 2024 19:09:52 +0800 Subject: [PATCH 4/4] Fix but with importdocs.py * The script was unable to run due to previous changes (d47f2c2). The collection delete should run before creating collection or there will not be any collection to run import with. --- 2024-09-10-buildrag/python/importdocs.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/2024-09-10-buildrag/python/importdocs.py b/2024-09-10-buildrag/python/importdocs.py index 684a780..2b3f7ca 100644 --- a/2024-09-10-buildrag/python/importdocs.py +++ b/2024-09-10-buildrag/python/importdocs.py @@ -8,9 +8,11 @@ textdocspath = "../../scripts" text_data = readtextfiles(textdocspath) -collection = chromaclient.get_or_create_collection(name="buildragwithpython", metadata={"hnsw:space": "cosine"} ) +collectionname = "buildragwithpython" +# remove existing collection of the name to re-import every time if any(collection.name == collectionname for collection in chromaclient.list_collections()): - chromaclient.delete_collection("buildragwithpython") + chromaclient.delete_collection(collectionname) +collection = chromaclient.get_or_create_collection(name=collectionname, metadata={"hnsw:space": "cosine"} ) for filename, text in text_data.items(): chunks = chunksplitter(text)