Skip to content

Commit 1d5f75e

Browse files
Release prepararations (#65)
* Chnages invalid api key notificaiton message * Include cohere message * Improved error message for wrong api key for Azure * Submodules merged --------- Co-authored-by: Lina <[email protected]>
1 parent af7b6ab commit 1d5f75e

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

controller.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ def run_encoding(
236236
f"embedding:{embedding_id}:state:{enums.EmbeddingState.FAILED.value}",
237237
)
238238
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}"
240240
notification.create(
241241
project_id,
242242
user_id,
243-
message,
243+
notification_message,
244244
enums.Notification.ERROR.value,
245245
enums.NotificationType.EMBEDDING_CREATION_FAILED.value,
246246
True,
@@ -328,7 +328,8 @@ def run_encoding(
328328
)
329329
doc_ock.post_embedding_failed(user_id, f"{model}-{platform}")
330330
return status.HTTP_500_INTERNAL_SERVER_ERROR
331-
except Exception:
331+
except Exception as e:
332+
error_message = str(e)
332333
print(traceback.format_exc(), flush=True)
333334
for warning_type, idx_list in embedder.get_warnings().items():
334335
# use last record with warning as example
@@ -366,16 +367,28 @@ def run_encoding(
366367
project_id,
367368
f"embedding:{embedding_id}:state:{enums.EmbeddingState.FAILED.value}",
368369
)
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."
369383
notification.create(
370384
project_id,
371385
user_id,
372-
"Error at runtime. Please contact support.",
386+
notification_message,
373387
enums.Notification.ERROR.value,
374388
enums.NotificationType.EMBEDDING_CREATION_FAILED.value,
375389
True,
376390
)
377391
send_project_update(project_id, f"notification_created:{user_id}", True)
378-
print(traceback.format_exc(), flush=True)
379392
doc_ock.post_embedding_failed(user_id, f"{model}-{platform}")
380393
return status.HTTP_500_INTERNAL_SERVER_ERROR
381394

0 commit comments

Comments
 (0)