khoj 1.20.4.dev13__py3-none-any.whl → 1.20.5.dev17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- khoj/configure.py +6 -32
- khoj/database/adapters/__init__.py +76 -28
- khoj/database/admin.py +15 -3
- khoj/database/migrations/0056_searchmodelconfig_cross_encoder_model_config.py +17 -0
- khoj/database/migrations/0057_remove_serverchatsettings_default_model_and_more.py +51 -0
- khoj/database/models/__init__.py +7 -4
- khoj/interface/compiled/404/index.html +1 -1
- khoj/interface/compiled/_next/static/chunks/{9178-5a1fa2b9023249af.js → 9178-b9ab3fa2e9be8287.js} +1 -1
- khoj/interface/compiled/_next/static/chunks/app/chat/page-8c9b92236d4daf4b.js +1 -0
- khoj/interface/compiled/_next/static/chunks/app/settings/page-ddcd51147d18c694.js +1 -0
- khoj/interface/compiled/_next/static/chunks/{webpack-c6008e79c8ef349d.js → webpack-9953d80989df2d20.js} +1 -1
- khoj/interface/compiled/agents/index.html +1 -1
- khoj/interface/compiled/agents/index.txt +2 -2
- khoj/interface/compiled/automations/index.html +1 -1
- khoj/interface/compiled/automations/index.txt +1 -1
- khoj/interface/compiled/chat/index.html +1 -1
- khoj/interface/compiled/chat/index.txt +2 -2
- khoj/interface/compiled/factchecker/index.html +1 -1
- khoj/interface/compiled/factchecker/index.txt +2 -2
- khoj/interface/compiled/index.html +1 -1
- khoj/interface/compiled/index.txt +2 -2
- khoj/interface/compiled/search/index.html +1 -1
- khoj/interface/compiled/search/index.txt +2 -2
- khoj/interface/compiled/settings/index.html +1 -1
- khoj/interface/compiled/settings/index.txt +2 -2
- khoj/interface/compiled/share/chat/index.html +1 -1
- khoj/interface/compiled/share/chat/index.txt +2 -2
- khoj/processor/conversation/anthropic/anthropic_chat.py +6 -2
- khoj/processor/conversation/offline/chat_model.py +15 -3
- khoj/processor/conversation/openai/gpt.py +6 -3
- khoj/processor/conversation/openai/utils.py +1 -1
- khoj/processor/conversation/prompts.py +20 -0
- khoj/processor/embeddings.py +3 -1
- khoj/processor/tools/online_search.py +19 -8
- khoj/routers/api.py +3 -1
- khoj/routers/api_chat.py +21 -9
- khoj/routers/helpers.py +38 -14
- khoj/search_filter/file_filter.py +5 -2
- {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev17.dist-info}/METADATA +1 -1
- {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev17.dist-info}/RECORD +49 -47
- khoj/interface/compiled/_next/static/chunks/app/chat/page-51ab7c4b766ff344.js +0 -1
- khoj/interface/compiled/_next/static/chunks/app/settings/page-e83f6fa32691ca64.js +0 -1
- /khoj/interface/compiled/_next/static/{EuaXDNeXisAc9H0EHd10x → QSaUkpIwMzbLQnDFgPg3j}/_buildManifest.js +0 -0
- /khoj/interface/compiled/_next/static/{EuaXDNeXisAc9H0EHd10x → QSaUkpIwMzbLQnDFgPg3j}/_ssgManifest.js +0 -0
- /khoj/interface/compiled/_next/static/chunks/{8423-132ea64eac83fd43.js → 8423-898d821eaab634af.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/{9417-2e54c6fd056982d8.js → 9417-5d14ac74aaab2c66.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/app/agents/{page-922694b75f1fb67b.js → page-989a824c640bc532.js} +0 -0
- /khoj/interface/compiled/_next/static/chunks/app/{page-ef4e7248d37fae41.js → page-851860583273ab5d.js} +0 -0
- {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev17.dist-info}/WHEEL +0 -0
- {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev17.dist-info}/entry_points.txt +0 -0
- {khoj-1.20.4.dev13.dist-info → khoj-1.20.5.dev17.dist-info}/licenses/LICENSE +0 -0
khoj/configure.py
CHANGED
|
@@ -32,10 +32,9 @@ from khoj.database.adapters import (
|
|
|
32
32
|
ClientApplicationAdapters,
|
|
33
33
|
ConversationAdapters,
|
|
34
34
|
ProcessLockAdapters,
|
|
35
|
-
SubscriptionState,
|
|
36
35
|
aget_or_create_user_by_phone_number,
|
|
37
36
|
aget_user_by_phone_number,
|
|
38
|
-
|
|
37
|
+
ais_user_subscribed,
|
|
39
38
|
delete_user_requests,
|
|
40
39
|
get_all_users,
|
|
41
40
|
get_or_create_search_models,
|
|
@@ -119,15 +118,7 @@ class UserAuthenticationBackend(AuthenticationBackend):
|
|
|
119
118
|
.afirst()
|
|
120
119
|
)
|
|
121
120
|
if user:
|
|
122
|
-
|
|
123
|
-
return AuthCredentials(["authenticated", "premium"]), AuthenticatedKhojUser(user)
|
|
124
|
-
|
|
125
|
-
subscription_state = await aget_user_subscription_state(user)
|
|
126
|
-
subscribed = (
|
|
127
|
-
subscription_state == SubscriptionState.SUBSCRIBED.value
|
|
128
|
-
or subscription_state == SubscriptionState.TRIAL.value
|
|
129
|
-
or subscription_state == SubscriptionState.UNSUBSCRIBED.value
|
|
130
|
-
)
|
|
121
|
+
subscribed = await ais_user_subscribed(user)
|
|
131
122
|
if subscribed:
|
|
132
123
|
return AuthCredentials(["authenticated", "premium"]), AuthenticatedKhojUser(user)
|
|
133
124
|
return AuthCredentials(["authenticated"]), AuthenticatedKhojUser(user)
|
|
@@ -144,15 +135,7 @@ class UserAuthenticationBackend(AuthenticationBackend):
|
|
|
144
135
|
.afirst()
|
|
145
136
|
)
|
|
146
137
|
if user_with_token:
|
|
147
|
-
|
|
148
|
-
return AuthCredentials(["authenticated", "premium"]), AuthenticatedKhojUser(user_with_token.user)
|
|
149
|
-
|
|
150
|
-
subscription_state = await aget_user_subscription_state(user_with_token.user)
|
|
151
|
-
subscribed = (
|
|
152
|
-
subscription_state == SubscriptionState.SUBSCRIBED.value
|
|
153
|
-
or subscription_state == SubscriptionState.TRIAL.value
|
|
154
|
-
or subscription_state == SubscriptionState.UNSUBSCRIBED.value
|
|
155
|
-
)
|
|
138
|
+
subscribed = await ais_user_subscribed(user_with_token.user)
|
|
156
139
|
if subscribed:
|
|
157
140
|
return AuthCredentials(["authenticated", "premium"]), AuthenticatedKhojUser(user_with_token.user)
|
|
158
141
|
return AuthCredentials(["authenticated"]), AuthenticatedKhojUser(user_with_token.user)
|
|
@@ -189,20 +172,10 @@ class UserAuthenticationBackend(AuthenticationBackend):
|
|
|
189
172
|
if user is None:
|
|
190
173
|
return AuthCredentials(), UnauthenticatedUser()
|
|
191
174
|
|
|
192
|
-
|
|
193
|
-
return AuthCredentials(["authenticated", "premium"]), AuthenticatedKhojUser(user, client_application)
|
|
175
|
+
subscribed = await ais_user_subscribed(user)
|
|
194
176
|
|
|
195
|
-
subscription_state = await aget_user_subscription_state(user)
|
|
196
|
-
subscribed = (
|
|
197
|
-
subscription_state == SubscriptionState.SUBSCRIBED.value
|
|
198
|
-
or subscription_state == SubscriptionState.TRIAL.value
|
|
199
|
-
or subscription_state == SubscriptionState.UNSUBSCRIBED.value
|
|
200
|
-
)
|
|
201
177
|
if subscribed:
|
|
202
|
-
return (
|
|
203
|
-
AuthCredentials(["authenticated", "premium"]),
|
|
204
|
-
AuthenticatedKhojUser(user, client_application),
|
|
205
|
-
)
|
|
178
|
+
return AuthCredentials(["authenticated", "premium"]), AuthenticatedKhojUser(user, client_application)
|
|
206
179
|
return AuthCredentials(["authenticated"]), AuthenticatedKhojUser(user, client_application)
|
|
207
180
|
|
|
208
181
|
# No auth required if server in anonymous mode
|
|
@@ -263,6 +236,7 @@ def configure_server(
|
|
|
263
236
|
model.cross_encoder,
|
|
264
237
|
model.cross_encoder_inference_endpoint,
|
|
265
238
|
model.cross_encoder_inference_endpoint_api_key,
|
|
239
|
+
model_kwargs=model.cross_encoder_model_config,
|
|
266
240
|
)
|
|
267
241
|
}
|
|
268
242
|
)
|
|
@@ -300,6 +300,38 @@ async def aget_user_subscription_state(user: KhojUser) -> str:
|
|
|
300
300
|
return subscription_to_state(user_subscription)
|
|
301
301
|
|
|
302
302
|
|
|
303
|
+
async def ais_user_subscribed(user: KhojUser) -> bool:
|
|
304
|
+
"""
|
|
305
|
+
Get whether the user is subscribed
|
|
306
|
+
"""
|
|
307
|
+
if not state.billing_enabled or state.anonymous_mode:
|
|
308
|
+
return True
|
|
309
|
+
|
|
310
|
+
subscription_state = await aget_user_subscription_state(user)
|
|
311
|
+
subscribed = (
|
|
312
|
+
subscription_state == SubscriptionState.SUBSCRIBED.value
|
|
313
|
+
or subscription_state == SubscriptionState.TRIAL.value
|
|
314
|
+
or subscription_state == SubscriptionState.UNSUBSCRIBED.value
|
|
315
|
+
)
|
|
316
|
+
return subscribed
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def is_user_subscribed(user: KhojUser) -> bool:
|
|
320
|
+
"""
|
|
321
|
+
Get whether the user is subscribed
|
|
322
|
+
"""
|
|
323
|
+
if not state.billing_enabled or state.anonymous_mode:
|
|
324
|
+
return True
|
|
325
|
+
|
|
326
|
+
subscription_state = get_user_subscription_state(user.email)
|
|
327
|
+
subscribed = (
|
|
328
|
+
subscription_state == SubscriptionState.SUBSCRIBED.value
|
|
329
|
+
or subscription_state == SubscriptionState.TRIAL.value
|
|
330
|
+
or subscription_state == SubscriptionState.UNSUBSCRIBED.value
|
|
331
|
+
)
|
|
332
|
+
return subscribed
|
|
333
|
+
|
|
334
|
+
|
|
303
335
|
async def get_user_by_email(email: str) -> KhojUser:
|
|
304
336
|
return await KhojUser.objects.filter(email=email).afirst()
|
|
305
337
|
|
|
@@ -751,17 +783,23 @@ class ConversationAdapters:
|
|
|
751
783
|
|
|
752
784
|
@staticmethod
|
|
753
785
|
def get_conversation_config(user: KhojUser):
|
|
786
|
+
subscribed = is_user_subscribed(user)
|
|
787
|
+
if not subscribed:
|
|
788
|
+
return ConversationAdapters.get_default_conversation_config()
|
|
754
789
|
config = UserConversationConfig.objects.filter(user=user).first()
|
|
755
|
-
if
|
|
756
|
-
return
|
|
757
|
-
return
|
|
790
|
+
if config:
|
|
791
|
+
return config.setting
|
|
792
|
+
return ConversationAdapters.get_advanced_conversation_config()
|
|
758
793
|
|
|
759
794
|
@staticmethod
|
|
760
795
|
async def aget_conversation_config(user: KhojUser):
|
|
796
|
+
subscribed = await ais_user_subscribed(user)
|
|
797
|
+
if not subscribed:
|
|
798
|
+
return await ConversationAdapters.aget_default_conversation_config()
|
|
761
799
|
config = await UserConversationConfig.objects.filter(user=user).prefetch_related("setting").afirst()
|
|
762
|
-
if
|
|
763
|
-
return
|
|
764
|
-
return
|
|
800
|
+
if config:
|
|
801
|
+
return config.setting
|
|
802
|
+
return ConversationAdapters.aget_advanced_conversation_config()
|
|
765
803
|
|
|
766
804
|
@staticmethod
|
|
767
805
|
async def aget_voice_model_config(user: KhojUser) -> Optional[VoiceModelOption]:
|
|
@@ -784,35 +822,38 @@ class ConversationAdapters:
|
|
|
784
822
|
@staticmethod
|
|
785
823
|
def get_default_conversation_config():
|
|
786
824
|
server_chat_settings = ServerChatSettings.objects.first()
|
|
787
|
-
if server_chat_settings is None or server_chat_settings.
|
|
825
|
+
if server_chat_settings is None or server_chat_settings.chat_default is None:
|
|
788
826
|
return ChatModelOptions.objects.filter().first()
|
|
789
|
-
return server_chat_settings.
|
|
827
|
+
return server_chat_settings.chat_default
|
|
790
828
|
|
|
791
829
|
@staticmethod
|
|
792
830
|
async def aget_default_conversation_config():
|
|
793
831
|
server_chat_settings: ServerChatSettings = (
|
|
794
832
|
await ServerChatSettings.objects.filter()
|
|
795
|
-
.prefetch_related("
|
|
833
|
+
.prefetch_related("chat_default", "chat_default__openai_config")
|
|
796
834
|
.afirst()
|
|
797
835
|
)
|
|
798
|
-
if server_chat_settings is None or server_chat_settings.
|
|
836
|
+
if server_chat_settings is None or server_chat_settings.chat_default is None:
|
|
799
837
|
return await ChatModelOptions.objects.filter().prefetch_related("openai_config").afirst()
|
|
800
|
-
return server_chat_settings.
|
|
838
|
+
return server_chat_settings.chat_default
|
|
801
839
|
|
|
802
840
|
@staticmethod
|
|
803
|
-
|
|
841
|
+
def get_advanced_conversation_config():
|
|
842
|
+
server_chat_settings = ServerChatSettings.objects.first()
|
|
843
|
+
if server_chat_settings is None or server_chat_settings.chat_advanced is None:
|
|
844
|
+
return ConversationAdapters.get_default_conversation_config()
|
|
845
|
+
return server_chat_settings.chat_advanced
|
|
846
|
+
|
|
847
|
+
@staticmethod
|
|
848
|
+
async def aget_advanced_conversation_config():
|
|
804
849
|
server_chat_settings: ServerChatSettings = (
|
|
805
850
|
await ServerChatSettings.objects.filter()
|
|
806
|
-
.prefetch_related(
|
|
807
|
-
"summarizer_model", "default_model", "default_model__openai_config", "summarizer_model__openai_config"
|
|
808
|
-
)
|
|
851
|
+
.prefetch_related("chat_advanced", "chat_advanced__openai_config")
|
|
809
852
|
.afirst()
|
|
810
853
|
)
|
|
811
|
-
if server_chat_settings is None or
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
return await ChatModelOptions.objects.filter().prefetch_related("openai_config").afirst()
|
|
815
|
-
return server_chat_settings.summarizer_model or server_chat_settings.default_model
|
|
854
|
+
if server_chat_settings is None or server_chat_settings.chat_advanced is None:
|
|
855
|
+
return await ConversationAdapters.aget_default_conversation_config()
|
|
856
|
+
return server_chat_settings.chat_advanced
|
|
816
857
|
|
|
817
858
|
@staticmethod
|
|
818
859
|
def create_conversation_from_public_conversation(
|
|
@@ -1048,7 +1089,7 @@ class FileObjectAdapters:
|
|
|
1048
1089
|
|
|
1049
1090
|
|
|
1050
1091
|
class EntryAdapters:
|
|
1051
|
-
|
|
1092
|
+
word_filter = WordFilter()
|
|
1052
1093
|
file_filter = FileFilter()
|
|
1053
1094
|
date_filter = DateFilter()
|
|
1054
1095
|
|
|
@@ -1150,14 +1191,14 @@ class EntryAdapters:
|
|
|
1150
1191
|
def apply_filters(user: KhojUser, query: str, file_type_filter: str = None):
|
|
1151
1192
|
q_filter_terms = Q()
|
|
1152
1193
|
|
|
1153
|
-
|
|
1194
|
+
word_filters = EntryAdapters.word_filter.get_filter_terms(query)
|
|
1154
1195
|
file_filters = EntryAdapters.file_filter.get_filter_terms(query)
|
|
1155
1196
|
date_filters = EntryAdapters.date_filter.get_query_date_range(query)
|
|
1156
1197
|
|
|
1157
|
-
if len(
|
|
1198
|
+
if len(word_filters) == 0 and len(file_filters) == 0 and len(date_filters) == 0:
|
|
1158
1199
|
return Entry.objects.filter(user=user)
|
|
1159
1200
|
|
|
1160
|
-
for term in
|
|
1201
|
+
for term in word_filters:
|
|
1161
1202
|
if term.startswith("+"):
|
|
1162
1203
|
q_filter_terms &= Q(raw__icontains=term[1:])
|
|
1163
1204
|
elif term.startswith("-"):
|
|
@@ -1167,7 +1208,16 @@ class EntryAdapters:
|
|
|
1167
1208
|
|
|
1168
1209
|
if len(file_filters) > 0:
|
|
1169
1210
|
for term in file_filters:
|
|
1170
|
-
|
|
1211
|
+
if term.startswith("-"):
|
|
1212
|
+
# Convert the glob term to a regex pattern
|
|
1213
|
+
regex_term = re.escape(term[1:]).replace(r"\*", ".*").replace(r"\?", ".")
|
|
1214
|
+
# Exclude all files that match the regex term
|
|
1215
|
+
q_file_filter_terms &= ~Q(file_path__regex=regex_term)
|
|
1216
|
+
else:
|
|
1217
|
+
# Convert the glob term to a regex pattern
|
|
1218
|
+
regex_term = re.escape(term).replace(r"\*", ".*").replace(r"\?", ".")
|
|
1219
|
+
# Include any files that match the regex term
|
|
1220
|
+
q_file_filter_terms |= Q(file_path__regex=regex_term)
|
|
1171
1221
|
|
|
1172
1222
|
q_filter_terms &= q_file_filter_terms
|
|
1173
1223
|
|
|
@@ -1182,9 +1232,7 @@ class EntryAdapters:
|
|
|
1182
1232
|
formatted_max_date = date.fromtimestamp(max_date).strftime("%Y-%m-%d")
|
|
1183
1233
|
q_filter_terms &= Q(embeddings_dates__date__lte=formatted_max_date)
|
|
1184
1234
|
|
|
1185
|
-
relevant_entries = Entry.objects.filter(user=user).filter(
|
|
1186
|
-
q_filter_terms,
|
|
1187
|
-
)
|
|
1235
|
+
relevant_entries = Entry.objects.filter(user=user).filter(q_filter_terms)
|
|
1188
1236
|
if file_type_filter:
|
|
1189
1237
|
relevant_entries = relevant_entries.filter(file_type=file_type_filter)
|
|
1190
1238
|
return relevant_entries
|
khoj/database/admin.py
CHANGED
|
@@ -26,6 +26,7 @@ from khoj.database.models import (
|
|
|
26
26
|
SpeechToTextModelOptions,
|
|
27
27
|
Subscription,
|
|
28
28
|
TextToImageModelConfig,
|
|
29
|
+
UserConversationConfig,
|
|
29
30
|
UserSearchModelConfig,
|
|
30
31
|
UserVoiceModelConfig,
|
|
31
32
|
VoiceModelOption,
|
|
@@ -94,7 +95,6 @@ admin.site.register(KhojUser, KhojUserAdmin)
|
|
|
94
95
|
|
|
95
96
|
admin.site.register(ProcessLock)
|
|
96
97
|
admin.site.register(SpeechToTextModelOptions)
|
|
97
|
-
admin.site.register(SearchModelConfig)
|
|
98
98
|
admin.site.register(ReflectiveQuestion)
|
|
99
99
|
admin.site.register(UserSearchModelConfig)
|
|
100
100
|
admin.site.register(ClientApplication)
|
|
@@ -102,6 +102,7 @@ admin.site.register(GithubConfig)
|
|
|
102
102
|
admin.site.register(NotionConfig)
|
|
103
103
|
admin.site.register(UserVoiceModelConfig)
|
|
104
104
|
admin.site.register(VoiceModelOption)
|
|
105
|
+
admin.site.register(UserConversationConfig)
|
|
105
106
|
|
|
106
107
|
|
|
107
108
|
@admin.register(Agent)
|
|
@@ -178,11 +179,22 @@ class OpenAIProcessorConversationConfigAdmin(admin.ModelAdmin):
|
|
|
178
179
|
search_fields = ("id", "name", "api_key", "api_base_url")
|
|
179
180
|
|
|
180
181
|
|
|
182
|
+
@admin.register(SearchModelConfig)
|
|
183
|
+
class SearchModelConfigAdmin(admin.ModelAdmin):
|
|
184
|
+
list_display = (
|
|
185
|
+
"id",
|
|
186
|
+
"name",
|
|
187
|
+
"bi_encoder",
|
|
188
|
+
"cross_encoder",
|
|
189
|
+
)
|
|
190
|
+
search_fields = ("id", "name", "bi_encoder", "cross_encoder")
|
|
191
|
+
|
|
192
|
+
|
|
181
193
|
@admin.register(ServerChatSettings)
|
|
182
194
|
class ServerChatSettingsAdmin(admin.ModelAdmin):
|
|
183
195
|
list_display = (
|
|
184
|
-
"
|
|
185
|
-
"
|
|
196
|
+
"chat_default",
|
|
197
|
+
"chat_advanced",
|
|
186
198
|
)
|
|
187
199
|
|
|
188
200
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Generated by Django 5.0.7 on 2024-08-07 09:12
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
dependencies = [
|
|
8
|
+
("database", "0055_alter_agent_style_icon"),
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
operations = [
|
|
12
|
+
migrations.AddField(
|
|
13
|
+
model_name="searchmodelconfig",
|
|
14
|
+
name="cross_encoder_model_config",
|
|
15
|
+
field=models.JSONField(blank=True, default=dict),
|
|
16
|
+
),
|
|
17
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Generated by Django 5.0.7 on 2024-08-16 18:18
|
|
2
|
+
|
|
3
|
+
import django.db.models.deletion
|
|
4
|
+
from django.db import migrations, models
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Migration(migrations.Migration):
|
|
8
|
+
dependencies = [
|
|
9
|
+
("database", "0056_searchmodelconfig_cross_encoder_model_config"),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.RenameField(
|
|
14
|
+
model_name="serverchatsettings",
|
|
15
|
+
old_name="default_model",
|
|
16
|
+
new_name="chat_default",
|
|
17
|
+
),
|
|
18
|
+
migrations.RemoveField(
|
|
19
|
+
model_name="serverchatsettings",
|
|
20
|
+
name="summarizer_model",
|
|
21
|
+
),
|
|
22
|
+
migrations.AddField(
|
|
23
|
+
model_name="chatmodeloptions",
|
|
24
|
+
name="subscribed_max_prompt_size",
|
|
25
|
+
field=models.IntegerField(blank=True, default=None, null=True),
|
|
26
|
+
),
|
|
27
|
+
migrations.AddField(
|
|
28
|
+
model_name="serverchatsettings",
|
|
29
|
+
name="chat_advanced",
|
|
30
|
+
field=models.ForeignKey(
|
|
31
|
+
blank=True,
|
|
32
|
+
default=None,
|
|
33
|
+
null=True,
|
|
34
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
35
|
+
related_name="chat_advanced",
|
|
36
|
+
to="database.chatmodeloptions",
|
|
37
|
+
),
|
|
38
|
+
),
|
|
39
|
+
migrations.AlterField(
|
|
40
|
+
model_name="serverchatsettings",
|
|
41
|
+
name="chat_default",
|
|
42
|
+
field=models.ForeignKey(
|
|
43
|
+
blank=True,
|
|
44
|
+
default=None,
|
|
45
|
+
null=True,
|
|
46
|
+
on_delete=django.db.models.deletion.CASCADE,
|
|
47
|
+
related_name="chat_default",
|
|
48
|
+
to="database.chatmodeloptions",
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
]
|
khoj/database/models/__init__.py
CHANGED
|
@@ -89,6 +89,7 @@ class ChatModelOptions(BaseModel):
|
|
|
89
89
|
ANTHROPIC = "anthropic"
|
|
90
90
|
|
|
91
91
|
max_prompt_size = models.IntegerField(default=None, null=True, blank=True)
|
|
92
|
+
subscribed_max_prompt_size = models.IntegerField(default=None, null=True, blank=True)
|
|
92
93
|
tokenizer = models.CharField(max_length=200, default=None, null=True, blank=True)
|
|
93
94
|
chat_model = models.CharField(max_length=200, default="NousResearch/Hermes-2-Pro-Mistral-7B-GGUF")
|
|
94
95
|
model_type = models.CharField(max_length=200, choices=ModelType.choices, default=ModelType.OFFLINE)
|
|
@@ -205,11 +206,11 @@ class GithubRepoConfig(BaseModel):
|
|
|
205
206
|
|
|
206
207
|
|
|
207
208
|
class ServerChatSettings(BaseModel):
|
|
208
|
-
|
|
209
|
-
ChatModelOptions, on_delete=models.CASCADE, default=None, null=True, blank=True, related_name="
|
|
209
|
+
chat_default = models.ForeignKey(
|
|
210
|
+
ChatModelOptions, on_delete=models.CASCADE, default=None, null=True, blank=True, related_name="chat_default"
|
|
210
211
|
)
|
|
211
|
-
|
|
212
|
-
ChatModelOptions, on_delete=models.CASCADE, default=None, null=True, blank=True, related_name="
|
|
212
|
+
chat_advanced = models.ForeignKey(
|
|
213
|
+
ChatModelOptions, on_delete=models.CASCADE, default=None, null=True, blank=True, related_name="chat_advanced"
|
|
213
214
|
)
|
|
214
215
|
|
|
215
216
|
|
|
@@ -259,6 +260,8 @@ class SearchModelConfig(BaseModel):
|
|
|
259
260
|
bi_encoder_docs_encode_config = models.JSONField(default=dict, blank=True)
|
|
260
261
|
# Cross-encoder model of sentence-transformer type to load from HuggingFace
|
|
261
262
|
cross_encoder = models.CharField(max_length=200, default="mixedbread-ai/mxbai-rerank-xsmall-v1")
|
|
263
|
+
# Config passed to the cross-encoder model constructor. E.g. device="cuda:0", trust_remote_server=True etc.
|
|
264
|
+
cross_encoder_model_config = models.JSONField(default=dict, blank=True)
|
|
262
265
|
# Inference server API endpoint to use for embeddings inference. Bi-encoder model should be hosted on this server
|
|
263
266
|
embeddings_inference_endpoint = models.CharField(max_length=200, default=None, null=True, blank=True)
|
|
264
267
|
# Inference server API Key to use for embeddings inference. Bi-encoder model should be hosted on this server
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/0e790e04fd40ad16-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/1538cedb321e3a97.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/9d5b867ec04494a6.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-c6008e79c8ef349d.js"/><script src="/_next/static/chunks/fd9d1056-2b978342deb60015.js" async=""></script><script src="/_next/static/chunks/7023-52c1be60135eb057.js" async=""></script><script src="/_next/static/chunks/main-app-6d6ee3495efe03d4.js" async=""></script><meta http-equiv="Content-Security-Policy" content="default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';"/><title>404: This page could not be found.</title><title>Khoj AI - Home</title><meta name="description" content="Your Second Brain."/><link rel="manifest" href="/static/khoj.webmanifest" crossorigin="use-credentials"/><meta property="og:title" content="Khoj AI - Home"/><meta property="og:description" content="Your Second Brain."/><meta property="og:url" content="https://app.khoj.dev/"/><meta property="og:site_name" content="Khoj AI"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta property="og:image:width" content="256"/><meta property="og:image:height" content="256"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta property="og:image:width" content="1200"/><meta property="og:image:height" content="630"/><meta property="og:type" content="website"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Khoj AI - Home"/><meta name="twitter:description" content="Your Second Brain."/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta name="twitter:image:width" content="256"/><meta name="twitter:image:height" content="256"/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta name="twitter:image:width" content="1200"/><meta name="twitter:image:height" content="630"/><link rel="icon" href="/static/assets/icons/khoj_lantern.ico"/><link rel="apple-touch-icon" href="/static/assets/icons/khoj_lantern_256x256.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_90df87"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/_next/static/chunks/webpack-c6008e79c8ef349d.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e790e04fd40ad16-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/1538cedb321e3a97.css\",\"style\"]\n3:HL[\"/_next/static/css/9d5b867ec04494a6.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[95751,[],\"\"]\n6:I[39275,[],\"\"]\n7:I[61343,[],\"\"]\nd:I[76130,[],\"\"]\n8:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n9:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\na:{\"display\":\"inline-block\"}\nb:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\ne:[]\n"])</script><script>self.__next_f.push([1,"0:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/1538cedb321e3a97.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/9d5b867ec04494a6.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"buildId\":\"EuaXDNeXisAc9H0EHd10x\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/_not-found/\",\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]]],null],null]},[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[[\"$\",\"meta\",null,{\"httpEquiv\":\"Content-Security-Policy\",\"content\":\"default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';\"}],[\"$\",\"body\",null,{\"className\":\"__className_90df87\",\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$8\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$9\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$a\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$b\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[],\"styles\":null}]}]]}],null],null],\"couldBeIntercepted\":false,\"initialHead\":[false,\"$Lc\"],\"globalErrorComponent\":\"$d\",\"missingSlots\":\"$We\"}]]\n"])</script><script>self.__next_f.push([1,"c:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"link\",\"4\",{\"rel\":\"manifest\",\"href\":\"/static/khoj.webmanifest\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"5\",{\"property\":\"og:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"6\",{\"property\":\"og:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"7\",{\"property\":\"og:url\",\"content\":\"https://app.khoj.dev/\"}],[\"$\",\"meta\",\"8\",{\"property\":\"og:site_name\",\"content\":\"Khoj AI\"}],[\"$\",\"meta\",\"9\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"10\",{\"property\":\"og:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"11\",{\"property\":\"og:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"12\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"13\",{\"property\":\"og:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"14\",{\"property\":\"og:image:height\",\"content\":\"630\"}],[\"$\",\"meta\",\"15\",{\"property\":\"og:type\",\"content\":\"website\"}],[\"$\",\"meta\",\"16\",{\"name\":\"twitter:card\",\"content\":\"summary_large_image\"}],[\"$\",\"meta\",\"17\",{\"name\":\"twitter:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"18\",{\"name\":\"twitter:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"19\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"20\",{\"name\":\"twitter:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"21\",{\"name\":\"twitter:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"22\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"23\",{\"name\":\"twitter:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"24\",{\"name\":\"twitter:image:height\",\"content\":\"630\"}],[\"$\",\"link\",\"25\",{\"rel\":\"icon\",\"href\":\"/static/assets/icons/khoj_lantern.ico\"}],[\"$\",\"link\",\"26\",{\"rel\":\"apple-touch-icon\",\"href\":\"/static/assets/icons/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"27\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"5:null\n"])</script></body></html>
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" href="/_next/static/media/0e790e04fd40ad16-s.p.woff2" as="font" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/1538cedb321e3a97.css" data-precedence="next"/><link rel="stylesheet" href="/_next/static/css/9d5b867ec04494a6.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-9953d80989df2d20.js"/><script src="/_next/static/chunks/fd9d1056-2b978342deb60015.js" async=""></script><script src="/_next/static/chunks/7023-52c1be60135eb057.js" async=""></script><script src="/_next/static/chunks/main-app-6d6ee3495efe03d4.js" async=""></script><meta http-equiv="Content-Security-Policy" content="default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';"/><title>404: This page could not be found.</title><title>Khoj AI - Home</title><meta name="description" content="Your Second Brain."/><link rel="manifest" href="/static/khoj.webmanifest" crossorigin="use-credentials"/><meta property="og:title" content="Khoj AI - Home"/><meta property="og:description" content="Your Second Brain."/><meta property="og:url" content="https://app.khoj.dev/"/><meta property="og:site_name" content="Khoj AI"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta property="og:image:width" content="256"/><meta property="og:image:height" content="256"/><meta property="og:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta property="og:image:width" content="1200"/><meta property="og:image:height" content="630"/><meta property="og:type" content="website"/><meta name="twitter:card" content="summary_large_image"/><meta name="twitter:title" content="Khoj AI - Home"/><meta name="twitter:description" content="Your Second Brain."/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_256x256.png"/><meta name="twitter:image:width" content="256"/><meta name="twitter:image:height" content="256"/><meta name="twitter:image" content="https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png"/><meta name="twitter:image:width" content="1200"/><meta name="twitter:image:height" content="630"/><link rel="icon" href="/static/assets/icons/khoj_lantern.ico"/><link rel="apple-touch-icon" href="/static/assets/icons/khoj_lantern_256x256.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_90df87"><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/_next/static/chunks/webpack-9953d80989df2d20.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e790e04fd40ad16-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/1538cedb321e3a97.css\",\"style\"]\n3:HL[\"/_next/static/css/9d5b867ec04494a6.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[95751,[],\"\"]\n6:I[39275,[],\"\"]\n7:I[61343,[],\"\"]\nd:I[76130,[],\"\"]\n8:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n9:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\na:{\"display\":\"inline-block\"}\nb:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\ne:[]\n"])</script><script>self.__next_f.push([1,"0:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/1538cedb321e3a97.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/9d5b867ec04494a6.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"buildId\":\"QSaUkpIwMzbLQnDFgPg3j\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/_not-found/\",\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]]],null],null]},[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[[\"$\",\"meta\",null,{\"httpEquiv\":\"Content-Security-Policy\",\"content\":\"default-src 'self' https://assets.khoj.dev; media-src * blob:; script-src 'self' https://assets.khoj.dev 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://ipapi.co/json ws://localhost:42110; style-src 'self' https://assets.khoj.dev 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https://*.khoj.dev https://*.googleusercontent.com https://*.google.com/ https://*.gstatic.com; font-src 'self' https://assets.khoj.dev https://fonts.gstatic.com; child-src 'none'; object-src 'none';\"}],[\"$\",\"body\",null,{\"className\":\"__className_90df87\",\"children\":[\"$\",\"$L6\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L7\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$8\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$9\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$a\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$b\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[],\"styles\":null}]}]]}],null],null],\"couldBeIntercepted\":false,\"initialHead\":[false,\"$Lc\"],\"globalErrorComponent\":\"$d\",\"missingSlots\":\"$We\"}]]\n"])</script><script>self.__next_f.push([1,"c:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"link\",\"4\",{\"rel\":\"manifest\",\"href\":\"/static/khoj.webmanifest\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"5\",{\"property\":\"og:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"6\",{\"property\":\"og:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"7\",{\"property\":\"og:url\",\"content\":\"https://app.khoj.dev/\"}],[\"$\",\"meta\",\"8\",{\"property\":\"og:site_name\",\"content\":\"Khoj AI\"}],[\"$\",\"meta\",\"9\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"10\",{\"property\":\"og:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"11\",{\"property\":\"og:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"12\",{\"property\":\"og:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"13\",{\"property\":\"og:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"14\",{\"property\":\"og:image:height\",\"content\":\"630\"}],[\"$\",\"meta\",\"15\",{\"property\":\"og:type\",\"content\":\"website\"}],[\"$\",\"meta\",\"16\",{\"name\":\"twitter:card\",\"content\":\"summary_large_image\"}],[\"$\",\"meta\",\"17\",{\"name\":\"twitter:title\",\"content\":\"Khoj AI - Home\"}],[\"$\",\"meta\",\"18\",{\"name\":\"twitter:description\",\"content\":\"Your Second Brain.\"}],[\"$\",\"meta\",\"19\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"20\",{\"name\":\"twitter:image:width\",\"content\":\"256\"}],[\"$\",\"meta\",\"21\",{\"name\":\"twitter:image:height\",\"content\":\"256\"}],[\"$\",\"meta\",\"22\",{\"name\":\"twitter:image\",\"content\":\"https://assets.khoj.dev/khoj_lantern_logomarktype_1200x630.png\"}],[\"$\",\"meta\",\"23\",{\"name\":\"twitter:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"24\",{\"name\":\"twitter:image:height\",\"content\":\"630\"}],[\"$\",\"link\",\"25\",{\"rel\":\"icon\",\"href\":\"/static/assets/icons/khoj_lantern.ico\"}],[\"$\",\"link\",\"26\",{\"rel\":\"apple-touch-icon\",\"href\":\"/static/assets/icons/khoj_lantern_256x256.png\"}],[\"$\",\"meta\",\"27\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"5:null\n"])</script></body></html>
|
khoj/interface/compiled/_next/static/chunks/{9178-5a1fa2b9023249af.js → 9178-b9ab3fa2e9be8287.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9178],{89178:function(e,t,a){"use strict";a.d(t,{H:function(){return Q},Z:function(){return X}});var s=a(57437),n=a(34531),l=a.n(n),r=a(14944),o=a(39952),c=a.n(o),i=a(2265);a(7395);var d=a(26100),h=a(36013),u=a(13304),m=a(12218),g=a(74697),p=a(37440);let f=u.fC,x=u.xz;u.x8;let w=u.h_,j=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(u.aV,{className:(0,p.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n,ref:t})});j.displayName=u.aV.displayName;let y=(0,m.j)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),b=i.forwardRef((e,t)=>{let{side:a="right",className:n,children:l,...r}=e;return(0,s.jsxs)(w,{children:[(0,s.jsx)(j,{}),(0,s.jsxs)(u.VY,{ref:t,className:(0,p.cn)(y({side:a}),n),...r,children:[l,(0,s.jsxs)(u.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,s.jsx)(g.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});b.displayName=u.VY.displayName;let N=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,p.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};N.displayName="SheetHeader";let k=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(u.Dx,{ref:t,className:(0,p.cn)("text-lg font-semibold text-foreground",a),...n})});k.displayName=u.Dx.displayName;let C=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(u.dk,{ref:t,className:(0,p.cn)("text-sm text-muted-foreground",a),...n})});C.displayName=u.dk.displayName;var M=a(19573),v=a(11838),_=a.n(v),R=a(89417);let E=new r.Z({html:!0,linkify:!0,typographer:!0});function T(e){let t=(0,R.L)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?_().sanitize(E.render(t)):_().sanitize(t)}(e),[n,l]=(0,i.useState)(!1);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(M.J2,{open:n&&!e.showFullContent,onOpenChange:l,children:[(0,s.jsx)(M.xo,{asChild:!0,children:(0,s.jsxs)(h.Zb,{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg p-2 bg-muted border-none"),children:[(0,s.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.title]}),(0,s.jsx)("p",{className:"".concat(e.showFullContent?"block":"overflow-hidden line-clamp-2"),dangerouslySetInnerHTML:{__html:a}})]})}),(0,s.jsx)(M.yk,{className:"w-[400px] mx-2",children:(0,s.jsxs)(h.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg p-2 border-none",children:[(0,s.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,s.jsx)("p",{className:"overflow-hidden line-clamp-3",dangerouslySetInnerHTML:{__html:a}})]})})]})})}function L(e){let[t,a]=(0,i.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let n="https://www.google.com/s2/favicons?domain=globe",l="unknown";try{l=new URL(e.link).hostname,n="https://www.google.com/s2/favicons?domain=".concat(l)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(M.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,s.jsx)(M.xo,{asChild:!0,children:(0,s.jsx)(h.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words rounded-lg text-balance p-2 bg-muted border-none"),children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]})})})}),(0,s.jsx)(M.yk,{className:"w-[400px] mx-2",children:(0,s.jsx)(h.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-3"),children:e.description})]})})})})]})})}function D(e){let[t,a]=(0,i.useState)(3);(0,i.useEffect)(()=>{a(e.isMobileWidth?1:3)},[e.isMobileWidth]);let n=e.notesReferenceCardData.slice(0,t),l=n.length<t?e.onlineReferenceCardData.slice(0,t-n.length):[],r=e.notesReferenceCardData.length>0||e.onlineReferenceCardData.length>0,o=e.notesReferenceCardData.length+e.onlineReferenceCardData.length;return 0===o?null:(0,s.jsxs)("div",{className:"pt-0 px-4 pb-4 md:px-6",children:[(0,s.jsxs)("h3",{className:"inline-flex items-center",children:["References",(0,s.jsxs)("p",{className:"text-gray-400 m-2",children:[o," sources"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[n.map((e,t)=>(0,i.createElement)(T,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),l.map((e,t)=>(0,i.createElement)(L,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),r&&(0,s.jsx)(F,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData})]})]})}function F(e){return e.notesReferenceCardData||e.onlineReferenceCardData?(0,s.jsxs)(f,{children:[(0,s.jsxs)(x,{className:"text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center !m-2 inline-flex",children:["View references",(0,s.jsx)(d.o,{className:"m-1"})]}),(0,s.jsxs)(b,{className:"overflow-y-scroll",children:[(0,s.jsxs)(N,{children:[(0,s.jsx)(k,{children:"References"}),(0,s.jsx)(C,{children:"View all references for this response"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.notesReferenceCardData.map((e,t)=>(0,i.createElement)(T,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,i.createElement)(L,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]}):null}var S=a(34149),B=a(29386),H=a(31784),O=a(60665),A=a(96006),Z=a(18444),q=a(35304),$=a(8589),P=a(63205),W=a(92880),z=a(48408),G=a(67722),I=a(58485),U=a(58575),V=a(25800);let Y=new r.Z({html:!0,linkify:!0,typographer:!0});function J(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function K(e){let{uquery:t,kquery:a}=e,[n,r]=(0,i.useState)(null);return(0,i.useEffect)(()=>{null!==n&&setTimeout(()=>{r(null)},2e3)},[n]),(0,s.jsxs)("div",{className:"".concat(l().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,s.jsx)("button",{title:"Like",className:l().thumbsUpButton,disabled:null!==n,onClick:()=>{J(t,a,"positive"),r(!0)},children:!0===n?(0,s.jsx)(S.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,s.jsx)(S.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,s.jsx)("button",{title:"Dislike",className:l().thumbsDownButton,disabled:null!==n,onClick:()=>{J(t,a,"negative"),r(!1)},children:!1===n?(0,s.jsx)(B.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,s.jsx)(B.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function Q(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),n="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,s.jsx)(H.a,{className:"".concat(n)}):a.includes("generating")?(0,s.jsx)(O.Z,{className:"".concat(n)}):a.includes("data sources")||a.includes("notes")?(0,s.jsx)(A.g,{className:"".concat(n)}):a.includes("read")?(0,s.jsx)(Z.f,{className:"".concat(n)}):a.includes("search")?(0,s.jsx)(q.Y,{className:"".concat(n)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,s.jsx)($.u,{className:"".concat(n)}):a.includes("paint")?(0,s.jsx)(P.Y,{className:"".concat(n)}):(0,s.jsx)(H.a,{className:"".concat(n)})}(t?t[1]:"",e.primary?(0,U.oz)(e.agentColor):"text-gray-500"),n=_().sanitize(Y.render(e.message));return(0,s.jsxs)("div",{className:"".concat(l().trainOfThoughtElement," items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(l().trainOfThought," ").concat(e.primary?l().primary:""),children:[a,(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}function X(e){var t,a;let n,r,o,c,d;let[h,u]=(0,i.useState)(!1),[m,g]=(0,i.useState)(!1),[p,f]=(0,i.useState)(""),[x,w]=(0,i.useState)(!1),[j,y]=(0,i.useState)(!1),b=(0,i.useRef)(!1),N=(0,i.useRef)(null);if((0,i.useEffect)(()=>{b.current=j},[j]),(0,i.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(N.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,V.Z)(N.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1}]})});return N.current&&e.observe(N.current,{childList:!0}),()=>e.disconnect()},[N.current]),(0,i.useEffect)(()=>{var t;let a=e.chatMessage.message;a=a.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET"),e.chatMessage.intent&&"text-to-image"==e.chatMessage.intent.type?a=""):e.chatMessage.intent&&"text-to-image2"==e.chatMessage.intent.type?a=""):e.chatMessage.intent&&"text-to-image-v3"==e.chatMessage.intent.type&&(a="")),e.chatMessage.intent&&e.chatMessage.intent.type.includes("text-to-image")&&(null===(t=e.chatMessage.intent["inferred-queries"])||void 0===t?void 0:t.length)>0&&(a+="\n\n**Inferred Query**\n\n".concat(e.chatMessage.intent["inferred-queries"][0]));let s=Y.render(a);s=s.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),f(_().sanitize(s))},[e.chatMessage.message,e.chatMessage.intent]),(0,i.useEffect)(()=>{h&&setTimeout(()=>{u(!1)},2e3)},[h]),(0,i.useEffect)(()=>{N.current&&(N.current.querySelectorAll("pre > .hljs").forEach(e=>{let t=document.createElement("button"),a=document.createElement("img");a.src="/static/copy-button.svg",a.alt="Copy",a.width=24,a.height=24,t.appendChild(a),t.className="hljs ".concat(l().codeCopyButton),t.addEventListener("click",()=>{let t=e.textContent||"";t=(t=(t=t.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(t),a.src="/static/copy-button-success.svg"}),e.prepend(t)}),console.log("render katex within the chat message"),(0,V.Z)(N.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1}]}))},[p,m,N]),!e.chatMessage.message)return null;async function k(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;w(!0);let a=C(t[0]);for(let e=0;e<t.length&&!b.current;e++){let s=a;e<t.length-1&&(a=C(t[e+1]));try{let e=await s,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let s=new Audio(e);s.onended=t,s.onerror=a,s.play()})}(t)}catch(e){console.error("Error:",e);break}}w(!1),y(!1)}async function C(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}let M=function(e,t){let a=[],s=[];if(t){let e=[];for(let[a,s]of Object.entries(t)){if(s.answerBox&&e.push({title:s.answerBox.title,description:s.answerBox.answer,link:s.answerBox.source}),s.knowledgeGraph&&e.push({title:s.knowledgeGraph.title,description:s.knowledgeGraph.description,link:s.knowledgeGraph.descriptionLink}),s.webpages){if(s.webpages instanceof Array){let t=s.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=s.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(s.organic){let t=s.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}a.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:a}}(e.chatMessage.context,e.chatMessage.onlineContext);return(0,s.jsxs)("div",{className:(t=e.chatMessage,(n=[l().chatMessageContainer,"shadow-md"]).push(l()[t.by]),e.customClassName&&n.push(l()["".concat(t.by).concat(e.customClassName)]),n.join(" ")),onMouseLeave:e=>g(!1),onMouseEnter:e=>g(!0),onClick:"khoj"===e.chatMessage.by?e=>void 0:void 0,children:[(0,s.jsx)("div",{className:(a=e.chatMessage,(r=[l().chatMessageWrapper]).push(l()[a.by]),"khoj"===a.by&&r.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),r.join(" ")),children:(0,s.jsx)("div",{ref:N,className:l().chatMessage,dangerouslySetInnerHTML:{__html:p}})}),(0,s.jsx)("div",{className:l().teaserReferencesContainer,children:(0,s.jsx)(D,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:M.notesReferenceCardData,onlineReferenceCardData:M.onlineReferenceCardData})}),(0,s.jsx)("div",{className:l().chatFooter,children:(m||e.isMobileWidth||e.isLastMessage||x)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{title:(c=(o=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),d=o.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(c," on ").concat(d)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,s.jsxs)("div",{className:"".concat(l().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(x?j?(0,s.jsx)(I.l,{iconClassName:"p-0",className:"m-0"}):(0,s.jsx)("button",{title:"Pause Speech",onClick:e=>y(!0),children:(0,s.jsx)(W.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,s.jsx)("button",{title:"Speak",onClick:e=>k(),children:(0,s.jsx)(z.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),(0,s.jsx)("button",{title:"Copy",className:"".concat(l().copyButton),onClick:()=>{navigator.clipboard.writeText(e.chatMessage.message),u(!0)},children:h?(0,s.jsx)(G.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,s.jsx)(G.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,s.jsx)(K,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,s.jsx)(K,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})}Y.use(c(),{inline:!0,code:!0})},34531:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}}}]);
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9178],{89178:function(e,t,a){"use strict";a.d(t,{H:function(){return Q},Z:function(){return X}});var s=a(57437),n=a(34531),l=a.n(n),r=a(14944),o=a(39952),c=a.n(o),i=a(2265);a(7395);var d=a(26100),h=a(36013),u=a(13304),m=a(12218),g=a(74697),p=a(37440);let f=u.fC,x=u.xz;u.x8;let w=u.h_,j=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(u.aV,{className:(0,p.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...n,ref:t})});j.displayName=u.aV.displayName;let y=(0,m.j)("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),b=i.forwardRef((e,t)=>{let{side:a="right",className:n,children:l,...r}=e;return(0,s.jsxs)(w,{children:[(0,s.jsx)(j,{}),(0,s.jsxs)(u.VY,{ref:t,className:(0,p.cn)(y({side:a}),n),...r,children:[l,(0,s.jsxs)(u.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[(0,s.jsx)(g.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});b.displayName=u.VY.displayName;let N=e=>{let{className:t,...a}=e;return(0,s.jsx)("div",{className:(0,p.cn)("flex flex-col space-y-2 text-center sm:text-left",t),...a})};N.displayName="SheetHeader";let k=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(u.Dx,{ref:t,className:(0,p.cn)("text-lg font-semibold text-foreground",a),...n})});k.displayName=u.Dx.displayName;let C=i.forwardRef((e,t)=>{let{className:a,...n}=e;return(0,s.jsx)(u.dk,{ref:t,className:(0,p.cn)("text-sm text-muted-foreground",a),...n})});C.displayName=u.dk.displayName;var M=a(19573),v=a(11838),_=a.n(v),R=a(89417);let E=new r.Z({html:!0,linkify:!0,typographer:!0});function T(e){let t=(0,R.L)(e.title||".txt","w-6 h-6 text-muted-foreground inline-flex mr-2"),a=function(e){let t=["org","md","markdown"].includes(e.title.split(".").pop()||"")?e.content.split("\n").slice(1).join("\n"):e.content;return e.showFullContent?_().sanitize(E.render(t)):_().sanitize(t)}(e),[n,l]=(0,i.useState)(!1);return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(M.J2,{open:n&&!e.showFullContent,onOpenChange:l,children:[(0,s.jsx)(M.xo,{asChild:!0,children:(0,s.jsxs)(h.Zb,{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words text-balance rounded-lg p-2 bg-muted border-none"),children:[(0,s.jsxs)("h3",{className:"".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground}"),children:[t,e.title]}),(0,s.jsx)("p",{className:"".concat(e.showFullContent?"block":"overflow-hidden line-clamp-2"),dangerouslySetInnerHTML:{__html:a}})]})}),(0,s.jsx)(M.yk,{className:"w-[400px] mx-2",children:(0,s.jsxs)(h.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg p-2 border-none",children:[(0,s.jsxs)("h3",{className:"line-clamp-2 text-muted-foreground}",children:[t,e.title]}),(0,s.jsx)("p",{className:"overflow-hidden line-clamp-3",dangerouslySetInnerHTML:{__html:a}})]})})]})})}function L(e){let[t,a]=(0,i.useState)(!1);if(!e.link||e.link.split(" ").length>1)return null;let n="https://www.google.com/s2/favicons?domain=globe",l="unknown";try{l=new URL(e.link).hostname,n="https://www.google.com/s2/favicons?domain=".concat(l)}catch(t){return console.warn("Error parsing domain from link: ".concat(e.link)),null}return(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(M.J2,{open:t&&!e.showFullContent,onOpenChange:a,children:[(0,s.jsx)(M.xo,{asChild:!0,children:(0,s.jsx)(h.Zb,{onMouseEnter:()=>{a(!0)},onMouseLeave:()=>{a(!1)},className:"".concat(e.showFullContent?"w-auto":"w-[200px]"," overflow-hidden break-words rounded-lg text-balance p-2 bg-muted border-none"),children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-1"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"),children:e.description})]})})})}),(0,s.jsx)(M.yk,{className:"w-[400px] mx-2",children:(0,s.jsx)(h.Zb,{className:"w-auto overflow-hidden break-words text-balance rounded-lg border-none",children:(0,s.jsx)("div",{className:"flex flex-col",children:(0,s.jsxs)("a",{href:e.link,target:"_blank",rel:"noreferrer",className:"!no-underline p-2",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:n,alt:"",className:"!w-4 h-4 mr-2"}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," text-muted-foreground"),children:l})]}),(0,s.jsx)("h3",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-2"," font-bold"),children:e.title}),(0,s.jsx)("p",{className:"overflow-hidden ".concat(e.showFullContent?"block":"line-clamp-3"),children:e.description})]})})})})]})})}function D(e){let[t,a]=(0,i.useState)(3);(0,i.useEffect)(()=>{a(e.isMobileWidth?1:3)},[e.isMobileWidth]);let n=e.notesReferenceCardData.slice(0,t),l=n.length<t?e.onlineReferenceCardData.slice(0,t-n.length):[],r=e.notesReferenceCardData.length>0||e.onlineReferenceCardData.length>0,o=e.notesReferenceCardData.length+e.onlineReferenceCardData.length;return 0===o?null:(0,s.jsxs)("div",{className:"pt-0 px-4 pb-4 md:px-6",children:[(0,s.jsxs)("h3",{className:"inline-flex items-center",children:["References",(0,s.jsxs)("p",{className:"text-gray-400 m-2",children:[o," sources"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[n.map((e,t)=>(0,i.createElement)(T,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),l.map((e,t)=>(0,i.createElement)(L,{showFullContent:!1,...e,key:"".concat(e.title,"-").concat(t)})),r&&(0,s.jsx)(F,{notesReferenceCardData:e.notesReferenceCardData,onlineReferenceCardData:e.onlineReferenceCardData})]})]})}function F(e){return e.notesReferenceCardData||e.onlineReferenceCardData?(0,s.jsxs)(f,{children:[(0,s.jsxs)(x,{className:"text-balance w-auto md:w-[200px] justify-start overflow-hidden break-words p-0 bg-transparent border-none text-gray-400 align-middle items-center !m-2 inline-flex",children:["View references",(0,s.jsx)(d.o,{className:"m-1"})]}),(0,s.jsxs)(b,{className:"overflow-y-scroll",children:[(0,s.jsxs)(N,{children:[(0,s.jsx)(k,{children:"References"}),(0,s.jsx)(C,{children:"View all references for this response"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 w-auto mt-2",children:[e.notesReferenceCardData.map((e,t)=>(0,i.createElement)(T,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)})),e.onlineReferenceCardData.map((e,t)=>(0,i.createElement)(L,{showFullContent:!0,...e,key:"".concat(e.title,"-").concat(t)}))]})]})]}):null}var S=a(34149),B=a(29386),H=a(31784),O=a(60665),A=a(96006),Z=a(18444),q=a(35304),$=a(8589),P=a(63205),W=a(92880),z=a(48408),G=a(67722),I=a(58485),U=a(58575),V=a(25800);let Y=new r.Z({html:!0,linkify:!0,typographer:!0});function J(e,t,a){fetch("/api/chat/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({uquery:e,kquery:t,sentiment:a})})}function K(e){let{uquery:t,kquery:a}=e,[n,r]=(0,i.useState)(null);return(0,i.useEffect)(()=>{null!==n&&setTimeout(()=>{r(null)},2e3)},[n]),(0,s.jsxs)("div",{className:"".concat(l().feedbackButtons," flex align-middle justify-center items-center"),children:[(0,s.jsx)("button",{title:"Like",className:l().thumbsUpButton,disabled:null!==n,onClick:()=>{J(t,a,"positive"),r(!0)},children:!0===n?(0,s.jsx)(S.V,{alt:"Liked Message",className:"text-green-500",weight:"fill"}):(0,s.jsx)(S.V,{alt:"Like Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),(0,s.jsx)("button",{title:"Dislike",className:l().thumbsDownButton,disabled:null!==n,onClick:()=>{J(t,a,"negative"),r(!1)},children:!1===n?(0,s.jsx)(B.L,{alt:"Disliked Message",className:"text-red-500",weight:"fill"}):(0,s.jsx)(B.L,{alt:"Dislike Message",className:"hsl(var(--muted-foreground)) hover:text-red-500"})})]})}function Q(e){let t=e.message.match(/\*\*(.*)\*\*/),a=function(e,t){let a=e.toLowerCase(),n="inline mt-1 mr-2 ".concat(t," h-4 w-4");return a.includes("understanding")?(0,s.jsx)(H.a,{className:"".concat(n)}):a.includes("generating")?(0,s.jsx)(O.Z,{className:"".concat(n)}):a.includes("data sources")||a.includes("notes")?(0,s.jsx)(A.g,{className:"".concat(n)}):a.includes("read")?(0,s.jsx)(Z.f,{className:"".concat(n)}):a.includes("search")?(0,s.jsx)(q.Y,{className:"".concat(n)}):a.includes("summary")||a.includes("summarize")||a.includes("enhanc")?(0,s.jsx)($.u,{className:"".concat(n)}):a.includes("paint")?(0,s.jsx)(P.Y,{className:"".concat(n)}):(0,s.jsx)(H.a,{className:"".concat(n)})}(t?t[1]:"",e.primary?(0,U.oz)(e.agentColor):"text-gray-500"),n=_().sanitize(Y.render(e.message));return(0,s.jsxs)("div",{className:"".concat(l().trainOfThoughtElement," items-center ").concat(e.primary?"text-gray-400":"text-gray-300"," ").concat(l().trainOfThought," ").concat(e.primary?l().primary:""),children:[a,(0,s.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}function X(e){var t,a;let n,r,o,c,d;let[h,u]=(0,i.useState)(!1),[m,g]=(0,i.useState)(!1),[p,f]=(0,i.useState)(""),[x,w]=(0,i.useState)(!1),[j,y]=(0,i.useState)(!1),b=(0,i.useRef)(!1),N=(0,i.useRef)(null);if((0,i.useEffect)(()=>{b.current=j},[j]),(0,i.useEffect)(()=>{let e=new MutationObserver((e,t)=>{if(N.current)for(let t of e)"childList"===t.type&&t.addedNodes.length>0&&(0,V.Z)(N.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1}]})});return N.current&&e.observe(N.current,{childList:!0}),()=>e.disconnect()},[N.current]),(0,i.useEffect)(()=>{var t;let a=e.chatMessage.message;a=a.replace(/\\\(/g,"LEFTPAREN").replace(/\\\)/g,"RIGHTPAREN").replace(/\\\[/g,"LEFTBRACKET").replace(/\\\]/g,"RIGHTBRACKET"),e.chatMessage.intent&&"text-to-image"==e.chatMessage.intent.type?a=""):e.chatMessage.intent&&"text-to-image2"==e.chatMessage.intent.type?a=""):e.chatMessage.intent&&"text-to-image-v3"==e.chatMessage.intent.type&&(a="")),e.chatMessage.intent&&e.chatMessage.intent.type.includes("text-to-image")&&(null===(t=e.chatMessage.intent["inferred-queries"])||void 0===t?void 0:t.length)>0&&(a+="\n\n**Inferred Query**\n\n".concat(e.chatMessage.intent["inferred-queries"][0]));let s=Y.render(a);s=s.replace(/LEFTPAREN/g,"\\(").replace(/RIGHTPAREN/g,"\\)").replace(/LEFTBRACKET/g,"\\[").replace(/RIGHTBRACKET/g,"\\]"),f(_().sanitize(s))},[e.chatMessage.message,e.chatMessage.intent]),(0,i.useEffect)(()=>{h&&setTimeout(()=>{u(!1)},2e3)},[h]),(0,i.useEffect)(()=>{N.current&&(N.current.querySelectorAll("pre > .hljs").forEach(e=>{let t=document.createElement("button"),a=document.createElement("img");a.src="/static/copy-button.svg",a.alt="Copy",a.width=24,a.height=24,t.appendChild(a),t.className="hljs ".concat(l().codeCopyButton),t.addEventListener("click",()=>{let t=e.textContent||"";t=(t=(t=t.replace(/^\$+/,"")).replace(/^Copy/,"")).trim(),navigator.clipboard.writeText(t),a.src="/static/copy-button-success.svg"}),e.prepend(t)}),(0,V.Z)(N.current,{delimiters:[{left:"$$",right:"$$",display:!0},{left:"\\[",right:"\\]",display:!0},{left:"$",right:"$",display:!1},{left:"\\(",right:"\\)",display:!1}]}))},[p,m,N]),!e.chatMessage.message)return null;async function k(){let t=e.chatMessage.message.match(/[^.!?]+[.!?]*/g)||[];if(!t||0===t.length||!t[0])return;w(!0);let a=C(t[0]);for(let e=0;e<t.length&&!b.current;e++){let s=a;e<t.length-1&&(a=C(t[e+1]));try{let e=await s,t=URL.createObjectURL(e);await function(e){return new Promise((t,a)=>{let s=new Audio(e);s.onended=t,s.onerror=a,s.play()})}(t)}catch(e){console.error("Error:",e);break}}w(!1),y(!1)}async function C(e){let t=await fetch("/api/chat/speech?text=".concat(encodeURIComponent(e)),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("Network response was not ok");return await t.blob()}let M=function(e,t){let a=[],s=[];if(t){let e=[];for(let[a,s]of Object.entries(t)){if(s.answerBox&&e.push({title:s.answerBox.title,description:s.answerBox.answer,link:s.answerBox.source}),s.knowledgeGraph&&e.push({title:s.knowledgeGraph.title,description:s.knowledgeGraph.description,link:s.knowledgeGraph.descriptionLink}),s.webpages){if(s.webpages instanceof Array){let t=s.webpages.map(e=>({title:e.query,description:e.snippet,link:e.link}));e.push(...t)}else{let t=s.webpages;e.push({title:t.query,description:t.snippet,link:t.link})}}if(s.organic){let t=s.organic.map(e=>({title:e.title,description:e.snippet,link:e.link}));e.push(...t)}}a.push(...e)}if(e){let t=e.map(e=>e.compiled?{title:e.file,content:e.compiled}:{title:e.split("\n")[0],content:e.split("\n").slice(1).join("\n")});s.push(...t)}return{notesReferenceCardData:s,onlineReferenceCardData:a}}(e.chatMessage.context,e.chatMessage.onlineContext);return(0,s.jsxs)("div",{className:(t=e.chatMessage,(n=[l().chatMessageContainer,"shadow-md"]).push(l()[t.by]),e.customClassName&&n.push(l()["".concat(t.by).concat(e.customClassName)]),n.join(" ")),onMouseLeave:e=>g(!1),onMouseEnter:e=>g(!0),onClick:"khoj"===e.chatMessage.by?e=>void 0:void 0,children:[(0,s.jsx)("div",{className:(a=e.chatMessage,(r=[l().chatMessageWrapper]).push(l()[a.by]),"khoj"===a.by&&r.push("border-l-4 border-opacity-50 ".concat("border-l-"+e.borderLeftColor)),r.join(" ")),children:(0,s.jsx)("div",{ref:N,className:l().chatMessage,dangerouslySetInnerHTML:{__html:p}})}),(0,s.jsx)("div",{className:l().teaserReferencesContainer,children:(0,s.jsx)(D,{isMobileWidth:e.isMobileWidth,notesReferenceCardData:M.notesReferenceCardData,onlineReferenceCardData:M.onlineReferenceCardData})}),(0,s.jsx)("div",{className:l().chatFooter,children:(m||e.isMobileWidth||e.isLastMessage||x)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{title:(c=(o=new Date(e.chatMessage.created+"Z")).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0}).toUpperCase(),d=o.toLocaleString("en-US",{year:"numeric",month:"short",day:"2-digit"}).replaceAll("-"," "),"".concat(c," on ").concat(d)),className:"text-gray-400 relative top-0 left-4",children:function(e){e.endsWith("Z")||(e+="Z");let t=new Date(e),a=new Date().getTime()-t.getTime();return a<6e4?"Just now":a<36e5?"".concat(Math.round(a/6e4),"m ago"):a<864e5?"".concat(Math.round(a/36e5),"h ago"):"".concat(Math.round(a/864e5),"d ago")}(e.chatMessage.created)}),(0,s.jsxs)("div",{className:"".concat(l().chatButtons," shadow-sm"),children:["khoj"===e.chatMessage.by&&(x?j?(0,s.jsx)(I.l,{iconClassName:"p-0",className:"m-0"}):(0,s.jsx)("button",{title:"Pause Speech",onClick:e=>y(!0),children:(0,s.jsx)(W.d,{alt:"Pause Message",className:"hsl(var(--muted-foreground))"})}):(0,s.jsx)("button",{title:"Speak",onClick:e=>k(),children:(0,s.jsx)(z.j,{alt:"Speak Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})})),(0,s.jsx)("button",{title:"Copy",className:"".concat(l().copyButton),onClick:()=>{navigator.clipboard.writeText(e.chatMessage.message),u(!0)},children:h?(0,s.jsx)(G.C,{alt:"Copied Message",weight:"fill",className:"text-green-500"}):(0,s.jsx)(G.C,{alt:"Copy Message",className:"hsl(var(--muted-foreground)) hover:text-green-500"})}),"khoj"===e.chatMessage.by&&(e.chatMessage.intent?(0,s.jsx)(K,{uquery:e.chatMessage.intent.query,kquery:e.chatMessage.message}):(0,s.jsx)(K,{uquery:e.chatMessage.rawQuery||e.chatMessage.message,kquery:e.chatMessage.message}))]})]})})]})}Y.use(c(),{inline:!0,code:!0})},34531:function(e){e.exports={chatMessageContainer:"chatMessage_chatMessageContainer__sAivf",chatMessageWrapper:"chatMessage_chatMessageWrapper__u5m8A",khojfullHistory:"chatMessage_khojfullHistory__NPu2l",youfullHistory:"chatMessage_youfullHistory__ioyfH",you:"chatMessage_you__6GUC4",khoj:"chatMessage_khoj__cjWON",khojChatMessage:"chatMessage_khojChatMessage__BabQz",author:"chatMessage_author__muRtC",chatFooter:"chatMessage_chatFooter__0vR8s",chatButtons:"chatMessage_chatButtons__Lbk8T",codeCopyButton:"chatMessage_codeCopyButton__Y_Ujv",feedbackButtons:"chatMessage_feedbackButtons___Brdy",copyButton:"chatMessage_copyButton__jd7q7",trainOfThought:"chatMessage_trainOfThought__mR2Gg",primary:"chatMessage_primary__WYPEb",trainOfThoughtElement:"chatMessage_trainOfThoughtElement__le_bC"}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1929],{39929:function(e,t,s){Promise.resolve().then(s.bind(s,38874))},38874:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return x}});var n=s(57437),a=s(65104),o=s.n(a),c=s(2265),r=s(48861),i=s(82697),l=s(16463),d=s(58485),u=s(9557);s(7395);var h=s(69591),g=s(38423),m=s(79306);function f(e){let t=(0,l.useSearchParams)().get("conversationId"),[s,a]=(0,c.useState)(""),[r,d]=(0,c.useState)(!1),[u,h]=(0,c.useState)(null),m=e.setQueryToProcess,f=e.onConversationIdChange;if((0,c.useEffect)(()=>{let e=localStorage.getItem("message");e&&(d(!0),m(e))},[m]),(0,c.useEffect)(()=>{s&&(d(!0),m(s))},[s,m]),(0,c.useEffect)(()=>{t&&(null==f||f(t))},[t,f]),(0,c.useEffect)(()=>{e.streamedMessages&&e.streamedMessages.length>0&&e.streamedMessages[e.streamedMessages.length-1].completed?d(!1):a("")},[e.streamedMessages]),!t){window.location.href="/";return}return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:o().chatBodyFull,children:(0,n.jsx)(i.Z,{conversationId:t,setTitle:e.setTitle,setAgent:h,pendingMessage:r?s:"",incomingMessages:e.streamedMessages})}),(0,n.jsx)("div",{className:"".concat(o().inputBox," p-1 md:px-2 shadow-md bg-background align-middle items-center justify-center dark:bg-neutral-700 dark:border-0 dark:shadow-sm rounded-t-2xl rounded-b-none md:rounded-xl"),children:(0,n.jsx)(g.Z,{agentColor:null==u?void 0:u.color,isLoggedIn:e.isLoggedIn,sendMessage:e=>a(e),sendDisabled:r,chatOptionsData:e.chatOptionsData,conversationId:t,isMobileWidth:e.isMobileWidth,setUploadedFiles:e.setUploadedFiles})})]})}function x(){let e="Khoj AI - Chat",[t,s]=(0,c.useState)(null),[a,i]=(0,c.useState)(!0),[l,g]=(0,c.useState)(e),[x,p]=(0,c.useState)(null),[v,_]=(0,c.useState)([]),[y,j]=(0,c.useState)(""),[b,w]=(0,c.useState)(!1),[M,C]=(0,c.useState)([]),S=(0,h.k6)(),I=(0,m.G)(),N=(0,h.IC)();async function B(e){if(!e.ok)throw Error(e.statusText);if(!e.body)throw Error("Response body is null");let t=e.body.getReader(),s=new TextDecoder,n="␃\uD83D\uDD1A␗",a="",o=[],c={};for(;;){let e;let{done:r,value:i}=await t.read();if(r){j(""),w(!1);break}for(a+=s.decode(i,{stream:!0});-1!==(e=a.indexOf(n));){let t=a.slice(0,e);if(a=a.slice(e+n.length),t){let e=v.find(e=>!e.completed);if(!e){console.error("No current message found");return}({context:o,onlineContext:c}=(0,u.VK)(t,e,o,c)),_([...v])}}}}async function E(){if(localStorage.removeItem("message"),!y||!x)return;let e="/api/chat?q=".concat(encodeURIComponent(y),"&conversation_id=").concat(x,"&stream=true&client=web");S&&(e+="®ion=".concat(S.region,"&country=").concat(S.country,"&city=").concat(S.city,"&timezone=").concat(S.timezone));let t=await fetch(e);try{await B(t)}catch(s){console.error(s);let e=v.find(e=>!e.completed);if(!e)return;let t=s.message;e.rawResponse="Encountered Error: ".concat(t,". Please try again later."),e.completed=!0,_([...v]),j(""),w(!1)}}return((0,c.useEffect)(()=>{fetch("/api/chat/options").then(e=>e.json()).then(e=>{i(!1),e&&s(e)}).catch(e=>{console.error(e)}),(0,h.EK)()},[]),(0,c.useEffect)(()=>{if(y){let e={rawResponse:"",trainOfThought:[],context:[],onlineContext:{},completed:!1,timestamp:new Date().toISOString(),rawQuery:y||""};_(t=>[...t,e]),w(!0)}},[y]),(0,c.useEffect)(()=>{b&&E()},[b]),a)?(0,n.jsx)(d.Z,{}):(0,n.jsxs)("div",{className:"".concat(o().main," ").concat(o().chatLayout),children:[(0,n.jsx)("title",{children:"".concat(e).concat(l&&l!==e?": ".concat(l):"")}),(0,n.jsx)("div",{children:(0,n.jsx)(r.Z,{conversationId:x,uploadedFiles:M,isMobileWidth:N})}),(0,n.jsx)("div",{className:o().chatBox,children:(0,n.jsxs)("div",{className:o().chatBoxBody,children:[!N&&(0,n.jsx)("div",{className:"text-nowrap text-ellipsis overflow-hidden max-w-screen-md grid items-top font-bold mr-8",children:l&&(0,n.jsx)("h2",{className:"text-lg text-ellipsis whitespace-nowrap overflow-x-hidden pt-6",children:l})}),(0,n.jsx)(c.Suspense,{fallback:(0,n.jsx)(d.Z,{}),children:(0,n.jsx)(f,{isLoggedIn:null!==I,streamedMessages:v,chatOptionsData:t,setTitle:g,setQueryToProcess:j,setUploadedFiles:C,isMobileWidth:N,onConversationIdChange:e=>{p(e)}})})]})})]})}},82697:function(e,t,s){"use strict";s.d(t,{Z:function(){return p}});var n=s(57437),a=s(15238),o=s.n(a),c=s(2265),r=s(89178),i=s(94880),l=s(58485),d=s(16288),u=s(26100),h=s(19666),g=s(50495),m=e=>{let{name:t,avatar:s,link:a,description:o}=e;return(0,n.jsx)("div",{className:"relative group flex",children:(0,n.jsx)(h.pn,{children:(0,n.jsxs)(h.u,{children:[(0,n.jsx)(h.aJ,{asChild:!0,children:(0,n.jsxs)(g.z,{variant:"ghost",className:"flex items-center justify-center",children:[s,(0,n.jsx)("div",{children:t})]})}),(0,n.jsx)(h._v,{children:(0,n.jsxs)("div",{className:"w-80 h-30",children:[(0,n.jsx)("a",{href:a,target:"_blank",rel:"noreferrer",className:"mt-1 ml-2 block no-underline",children:(0,n.jsxs)("div",{className:"flex items-center justify-start gap-2",children:[s,(0,n.jsxs)("div",{className:"mr-2 mt-1 flex justify-center items-center text-sm font-semibold text-gray-800",children:[t,(0,n.jsx)(u.o,{weight:"bold",className:"ml-1"})]})]})}),o&&(0,n.jsx)("p",{className:"mt-2 ml-6 text-sm text-gray-600 line-clamp-2",children:o||"A Khoj agent"})]})})]})})})},f=s(89417),x=s(69591);function p(e){let[t,s]=(0,c.useState)(null),[a,u]=(0,c.useState)(0),[h,g]=(0,c.useState)(!0),p=(0,c.useRef)(null),v=(0,c.useRef)(null),_=(0,c.useRef)(null),[y,j]=(0,c.useState)(null),[b,w]=(0,c.useState)(!1),M=(0,x.IC)();(0,c.useEffect)(()=>{a<2&&((null==t?void 0:t.chat.length)||setTimeout(()=>{C()},500))},[t,a]),(0,c.useEffect)(()=>{if(!h||b)return;let n=new IntersectionObserver(n=>{n[0].isIntersecting&&h&&(w(!0),function(n){if(!h||b)return;let a=n+1,o="";if(e.conversationId)o="/api/chat/history?client=web&conversation_id=".concat(e.conversationId,"&n=").concat(10*a);else{if(!e.publicConversationSlug)return;o="/api/chat/share/history?client=web&public_conversation_slug=".concat(e.publicConversationSlug,"&n=").concat(10*a)}fetch(o).then(e=>e.json()).then(a=>{if(e.setTitle(a.response.slug),a&&a.response&&a.response.chat&&a.response.chat.length>0){if(a.response.chat.length===(null==t?void 0:t.chat.length)){g(!1),w(!1);return}e.setAgent(a.response.agent),s(a.response),n<2&&C(),w(!1)}else{if(a.response.agent&&a.response.conversation_id){let t={chat:[],agent:a.response.agent,conversation_id:a.response.conversation_id,slug:a.response.slug};e.setAgent(a.response.agent),s(t)}g(!1),w(!1)}}).catch(e=>{console.error(e),window.location.href="/"})}(a),u(e=>e+1))},{threshold:1});return _.current&&n.observe(_.current),()=>n.disconnect()},[h,a,b]),(0,c.useEffect)(()=>{g(!0),w(!1),u(0),s(null)},[e.conversationId]),(0,c.useEffect)(()=>{if(e.incomingMessages){let t=e.incomingMessages[e.incomingMessages.length-1];t&&!t.completed&&j(e.incomingMessages.length-1)}S()&&C()},[e.incomingMessages]);let C=()=>{v.current&&v.current.scrollIntoView(!1)},S=()=>{if(!v.current)return!1;let{scrollTop:e,scrollHeight:t,clientHeight:s}=v.current;return e+s>=t-25};return e.conversationId||e.publicConversationSlug?(0,n.jsx)(i.x,{className:"h-[80vh]",children:(0,n.jsx)("div",{ref:p,children:(0,n.jsxs)("div",{className:o().chatHistory,ref:v,children:[(0,n.jsx)("div",{ref:_,style:{height:"1px"},children:b&&(0,n.jsx)(l.l,{message:"Loading Conversation",className:"opacity-50"})}),t&&t.chat&&t.chat.map((e,s)=>(0,n.jsx)(r.Z,{isMobileWidth:M,chatMessage:e,customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:s===t.chat.length-1},"".concat(s,"fullHistory"))),e.incomingMessages&&e.incomingMessages.map((e,s)=>(0,n.jsxs)(c.Fragment,{children:[(0,n.jsx)(r.Z,{isMobileWidth:M,chatMessage:{message:e.rawQuery,context:[],onlineContext:{},created:e.timestamp,by:"you",automationId:""},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500")},"".concat(s,"outgoing")),e.trainOfThought&&function(e,t,s,a){let c=arguments.length>4&&void 0!==arguments[4]&&arguments[4],i=e.length-1;return(0,n.jsxs)("div",{className:"".concat(o().trainOfThought," shadow-sm"),children:[!c&&(0,n.jsx)(l.l,{className:"float-right"}),e.map((e,a)=>(0,n.jsx)(r.H,{message:e,primary:a===i&&t&&!c,agentColor:s},"train-".concat(a)))]},a)}(e.trainOfThought,s===y,(null==t?void 0:t.agent.color)||"orange","".concat(s,"trainOfThought"),e.completed),(0,n.jsx)(r.Z,{isMobileWidth:M,chatMessage:{message:e.rawResponse,context:e.context,onlineContext:e.onlineContext,created:e.timestamp,by:"khoj",automationId:"",rawQuery:e.rawQuery},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"".concat(s,"incoming"))]},"incomingMessage".concat(s))),e.pendingMessage&&(0,n.jsx)(r.Z,{isMobileWidth:M,chatMessage:{message:e.pendingMessage,context:[],onlineContext:{},created:new Date().getTime().toString(),by:"you",automationId:""},customClassName:"fullHistory",borderLeftColor:"".concat(null==t?void 0:t.agent.color,"-500"),isLastMessage:!0},"pendingMessage-".concat(e.pendingMessage.length)),t&&(0,n.jsx)("div",{className:"".concat(o().agentIndicator," pb-4"),children:(0,n.jsx)("div",{className:"relative group mx-2 cursor-pointer",children:(0,n.jsx)(m,{name:t&&t.agent&&t.agent.name?t.agent.name:"Agent",link:t&&t.agent&&t.agent.slug?"/agents?agent=".concat(t.agent.slug):"/agents",avatar:(0,f.T)(t.agent.icon,t.agent.color)||(0,n.jsx)(d.v,{}),description:t&&t.agent&&t.agent.persona?t.agent.persona:""})})})]})})}):null}},16463:function(e,t,s){"use strict";var n=s(71169);s.o(n,"useSearchParams")&&s.d(t,{useSearchParams:function(){return n.useSearchParams}})},65104:function(e){e.exports={main:"chat_main__8xQu5",suggestions:"chat_suggestions__m8n2t",inputBox:"chat_inputBox__LOFws",chatBodyFull:"chat_chatBodyFull__FfKEK",chatBody:"chat_chatBody__sS1LX",chatLayout:"chat_chatLayout__pR203",chatBox:"chat_chatBox__FBct_",titleBar:"chat_titleBar__R5QlK",chatBoxBody:"chat_chatBoxBody__qT_SC",agentIndicator:"chat_agentIndicator__8V55w"}},15238:function(e){e.exports={chatHistory:"chatHistory_chatHistory__CoaVT",chatLayout:"chatHistory_chatLayout__ABli_",agentIndicator:"chatHistory_agentIndicator__wOU1f",trainOfThought:"chatHistory_trainOfThought__mMWSR"}}},function(e){e.O(0,[7812,647,929,3954,9001,3062,743,7071,2614,9693,1603,9417,9178,8423,2971,7023,1744],function(){return e(e.s=39929)}),_N_E=e.O()}]);
|