From eb34987c2333f984f61ae5bc426864df22df1afd Mon Sep 17 00:00:00 2001 From: Sophie Chen <39424052+SophieGarden@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:00:00 -0700 Subject: [PATCH] Sophiech/add error log (#808) Co-authored-by: Sophie Chen --- scripts/data_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/data_utils.py b/scripts/data_utils.py index e9a3cabbc7..25a1def206 100644 --- a/scripts/data_utils.py +++ b/scripts/data_utils.py @@ -752,11 +752,12 @@ def chunk_content( for chunk, chunk_size, doc in chunked_context: if chunk_size >= min_chunk_size: if add_embeddings: - for _ in range(RETRY_COUNT): + for i in range(RETRY_COUNT): try: doc.contentVector = get_embedding(chunk, azure_credential=azure_credential, embedding_model_endpoint=embedding_endpoint) break - except: + except Exception as e: + print(f"Error getting embedding for chunk with error={e}, retrying, current at {i + 1} retry, {RETRY_COUNT - (i + 1)} retries left") time.sleep(30) if doc.contentVector is None: raise Exception(f"Error getting embedding for chunk={chunk}")