From 61dde8ed89112f115b07062cfc291f801d119324 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Sun, 17 Dec 2023 12:54:50 +0530 Subject: [PATCH] If text to image config isn't set, send back an error message to the client --- src/khoj/routers/api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index a4063afa..235b6e7c 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -715,6 +715,13 @@ async def chat( ) elif conversation_command == ConversationCommand.Image: image, status_code = await text_to_image(q) + if image is None: + content_obj = { + "image": image, + "intentType": "text-to-image", + "detail": "Failed to generate image. Make sure your image generation configuration is set.", + } + return Response(content=json.dumps(content_obj), media_type="application/json", status_code=status_code) await sync_to_async(save_to_conversation_log)(q, image, user, meta_log, intent_type="text-to-image") content_obj = {"image": image, "intentType": "text-to-image"} return Response(content=json.dumps(content_obj), media_type="application/json", status_code=status_code)