From 18ae8a409192894db96ba24099fc9615f31dd217 Mon Sep 17 00:00:00 2001 From: Kevin Hu Date: Tue, 5 Nov 2024 09:29:01 +0800 Subject: [PATCH] raise exception if embedding model not found (#3199) ### What problem does this PR solve? #3173 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/db/services/dialog_service.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/db/services/dialog_service.py b/api/db/services/dialog_service.py index 4245a284f..1e5fd8c79 100644 --- a/api/db/services/dialog_service.py +++ b/api/db/services/dialog_service.py @@ -162,6 +162,9 @@ def chat(dialog, messages, stream=True, **kwargs): attachments.extend(m["doc_ids"]) embd_mdl = LLMBundle(dialog.tenant_id, LLMType.EMBEDDING, embd_nms[0]) + if not embd_mdl: + raise LookupError("Embedding model(%s) not found" % embd_nms[0]) + if llm_id2llm_type(dialog.llm_id) == "image2text": chat_mdl = LLMBundle(dialog.tenant_id, LLMType.IMAGE2TEXT, dialog.llm_id) else: