Skip to content

Commit b2e8837

Browse files
amethystaniclaude
andcommitted
feat: Add Knowledge Base document management with RAG pipeline
- Create kb_uploaded_documents table and enhance kb_documents with user/document tracking - Add Supabase Storage bucket (kb-documents) with RLS policies - Create api-documents Edge Function for PDF text extraction - Enhance ragService with smart sentence-aware chunking, document CRUD, and full processing pipeline - Add DocumentsView dashboard component with drag-and-drop upload, chunk viewer, and progress tracking - Add Documents sidebar nav item in AI Behavior section - Add EN/DE translation keys for knowledge base documents - Chatbot automatically pulls document context via existing RAG integration in localLLMService Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7d58327 commit b2e8837

File tree

8 files changed

+1264
-5
lines changed

8 files changed

+1264
-5
lines changed

src/components/AppSidebar.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121
LogOut,
2222
Users,
2323
Wand2,
24-
ShieldCheck
24+
ShieldCheck,
25+
FileText
2526
} from "lucide-react"
2627

2728
import { useTheme } from "@/hooks/useTheme"
@@ -212,6 +213,24 @@ export function AppSidebar({ activeTab, setActiveTab, hasAccess = false, ...prop
212213
</SidebarMenuButton>
213214
</SidebarMenuItem>
214215

216+
{/* Documents */}
217+
<SidebarMenuItem>
218+
<SidebarMenuButton
219+
isActive={activeTab === 'kb_documents'}
220+
onClick={() => handleTabClick('kb_documents')}
221+
tooltip={t('sidebar.kbDocuments')}
222+
className={cn(
223+
"transition-colors",
224+
isDark
225+
? "text-white/80 hover:text-white hover:bg-white/10 data-[active=true]:bg-white/10 data-[active=true]:text-white"
226+
: "text-gray-600 hover:text-gray-900 hover:bg-black/5 data-[active=true]:bg-black/5 data-[active=true]:text-black"
227+
)}
228+
>
229+
<FileText className="text-blue-400" />
230+
<span>{t('sidebar.kbDocuments')}</span>
231+
</SidebarMenuButton>
232+
</SidebarMenuItem>
233+
215234
{/* Model Selection */}
216235
<SidebarMenuItem>
217236
<SidebarMenuButton

src/components/DashboardViews/DocumentsView.tsx

Lines changed: 531 additions & 0 deletions
Large diffs are not rendered by default.

src/i18n/de.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,20 @@ export const de = {
348348
'sidebar.docs': 'Dokumentation',
349349
'sidebar.team': 'Team',
350350
'sidebar.customerGraph': 'Kundengraph',
351+
'sidebar.kbDocuments': 'Dokumente',
352+
353+
// Knowledge Base Documents
354+
'kbDocs.title': 'Wissensdatenbank-Dokumente',
355+
'kbDocs.description': 'Laden Sie Dokumente hoch, um Ihrem KI-Assistenten mehr Kontext und Wissen zu geben.',
356+
'kbDocs.upload': 'Dokument hochladen',
357+
'kbDocs.dropzone': 'Dateien hier ablegen oder klicken zum Hochladen',
358+
'kbDocs.processing': 'Verarbeitung',
359+
'kbDocs.ready': 'Bereit',
360+
'kbDocs.error': 'Fehler',
361+
'kbDocs.chunks': 'Abschnitte',
362+
'kbDocs.deleteConfirm': 'Möchten Sie dieses Dokument wirklich löschen?',
363+
'kbDocs.empty': 'Noch keine Dokumente hochgeladen',
364+
'kbDocs.viewChunks': 'Abschnitte anzeigen',
351365

352366
// Customer Graph
353367
'customerGraph.title': 'Kunden-Ähnlichkeitsgraph',

src/i18n/en.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,20 @@ export const en = {
349349
'sidebar.docs': 'Docs',
350350
'sidebar.team': 'Team',
351351
'sidebar.customerGraph': 'Customer Graph',
352+
'sidebar.kbDocuments': 'Documents',
353+
354+
// Knowledge Base Documents
355+
'kbDocs.title': 'Knowledge Base Documents',
356+
'kbDocs.description': 'Upload documents to give your AI assistant more context and knowledge.',
357+
'kbDocs.upload': 'Upload Document',
358+
'kbDocs.dropzone': 'Drop files here or click to upload',
359+
'kbDocs.processing': 'Processing',
360+
'kbDocs.ready': 'Ready',
361+
'kbDocs.error': 'Error',
362+
'kbDocs.chunks': 'chunks',
363+
'kbDocs.deleteConfirm': 'Are you sure you want to delete this document?',
364+
'kbDocs.empty': 'No documents uploaded yet',
365+
'kbDocs.viewChunks': 'View Chunks',
352366

353367
// Customer Graph
354368
'customerGraph.title': 'Customer Similarity Graph',

src/pages/DemoDashboard.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import TeamView from '../components/DashboardViews/TeamView';
2121
import MonitorView from '../components/DashboardViews/MonitorView';
2222
import IntegrationView from '../components/DashboardViews/IntegrationView';
2323
import CustomerGraphView from '../components/DashboardViews/CustomerGraphView';
24+
import DocumentsView from '../components/DashboardViews/DocumentsView';
2425
import InitialSetupDialog from '../components/DashboardViews/InitialSetupDialog';
2526
import { RescueCenterProvider } from '../contexts/RescueCenterContext';
2627

@@ -85,6 +86,7 @@ function DemoDashboardContent() {
8586
priority_rules: t('sidebar.priorityRules'),
8687
instructions: t('sidebar.instructions'),
8788
groq_settings: t('sidebar.groqAi'),
89+
kb_documents: t('sidebar.kbDocuments'),
8890
usage: t('sidebar.usage'),
8991
billing: t('sidebar.billing'),
9092
keys: t('sidebar.keys'),
@@ -195,6 +197,7 @@ function DemoDashboardContent() {
195197
{activeTab === 'priority_rules' && <KnowledgeBase isDark={isDark} activeSection="rules" />}
196198
{activeTab === 'instructions' && <KnowledgeBase isDark={isDark} activeSection="instructions" />}
197199

200+
{activeTab === 'kb_documents' && <DocumentsView isDark={isDark} />}
198201
{activeTab === 'groq_settings' && <GroqSettingsPage isDark={isDark} />}
199202

200203
{/* New Account Sections */}

0 commit comments

Comments
 (0)