Knowledge base and chat extension for DjangoCFG
npm install @djangocfg/ext-knowbaseKnowledge base and RAG-powered chat extension for DjangoCFG.
Part of DjangoCFG — modern Django framework for production-ready SaaS applications.
- 📚 Document Management - Upload, organize, and manage documentation
- 💬 RAG-Powered Chat - AI chat with context from your documents
- 📁 Archive Processing - Bulk upload and process ZIP archives
- 🔍 Smart Search - Find information across all documents
- 📊 Document Analytics - Track usage and engagement
- 🔄 Auto-Processing - Automatic document parsing and indexing
- 💾 Session Management - Persistent chat sessions
``bash`
pnpm add @djangocfg/ext-knowbase
`typescript
import { KnowbaseProvider } from '@djangocfg/ext-knowbase/hooks';
export default function RootLayout({ children }) {
return (
{children}
);
}
`
`typescript
import {
useKnowbaseDocumentsContext,
} from '@djangocfg/ext-knowbase/hooks';
function DocumentsPage() {
const {
documents,
uploadDocument,
deleteDocument,
isLoadingDocuments,
} = useKnowbaseDocumentsContext();
const handleUpload = async (file: File) => {
await uploadDocument({
file,
title: file.name,
description: 'Uploaded document',
});
};
return (
Status: {doc.status}
$3
`typescript
import { useKnowbaseChatContext } from '@djangocfg/ext-knowbase/hooks';function ChatInterface() {
const { sendQuery, chatHistory, isLoading } = useKnowbaseChatContext();
const handleSend = async (message: string) => {
await sendQuery({
query: message,
session_id: sessionId,
});
};
return (
{chatHistory.map((msg, idx) => (
{msg.role}: {msg.content}
))}
onKeyDown={(e) => {
if (e.key === 'Enter') {
handleSend(e.currentTarget.value);
}
}}
disabled={isLoading}
/>
);
}
`$3
`typescript
import { useKnowbaseDocumentsContext } from '@djangocfg/ext-knowbase/hooks';function ArchiveUpload() {
const { uploadArchive, getArchiveById } = useKnowbaseDocumentsContext();
const handleArchiveUpload = async (file: File) => {
const result = await uploadArchive({
file,
auto_process: true,
});
// Check processing status
const archive = await getArchiveById(result.id);
console.log('Processing status:', archive.processing_status);
};
return (
type="file"
accept=".zip"
onChange={(e) => e.target.files && handleArchiveUpload(e.target.files[0])}
/>
);
}
`API Reference
$3
-
documents - List of all documents
- uploadDocument(data) - Upload single document
- deleteDocument(id) - Delete document
- updateDocument(id, data) - Update document metadata
- getDocumentById(id) - Get document details
- uploadArchive(data) - Upload ZIP archive
- processArchive(id) - Trigger archive processing$3
-
sendQuery(data) - Send chat query to RAG system
- chatHistory - Current chat session history
- clearHistory() - Clear chat history
- isLoading - Loading state$3
-
sessions - List of chat sessions
- createSession(data) - Create new session
- deleteSession(id) - Delete session
- getCurrentSession()` - Get active sessionMIT