Merge branch 'master' of github.com:khoj-ai/khoj into features/allow-multi-outputs-in-chat

This commit is contained in:
sabaimran 2024-12-08 10:57:16 -08:00
commit a138845fea
7 changed files with 169 additions and 29 deletions

View file

@ -22,7 +22,7 @@ services:
depends_on:
database:
condition: service_healthy
# Use the following line to use the latest version of khoj. Otherwise, it will build from source.
# Use the following line to use the latest version of khoj. Otherwise, it will build from source. Set this to ghcr.io/khoj-ai/khoj-cloud if you want to use the prod image.
image: ghcr.io/khoj-ai/khoj:latest
# Uncomment the following line to build from source. This will take a few minutes. Comment the next two lines out if you want to use the offiicial image.
# build:
@ -83,6 +83,7 @@ services:
# Telemetry helps us prioritize feature development and understand how people are using Khoj
# Read more at https://docs.khoj.dev/miscellaneous/telemetry
# - KHOJ_TELEMETRY_DISABLE=True
# Uncomment this line when you're using the official ghcr.io/khoj-ai/khoj-cloud prod image.
command: --host="0.0.0.0" --port=42110 -vv --anonymous-mode --non-interactive

View file

@ -114,7 +114,7 @@ This feature finds entries similar to the one you are currently on.
2. Hit `C-c s f` (or `M-x khoj RET f`) to find similar entries
### Advanced Usage
- Add [query filters](https://github.com/khoj-ai/khoj/#query-filters) during search to narrow down results further
- Add [query filters](/miscellaneous/advanced#query-filters) during search to narrow down results further
e.g. `What is the meaning of life? -"god" +"none" dt>"last week"`
- Use `C-c C-o 2` to open the current result at cursor in its source org file

View file

@ -64,6 +64,7 @@ dependencies = [
"anyio == 3.7.1",
"pymupdf == 1.24.11",
"django == 5.0.9",
"django-unfold == 0.42.0",
"authlib == 1.2.1",
"llama-cpp-python == 0.2.88",
"itsdangerous == 2.1.2",

View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="200"
height="200"
viewBox="0 0 200 200"
className="fill-zinc-950 dark:fill-zinc-300"
version="1.1"
id="svg14"
sodipodi:docname="khoj.svg"
inkscape:export-filename="khoj_lantern_512x512.png"
inkscape:export-xdpi="245.75999"
inkscape:export-ydpi="245.75999"
inkscape:version="1.3 (0e150ed, 2023-07-21)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="1.18"
inkscape:cx="99.576271"
inkscape:cy="77.542373"
inkscape:window-width="1680"
inkscape:window-height="1022"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg14"
inkscape:export-bgcolor="#ffffffe0" />
<g
clipPath="url(#clip0_45_75)"
id="g14"
transform="matrix(1.0349659,0,0,1.0429132,13.551981,6.7616199)">
<!-- Fire -->
<path
d="m 57.9394,93.0404 9.6002,-43.9341 c 1.2591,0.4205 4.1969,2.8379 7.1871,2.8379 3.7772,0 4.5116,-4.5196 11.4364,-6.1487 5.5084,-1.3138 10.1773,-0.3679 12.9053,1.8394 0,0 0.6295,5.991 2.0986,7.7778 1.364,1.6291 3.462,1.051 3.462,1.051 3.043,14.3469 9.443,44.1973 10.65,48.7693 1.521,5.728 -4.355,8.881 -6.61,14.136 -2.256,5.256 -14.427,7.515 -21.6141,8.251 -7.187,0.736 -27.3319,-7.988 -29.1155,-10.405 -1.7837,-2.418 -2.5706,-7.358 -2.8329,-12.035 -0.2623,-3.731 1.7837,-9.6696 2.8329,-12.1396 z"
fill="#fae80b"
id="path1" />
<path
d="m 57.9394,92.9879 4.3542,-18.1833 c 1.259,0.4205 4.669,-1.3663 9.1806,-5.7282 2.6755,-2.6276 8.3936,-10.1952 14.584,-13.7163 4.5116,-2.5751 8.8658,-1.1561 11.5413,1.0511 0,0 2.4135,1.2087 5.2465,1.2087 2.098,0 1.783,-1.2087 1.783,-1.2087 3.043,14.3469 9.443,44.1968 10.65,48.7688 1.521,5.728 -4.355,8.882 -6.61,14.137 -2.256,5.255 -14.427,7.515 -21.6141,8.251 -7.187,0.735 -27.3319,-7.988 -29.1155,-10.406 -1.7837,-2.417 -2.5706,-7.357 -2.8329,-12.034 -0.2623,-3.679 1.7837,-9.6176 2.8329,-12.1401 z"
fill="#ffcc09"
id="path2" />
<path
d="m 69.3233,123.731 c -10.3347,-2.627 -13.4299,-14.662 -13.6922,-20.338 3.1476,3.206 11.4889,9.407 19.5153,8.566 10.0724,-1.051 17.5743,-5.097 25.7056,-11.456 8.131,-6.3064 13.692,-3.3109 13.692,6.306 0,9.617 -6.925,11.299 -9.023,15.661 -2.098,4.414 -23.24,4.572 -36.1977,1.261 z"
fill="#fba719"
id="path3" />
<!-- Lamp -->
<path
d="m 46.6374,143.679 c -3.0428,0 -5.351,-0.841 -6.9773,-2.575 -2.9378,-3.1 -2.1509,-7.725 -2.0984,-7.935 0.1573,-0.894 14.7414,-89.2874 16.1053,-97.9586 1.2591,-8.0406 10.3872,-9.8274 15.0562,-9.6172 l -0.1049,3.1532 c -0.0525,0 -2.8853,-0.1051 -5.7707,0.7883 -3.5673,1.1036 -5.6132,3.1531 -6.0854,6.1487 -1.3115,8.6712 -15.948,97.1176 -16.1054,98.0106 0,0.053 -0.5246,3.311 1.3116,5.256 1.3115,1.366 3.5148,1.839 6.6624,1.418 l 0.3673,3.101 c -0.7869,0.158 -1.5738,0.21 -2.3607,0.21 z"
id="path4" />
<path
d="m 106.023,33.371 h -3.095 c 0.052,-0.1577 0.052,-0.3679 0.052,-0.5255 V 15.2403 c 0,-1.7343 -1.416,-3.1532 -3.1476,-3.1532 H 89.4977 c 1.3639,-1.2087 2.2558,-2.99549 2.2558,-4.99249 0,-3.67869 -2.9903,-6.6742 -6.6625,-6.6742 -3.6722,0 -6.6625,2.99551 -6.6625,6.6742 0,1.997 0.8394,3.78379 2.2558,4.99249 h -9.8626 c -1.7312,0 -3.1476,1.4189 -3.1476,3.1532 v 17.6052 c 0,0.2102 0,0.3678 0.0524,0.5255 h -3.6722 c -2.4656,0 -4.5116,2.0495 -4.5116,4.5195 0,2.5226 2.046,4.5196 4.5116,4.5196 h 42.0207 c 2.466,0 4.512,-2.0496 4.512,-4.5196 -0.053,-2.5225 -2.046,-4.5195 -4.564,-4.5195 z M 85.0385,3.52103 c 1.941,0 3.5149,1.57657 3.5149,3.52102 0,1.94446 -1.5739,3.52105 -3.5149,3.52105 -1.941,0 -3.5148,-1.57659 -3.5148,-3.52105 0,-1.94445 1.5738,-3.52102 3.5148,-3.52102 z"
id="path5" />
<path
d="m 123.177,143.679 c -0.734,0 -1.521,-0.052 -2.361,-0.157 l 0.368,-3.101 c 3.147,0.42 5.351,-0.105 6.662,-1.419 1.836,-1.944 1.312,-5.203 1.312,-5.203 -0.158,-0.893 -14.794,-89.3394 -16.106,-98.0106 -0.472,-2.9955 -2.518,-5.0451 -6.085,-6.1487 -2.885,-0.8934 -5.718,-0.7883 -5.771,-0.7883 l -0.105,-3.1531 c 4.669,-0.2102 13.85,1.5766 15.056,9.6171 1.312,8.6712 15.948,97.0646 16.106,97.9586 0.052,0.157 0.839,4.782 -2.099,7.883 -1.626,1.629 -3.934,2.522 -6.977,2.522 z"
id="path6" />
<path
d="m 122.443,151.142 -0.053,-21.337 c 0,-5.045 -12.748,-9.774 -12.748,-9.774 h -0.209 c -4.407,4.309 -11.8565,7.409 -24.1847,7.409 -12.3282,0 -19.7252,-3.1 -24.1843,-7.409 h -0.2099 c 0,0 -12.7478,4.729 -12.7478,9.774 0,5.045 0,21.337 0,21.337 0,0 -5.9281,3.836 -5.9281,8.303 0,4.467 0,7.725 0,7.725 0,0 5.0362,10.984 43.0701,10.984 h 0.0524 c 38.0343,0 43.0703,-10.984 43.0703,-10.984 0,0 0,-3.258 0,-7.725 0,-4.467 -5.928,-8.303 -5.928,-8.303 z"
id="path7" />
<path
d="m 117.931,87.658 c -1.206,-2.4174 -4.511,-7.1472 -5.875,-9.0916 l -8.132,-37.4176 -2.833,0.6307 11.647,53.4461 0.052,0.1577 c 0,0.0525 0.472,1.4714 0.84,3.6787 -0.578,0.5255 -1.26,0.998 -2.046,1.471 -3.253,1.945 -14.7943,5.361 -26.2831,8.461 -11.4364,-3.1 -22.9253,-6.516 -26.1778,-8.461 -0.8394,-0.525 -1.5738,-1.0506 -2.2034,-1.6287 0.3673,-2.1547 0.7869,-3.521 0.8394,-3.5736 V 95.2782 L 69.4053,41.5167 66.5725,40.886 58.3362,79.0394 c -1.5214,2.1546 -4.4592,6.4114 -5.5608,8.6712 -0.9443,1.8919 -1.9935,6.8318 1.259,11.1412 -0.7869,4.8872 -1.0492,12.9282 3.7247,19.5492 5.0362,6.99 14.2693,10.511 27.4893,10.511 13.2201,0 22.4536,-3.521 27.4896,-10.511 4.721,-6.569 4.511,-14.452 3.777,-19.339 3.515,-4.4145 2.413,-9.4595 1.416,-11.404 z m -1.836,0.946 c 0.63,1.3138 1.364,4.3618 -0.105,7.4099 -0.21,-0.7883 -0.367,-1.2613 -0.419,-1.4715 l -2.309,-10.5631 c 1.102,1.6817 2.256,3.4685 2.833,4.6247 z m -61.431,0 c 0.5246,-1.0511 1.4688,-2.5751 2.518,-4.1517 l -2.2033,10.0376 c -0.0525,0.1576 -0.2098,0.5781 -0.3672,1.2087 -1.2066,-2.943 -0.5246,-5.8334 0.0525,-7.0946 z m 1.9934,12.77 c 0.4197,0.316 0.9443,0.631 1.4165,0.946 3.0427,1.84 12.9053,4.835 23.24,7.725 -10.7544,2.891 -20.4596,5.256 -21.8761,5.624 -2.8853,-4.73 -3.1476,-10.196 -2.7804,-14.295 z m 28.6435,24.595 c -11.6463,0 -19.8825,-2.838 -24.4991,-8.461 3.305,-0.788 13.7447,-3.416 24.5515,-6.359 10.5971,2.89 20.9847,5.466 24.4467,6.359 -4.617,5.623 -12.8529,8.461 -24.4991,8.461 z m 25.8101,-10.3 c -1.941,-0.473 -11.3835,-2.838 -21.7707,-5.624 10.3872,-2.89 20.2497,-5.938 23.3447,-7.777 0.472,-0.263 0.84,-0.526 1.259,-0.841 0.367,4.099 0.053,9.564 -2.833,14.242 z"
id="path8" />
<path
d="m 39.188,44.7224 c -0.3147,0 -0.577,-0.1051 -0.8393,-0.2627 l -14.0594,-9.88 c -0.682,-0.4729 -0.8394,-1.3663 -0.3673,-2.0495 0.4722,-0.6832 1.364,-0.8409 2.046,-0.3679 l 14.0594,9.8799 c 0.682,0.473 0.8394,1.3664 0.3672,2.0496 -0.3147,0.4204 -0.7344,0.6306 -1.2066,0.6306 z"
id="path9" />
<path
d="M 18.8334,80.6685 1.67885,80.6159 c -0.786909,0 -1.468889,-0.6306 -1.468889,-1.4714 0,-0.8409 0.629519,-1.4715 1.468889,-1.4715 l 17.15455,0.0525 c 0.7869,0 1.4689,0.6307 1.4689,1.4715 0,0.8409 -0.682,1.4715 -1.4689,1.4715 z"
id="path10" />
<path
d="m 13.2726,128.754 c -0.4722,0 -0.9443,-0.21 -1.2066,-0.683 -0.4197,-0.683 -0.2098,-1.576 0.4197,-1.997 l 14.4266,-9.249 c 0.682,-0.421 1.5738,-0.263 1.9935,0.42 0.4197,0.683 0.2099,1.577 -0.4197,1.997 l -14.4266,9.25 c -0.2098,0.157 -0.4721,0.262 -0.7869,0.262 z"
id="path11" />
<path
d="m 130.889,43.6188 c -0.472,0 -0.892,-0.2102 -1.207,-0.6307 -0.472,-0.6831 -0.314,-1.5765 0.368,-2.0495 l 14.059,-9.8799 c 0.629,-0.473 1.574,-0.3154 2.046,0.3678 0.472,0.6832 0.315,1.5766 -0.367,2.0496 l -14.06,9.8799 c -0.262,0.1577 -0.524,0.2628 -0.839,0.2628 z"
id="path12" />
<path
d="m 151.244,79.5649 c -0.787,0 -1.469,-0.6306 -1.469,-1.4715 0,-0.7883 0.629,-1.4715 1.469,-1.4715 l 17.154,-0.0525 c 0.787,0 1.469,0.6306 1.469,1.4715 0,0.7883 -0.629,1.4714 -1.469,1.4714 z"
id="path13" />
<path
d="m 156.804,127.598 c -0.262,0 -0.524,-0.052 -0.787,-0.21 l -14.426,-9.249 c -0.682,-0.421 -0.892,-1.314 -0.42,-1.997 0.42,-0.684 1.312,-0.894 1.994,-0.421 l 14.426,9.249 c 0.682,0.421 0.892,1.314 0.42,1.997 -0.262,0.421 -0.734,0.631 -1.207,0.631 z"
id="path14" />
</g>
<defs
id="defs14">
<clipPath
id="clip0_45_75">
<rect
width="200"
height="200"
fill="currentColor"
id="rect14" />
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -13,6 +13,8 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
import os
from pathlib import Path
from django.templatetags.static import static
from khoj.utils.helpers import in_debug_mode, is_env_var_true
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -72,6 +74,7 @@ INSTALLED_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
"khoj.database.apps.DatabaseConfig",
"unfold",
"django.contrib.admin",
"django.contrib.sessions",
"django.contrib.messages",
@ -195,3 +198,21 @@ APSCHEDULER_DATETIME_FORMAT = "N j, Y, f:s a"
# that supports multiple background worker processes instead (e.g. Dramatiq, Celery, Django-RQ,
# etc. See: https://djangopackages.org/grids/g/workers-queues-tasks/ for popular options).
APSCHEDULER_RUN_NOW_TIMEOUT = 240 # Seconds
UNFOLD = {
"SITE_TITLE": "Khoj Admin Panel",
"SITE_HEADER": "Khoj Admin Panel",
"SITE_URL": "/",
"SITE_ICON": {
"light": lambda request: static("assets/icons/khoj_lantern_128x128.png"),
"dark": lambda request: static("assets/icons/khoj_lantern_128x128_dark.png"),
},
"SITE_FAVICONS": [
{
"rel": "icon",
"sizes": "32x32",
"type": "image/svg+xml",
"href": lambda request: static("assets/icons/khoj_lantern.svg"),
},
],
}

View file

@ -4,11 +4,14 @@ from datetime import date, datetime, timedelta, timezone
from apscheduler.job import Job
from django.contrib import admin, messages
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.admin import GroupAdmin as BaseGroupAdmin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import Group
from django.http import HttpResponse
from django_apscheduler.admin import DjangoJobAdmin
from django_apscheduler.admin import DjangoJobAdmin, DjangoJobExecutionAdmin
from django_apscheduler.jobstores import DjangoJobStore
from django_apscheduler.models import DjangoJob
from django_apscheduler.models import DjangoJob, DjangoJobExecution
from unfold import admin as unfold_admin
from khoj.database.models import (
Agent,
@ -35,10 +38,8 @@ from khoj.database.models import (
)
from khoj.utils.helpers import ImageIntentType
admin.site.unregister(DjangoJob)
class KhojDjangoJobAdmin(DjangoJobAdmin):
class KhojDjangoJobAdmin(DjangoJobAdmin, unfold_admin.ModelAdmin):
list_display = (
"id",
"next_run_time",
@ -62,10 +63,25 @@ class KhojDjangoJobAdmin(DjangoJobAdmin):
return queryset, use_distinct
class KhojDjangoJobExecutionAdmin(DjangoJobExecutionAdmin, unfold_admin.ModelAdmin):
pass
admin.site.unregister(DjangoJob)
admin.site.register(DjangoJob, KhojDjangoJobAdmin)
admin.site.unregister(DjangoJobExecution)
admin.site.register(DjangoJobExecution, KhojDjangoJobExecutionAdmin)
class KhojUserAdmin(UserAdmin):
class GroupAdmin(BaseGroupAdmin, unfold_admin.ModelAdmin):
pass
class UserAdmin(BaseUserAdmin, unfold_admin.ModelAdmin):
pass
class KhojUserAdmin(UserAdmin, unfold_admin.ModelAdmin):
class DateJoinedAfterFilter(admin.SimpleListFilter):
title = "Joined after"
parameter_name = "joined_after"
@ -137,21 +153,22 @@ class KhojUserAdmin(UserAdmin):
get_email_login_url.short_description = "Get email login URL" # type: ignore
admin.site.unregister(Group)
admin.site.register(KhojUser, KhojUserAdmin)
admin.site.register(ProcessLock)
admin.site.register(SpeechToTextModelOptions)
admin.site.register(ReflectiveQuestion)
admin.site.register(ClientApplication)
admin.site.register(GithubConfig)
admin.site.register(NotionConfig)
admin.site.register(UserVoiceModelConfig)
admin.site.register(VoiceModelOption)
admin.site.register(UserRequests)
admin.site.register(ProcessLock, unfold_admin.ModelAdmin)
admin.site.register(SpeechToTextModelOptions, unfold_admin.ModelAdmin)
admin.site.register(ReflectiveQuestion, unfold_admin.ModelAdmin)
admin.site.register(ClientApplication, unfold_admin.ModelAdmin)
admin.site.register(GithubConfig, unfold_admin.ModelAdmin)
admin.site.register(NotionConfig, unfold_admin.ModelAdmin)
admin.site.register(UserVoiceModelConfig, unfold_admin.ModelAdmin)
admin.site.register(VoiceModelOption, unfold_admin.ModelAdmin)
admin.site.register(UserRequests, unfold_admin.ModelAdmin)
@admin.register(Agent)
class AgentAdmin(admin.ModelAdmin):
class AgentAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"name",
@ -161,7 +178,7 @@ class AgentAdmin(admin.ModelAdmin):
@admin.register(Entry)
class EntryAdmin(admin.ModelAdmin):
class EntryAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"created_at",
@ -183,7 +200,7 @@ class EntryAdmin(admin.ModelAdmin):
@admin.register(Subscription)
class KhojUserSubscription(admin.ModelAdmin):
class KhojUserSubscription(unfold_admin.ModelAdmin):
list_display = (
"id",
"user",
@ -195,7 +212,7 @@ class KhojUserSubscription(admin.ModelAdmin):
@admin.register(ChatModelOptions)
class ChatModelOptionsAdmin(admin.ModelAdmin):
class ChatModelOptionsAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"chat_model",
@ -206,7 +223,7 @@ class ChatModelOptionsAdmin(admin.ModelAdmin):
@admin.register(TextToImageModelConfig)
class TextToImageModelOptionsAdmin(admin.ModelAdmin):
class TextToImageModelOptionsAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"model_name",
@ -216,7 +233,7 @@ class TextToImageModelOptionsAdmin(admin.ModelAdmin):
@admin.register(OpenAIProcessorConversationConfig)
class OpenAIProcessorConversationConfigAdmin(admin.ModelAdmin):
class OpenAIProcessorConversationConfigAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"name",
@ -227,7 +244,7 @@ class OpenAIProcessorConversationConfigAdmin(admin.ModelAdmin):
@admin.register(SearchModelConfig)
class SearchModelConfigAdmin(admin.ModelAdmin):
class SearchModelConfigAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"name",
@ -238,7 +255,7 @@ class SearchModelConfigAdmin(admin.ModelAdmin):
@admin.register(ServerChatSettings)
class ServerChatSettingsAdmin(admin.ModelAdmin):
class ServerChatSettingsAdmin(unfold_admin.ModelAdmin):
list_display = (
"chat_default",
"chat_advanced",
@ -247,7 +264,7 @@ class ServerChatSettingsAdmin(admin.ModelAdmin):
@admin.register(WebScraper)
class WebScraperAdmin(admin.ModelAdmin):
class WebScraperAdmin(unfold_admin.ModelAdmin):
list_display = (
"priority",
"name",
@ -261,7 +278,7 @@ class WebScraperAdmin(admin.ModelAdmin):
@admin.register(Conversation)
class ConversationAdmin(admin.ModelAdmin):
class ConversationAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"user",
@ -360,7 +377,7 @@ class ConversationAdmin(admin.ModelAdmin):
@admin.register(UserConversationConfig)
class UserConversationConfigAdmin(admin.ModelAdmin):
class UserConversationConfigAdmin(unfold_admin.ModelAdmin):
list_display = (
"id",
"get_user_email",