@@ -236,11 +236,11 @@ def run_encoding(
236
236
f"embedding:{ embedding_id } :state:{ enums .EmbeddingState .FAILED .value } " ,
237
237
)
238
238
doc_ock .post_embedding_failed (user_id , f"{ model } -{ platform } " )
239
- message = f"Error while getting model - { e } "
239
+ notification_message = f"Error while getting model - { e } "
240
240
notification .create (
241
241
project_id ,
242
242
user_id ,
243
- message ,
243
+ notification_message ,
244
244
enums .Notification .ERROR .value ,
245
245
enums .NotificationType .EMBEDDING_CREATION_FAILED .value ,
246
246
True ,
@@ -328,7 +328,8 @@ def run_encoding(
328
328
)
329
329
doc_ock .post_embedding_failed (user_id , f"{ model } -{ platform } " )
330
330
return status .HTTP_500_INTERNAL_SERVER_ERROR
331
- except Exception :
331
+ except Exception as e :
332
+ error_message = str (e )
332
333
print (traceback .format_exc (), flush = True )
333
334
for warning_type , idx_list in embedder .get_warnings ().items ():
334
335
# use last record with warning as example
@@ -366,16 +367,28 @@ def run_encoding(
366
367
project_id ,
367
368
f"embedding:{ embedding_id } :state:{ enums .EmbeddingState .FAILED .value } " ,
368
369
)
370
+ notification_message = "Error at runtime. Please contact support."
371
+ if (
372
+ error_message
373
+ == "OpenAI API key is invalid. Please provide a valid API key in the constructor of OpenAISentenceEmbedder."
374
+ or error_message == "Resource not found"
375
+ ):
376
+ if platform == enums .EmbeddingPlatform .OPENAI .value :
377
+ notification_message = "Access denied due to invalid api key."
378
+ elif platform == enums .EmbeddingPlatform .AZURE .value :
379
+ notification_message = "Access denied due to invalid subscription key or wrong endpoint data."
380
+ elif error_message == "invalid api token" :
381
+ # cohere
382
+ notification_message = "Access denied due to invalid api token."
369
383
notification .create (
370
384
project_id ,
371
385
user_id ,
372
- "Error at runtime. Please contact support." ,
386
+ notification_message ,
373
387
enums .Notification .ERROR .value ,
374
388
enums .NotificationType .EMBEDDING_CREATION_FAILED .value ,
375
389
True ,
376
390
)
377
391
send_project_update (project_id , f"notification_created:{ user_id } " , True )
378
- print (traceback .format_exc (), flush = True )
379
392
doc_ock .post_embedding_failed (user_id , f"{ model } -{ platform } " )
380
393
return status .HTTP_500_INTERNAL_SERVER_ERROR
381
394
0 commit comments