File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 66from __future__ import annotations
77import json
88import logging
9+ import os
910import re
1011import time
1112import urllib .parse
@@ -125,6 +126,14 @@ def delete_collection(self, name: str) -> None:
125126 # ── Document management ───────────────────────────────────────────────
126127
127128 def add_document (self , collection : str , file_path : str ) -> str :
129+ file_name = os .path .basename (file_path )
130+
131+ # Dedup: check if a document with the same name already exists
132+ existing_docs = self .list_documents (collection )
133+ for doc in existing_docs :
134+ if doc .get ("doc_name" ) == file_name :
135+ return doc ["doc_id" ]
136+
128137 folder_id = self ._get_folder_id (collection )
129138 data = {"if_retrieval" : "true" }
130139 if folder_id :
You can’t perform that action at this time.
0 commit comments