Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.8 KB
Raw Blame
from django.contrib import admin

from .models import KnowledgeChunk, KnowledgeDocument, KnowledgeSource, TeamBusinessKnowledgeConfig


@admin.register(KnowledgeSource)
class KnowledgeSourceAdmin(admin.ModelAdmin):
    list_display = ("id", "name", "team", "source_type", "status", "created_at")
    list_filter = ("source_type", "status", "created_at")
    search_fields = ("id", "name", "team__name")
    # Heavy FK to Team — use raw_id to avoid loading every team on change pages.
    raw_id_fields = ("team", "created_by")
    readonly_fields = ("id", "created_at", "updated_at")
    ordering = ("-created_at",)
    show_full_result_count = False


@admin.register(KnowledgeDocument)
class KnowledgeDocumentAdmin(admin.ModelAdmin):
    list_display = ("id", "source", "title", "team", "created_at")
    list_filter = ("created_at",)
    search_fields = ("id", "title", "stable_id", "source__name")
    raw_id_fields = ("team", "source")
    readonly_fields = ("id", "stable_id", "created_at", "updated_at")
    ordering = ("-created_at",)
    show_full_result_count = False


@admin.register(KnowledgeChunk)
class KnowledgeChunkAdmin(admin.ModelAdmin):
    list_display = ("id", "document", "heading_path", "ordinal", "char_count", "team")
    search_fields = ("id", "document__title", "heading_path")
    raw_id_fields = ("team", "source", "document")
    readonly_fields = ("id", "created_at")
    ordering = ("document_id", "ordinal")
    show_full_result_count = False


@admin.register(TeamBusinessKnowledgeConfig)
class TeamBusinessKnowledgeConfigAdmin(admin.ModelAdmin):
    list_display = ("team", "learn_from_support_enabled")
    list_filter = ("learn_from_support_enabled",)
    search_fields = ("team__name",)
    raw_id_fields = ("team",)
    show_full_result_count = False