mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
If text to image config isn't set, send back an error message to the client
This commit is contained in:
@@ -715,6 +715,13 @@ async def chat(
|
|||||||
)
|
)
|
||||||
elif conversation_command == ConversationCommand.Image:
|
elif conversation_command == ConversationCommand.Image:
|
||||||
image, status_code = await text_to_image(q)
|
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")
|
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"}
|
content_obj = {"image": image, "intentType": "text-to-image"}
|
||||||
return Response(content=json.dumps(content_obj), media_type="application/json", status_code=status_code)
|
return Response(content=json.dumps(content_obj), media_type="application/json", status_code=status_code)
|
||||||
|
|||||||
Reference in New Issue
Block a user