mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Merge pull request #585 from khoj-ai/fix/image-generation-and-csrf-cookie
Fix image generation setup bug and CSRF cookie for admin login
This commit is contained in:
commit
e9ea0195b0
3 changed files with 13 additions and 0 deletions
|
@ -33,6 +33,9 @@ ALLOWED_HOSTS = [f".{KHOJ_DOMAIN}", "localhost", "127.0.0.1", "[::1]"]
|
|||
CSRF_TRUSTED_ORIGINS = [
|
||||
f"https://*.{KHOJ_DOMAIN}",
|
||||
f"https://{KHOJ_DOMAIN}",
|
||||
f"http://*.{KHOJ_DOMAIN}",
|
||||
f"http://{KHOJ_DOMAIN}",
|
||||
f"https://app.{KHOJ_DOMAIN}",
|
||||
]
|
||||
|
||||
COOKIE_SAMESITE = "None"
|
||||
|
@ -42,6 +45,7 @@ if DEBUG or os.getenv("KHOJ_DOMAIN") == None:
|
|||
else:
|
||||
SESSION_COOKIE_DOMAIN = KHOJ_DOMAIN
|
||||
CSRF_COOKIE_DOMAIN = KHOJ_DOMAIN
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTOCOL", "https")
|
||||
|
||||
SESSION_COOKIE_SECURE = True
|
||||
CSRF_COOKIE_SECURE = True
|
||||
|
|
|
@ -12,6 +12,7 @@ from khoj.database.models import (
|
|||
SpeechToTextModelOptions,
|
||||
Subscription,
|
||||
ReflectiveQuestion,
|
||||
TextToImageModelConfig,
|
||||
)
|
||||
|
||||
admin.site.register(KhojUser, UserAdmin)
|
||||
|
@ -23,3 +24,4 @@ admin.site.register(OfflineChatProcessorConversationConfig)
|
|||
admin.site.register(SearchModelConfig)
|
||||
admin.site.register(Subscription)
|
||||
admin.site.register(ReflectiveQuestion)
|
||||
admin.site.register(TextToImageModelConfig)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue