Browse Source

refac: comments

Timothy J. Baek 7 months ago
parent
commit
378223aedb
1 changed files with 9 additions and 0 deletions
  1. 9 0
      backend/open_webui/apps/retrieval/main.py

+ 9 - 0
backend/open_webui/apps/retrieval/main.py

@@ -738,6 +738,9 @@ def process_file(
             collection_name = f"file-{file.id}"
             collection_name = f"file-{file.id}"
 
 
         if form_data.content:
         if form_data.content:
+            # Update the content in the file
+            # Usage: /files/{file_id}/data/content/update
+
             VECTOR_DB_CLIENT.delete(
             VECTOR_DB_CLIENT.delete(
                 collection_name=f"file-{file.id}",
                 collection_name=f"file-{file.id}",
                 filter={"file_id": file.id},
                 filter={"file_id": file.id},
@@ -757,6 +760,9 @@ def process_file(
 
 
             text_content = form_data.content
             text_content = form_data.content
         elif form_data.collection_name:
         elif form_data.collection_name:
+            # Check if the file has already been processed and save the content
+            # Usage: /knowledge/{id}/file/add, /knowledge/{id}/file/update
+
             result = VECTOR_DB_CLIENT.query(
             result = VECTOR_DB_CLIENT.query(
                 collection_name=f"file-{file.id}", filter={"file_id": file.id}
                 collection_name=f"file-{file.id}", filter={"file_id": file.id}
             )
             )
@@ -784,6 +790,9 @@ def process_file(
 
 
             text_content = file.data.get("content", "")
             text_content = file.data.get("content", "")
         else:
         else:
+            # Process the file and save the content
+            # Usage: /files/
+
             file_path = file.meta.get("path", None)
             file_path = file.meta.get("path", None)
             if file_path:
             if file_path:
                 loader = Loader(
                 loader = Loader(