mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Fix Notion indexing and add an admin view for Entry objects
This commit is contained in:
@@ -9,6 +9,7 @@ from khoj.database.models import (
|
||||
ChatModelOptions,
|
||||
ClientApplication,
|
||||
Conversation,
|
||||
Entry,
|
||||
KhojUser,
|
||||
OfflineChatProcessorConversationConfig,
|
||||
OpenAIProcessorConversationConfig,
|
||||
@@ -51,6 +52,23 @@ admin.site.register(TextToImageModelConfig)
|
||||
admin.site.register(ClientApplication)
|
||||
|
||||
|
||||
@admin.register(Entry)
|
||||
class EntryAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"id",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"user",
|
||||
"file_source",
|
||||
"file_type",
|
||||
"file_name",
|
||||
"file_path",
|
||||
)
|
||||
search_fields = ("id", "user__email", "user__username", "file_path")
|
||||
list_filter = ("file_type",)
|
||||
ordering = ("-created_at",)
|
||||
|
||||
|
||||
@admin.register(Conversation)
|
||||
class ConversationAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
|
||||
@@ -13,7 +13,7 @@ from fastapi.requests import Request
|
||||
from fastapi.responses import Response
|
||||
from starlette.authentication import requires
|
||||
|
||||
from khoj.configure import configure_server
|
||||
from khoj.configure import configure_server, initialize_content
|
||||
from khoj.database.adapters import (
|
||||
ConversationAdapters,
|
||||
EntryAdapters,
|
||||
@@ -182,7 +182,7 @@ def update(
|
||||
logger.warning(error_msg)
|
||||
raise HTTPException(status_code=500, detail=error_msg)
|
||||
try:
|
||||
configure_server(state.config, regenerate=force, search_type=t, user=user)
|
||||
initialize_content(regenerate=force, search_type=t, init=False, user=user)
|
||||
except Exception as e:
|
||||
error_msg = f"🚨 Failed to update server via API: {e}"
|
||||
logger.error(error_msg, exc_info=True)
|
||||
|
||||
@@ -189,6 +189,8 @@ def configure_content(
|
||||
|
||||
search_type = t.value if t else None
|
||||
|
||||
no_documents = all([not files.get(file_type) for file_type in files])
|
||||
|
||||
if files is None:
|
||||
logger.warning(f"🚨 No files to process for {search_type} search.")
|
||||
return None, True
|
||||
@@ -283,7 +285,7 @@ def configure_content(
|
||||
success = False
|
||||
|
||||
try:
|
||||
if files is None:
|
||||
if no_documents:
|
||||
github_config = GithubConfig.objects.filter(user=user).prefetch_related("githubrepoconfig").first()
|
||||
if (
|
||||
search_type == state.SearchType.All.value or search_type == state.SearchType.Github.value
|
||||
@@ -304,7 +306,7 @@ def configure_content(
|
||||
success = False
|
||||
|
||||
try:
|
||||
if files is None:
|
||||
if no_documents:
|
||||
# Initialize Notion Search
|
||||
notion_config = NotionConfig.objects.filter(user=user).first()
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user