Spaces:
Paused
Paused
Update app.py
Browse files48 unmodified lines495051525253545514 unmodified lines707172737374757624 unmodified lines10110210310410410510610710610710810911048 unmodified lines # Split the text into chunks of 1500 words words = text.split() chunks = [" ".join(words[i:i + 1500]) for i in range(0, len(words), 1500)] chunks = [" ".join(words[i:i + 1500]) for i in range(0, len(words), 1250)] logger.info(f"Segmented text into {len(chunks)} chunks.") return chunks
14 unmodified lines # Repository name on Hugging Face Hub repo_name = "TeacherPuffy/book2" # Process each chunk with a 20-second delay between API calls # Process each chunk with a 15-second delay between API calls results = [] for idx, chunk in enumerate(chunks): logger.info(f"Processing chunk {idx + 1}/{len(chunks)}")24 unmodified lines logger.error(f"Failed to upload chunk {idx + 1} to Hugging Face: {e}") raise gr.Error(f"Failed to upload chunk {idx + 1} to Hugging Face: {str(e)}") # Wait 20 seconds before the next API call # Wait 15 seconds before the next API call if idx < len(chunks) - 1: # No need to wait after the last chunk logger.info("Waiting 20 seconds before the next API call...") time.sleep(20) logger.info("Waiting 15 seconds before the next API call...") time.sleep(15) except Exception as e: logger.error(f"Failed to process chunk {idx + 1}: {e}")app.py+5-5