Spaces:
Runtime error
Runtime error
Update ingest_locally.py to support multiple file types
Browse files28 unmodified lines293031323334353637383940414243444546474849505128 unmodified lineselse:print(f"Found existing client ID: {client.id}")# 3. Find PDF Filesif not os.path.exists(SOURCE_DIRECTORY):os.makedirs(SOURCE_DIRECTORY)print(f"⚠️ Created directory '{SOURCE_DIRECTORY}'. Please put your PDFs there and run again.")returnpdf_files = glob.glob(os.path.join(SOURCE_DIRECTORY, "*.pdf"))if not pdf_files:print(f"❌ No PDF files found in '{SOURCE_DIRECTORY}'")returnprint(f"Found {len(pdf_files)} PDF files to process.")# 4. Process Each Filefor i, filepath in enumerate(pdf_files, 1):filename = os.path.basename(filepath)print(f"\n[{i}/{len(pdf_files)}] Processing: {filename}...")try:# Check for duplicates first28 unmodified lines29303132333435363738394041424344454647484950515253545528 unmodified lineselse:print(f"Found existing client ID: {client.id}")# 3. Find Files (PDF, DOCX, TXT, CSV)if not os.path.exists(SOURCE_DIRECTORY):os.makedirs(SOURCE_DIRECTORY)print(f"⚠️ Created directory '{SOURCE_DIRECTORY}'. Please put your documents there and run again.")returnextensions = ["*.pdf", "*.docx", "*.txt", "*.csv"]files = []for ext in extensions:files.extend(glob.glob(os.path.join(SOURCE_DIRECTORY, ext)))if not files:print(f"❌ No documents found in '{SOURCE_DIRECTORY}'")returnprint(f"Found {len(files)} documents to process.")# 4. Process Each Filefor i, filepath in enumerate(files, 1):filename = os.path.basename(filepath)print(f"\n[{i}/{len(files)}] Processing: {filename}...")try:# Check for duplicates first
ingest_locally.py+12-8