mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +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,
|
ChatModelOptions,
|
||||||
ClientApplication,
|
ClientApplication,
|
||||||
Conversation,
|
Conversation,
|
||||||
|
Entry,
|
||||||
KhojUser,
|
KhojUser,
|
||||||
OfflineChatProcessorConversationConfig,
|
OfflineChatProcessorConversationConfig,
|
||||||
OpenAIProcessorConversationConfig,
|
OpenAIProcessorConversationConfig,
|
||||||
@@ -51,6 +52,23 @@ admin.site.register(TextToImageModelConfig)
|
|||||||
admin.site.register(ClientApplication)
|
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)
|
@admin.register(Conversation)
|
||||||
class ConversationAdmin(admin.ModelAdmin):
|
class ConversationAdmin(admin.ModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from fastapi.requests import Request
|
|||||||
from fastapi.responses import Response
|
from fastapi.responses import Response
|
||||||
from starlette.authentication import requires
|
from starlette.authentication import requires
|
||||||
|
|
||||||
from khoj.configure import configure_server
|
from khoj.configure import configure_server, initialize_content
|
||||||
from khoj.database.adapters import (
|
from khoj.database.adapters import (
|
||||||
ConversationAdapters,
|
ConversationAdapters,
|
||||||
EntryAdapters,
|
EntryAdapters,
|
||||||
@@ -182,7 +182,7 @@ def update(
|
|||||||
logger.warning(error_msg)
|
logger.warning(error_msg)
|
||||||
raise HTTPException(status_code=500, detail=error_msg)
|
raise HTTPException(status_code=500, detail=error_msg)
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
error_msg = f"🚨 Failed to update server via API: {e}"
|
error_msg = f"🚨 Failed to update server via API: {e}"
|
||||||
logger.error(error_msg, exc_info=True)
|
logger.error(error_msg, exc_info=True)
|
||||||
|
|||||||
@@ -189,6 +189,8 @@ def configure_content(
|
|||||||
|
|
||||||
search_type = t.value if t else None
|
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:
|
if files is None:
|
||||||
logger.warning(f"🚨 No files to process for {search_type} search.")
|
logger.warning(f"🚨 No files to process for {search_type} search.")
|
||||||
return None, True
|
return None, True
|
||||||
@@ -283,7 +285,7 @@ def configure_content(
|
|||||||
success = False
|
success = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if files is None:
|
if no_documents:
|
||||||
github_config = GithubConfig.objects.filter(user=user).prefetch_related("githubrepoconfig").first()
|
github_config = GithubConfig.objects.filter(user=user).prefetch_related("githubrepoconfig").first()
|
||||||
if (
|
if (
|
||||||
search_type == state.SearchType.All.value or search_type == state.SearchType.Github.value
|
search_type == state.SearchType.All.value or search_type == state.SearchType.Github.value
|
||||||
@@ -304,7 +306,7 @@ def configure_content(
|
|||||||
success = False
|
success = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if files is None:
|
if no_documents:
|
||||||
# Initialize Notion Search
|
# Initialize Notion Search
|
||||||
notion_config = NotionConfig.objects.filter(user=user).first()
|
notion_config = NotionConfig.objects.filter(user=user).first()
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user