Replies: 1 comment
-
|
good idea. i want it |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Overview
Add a "Knowledge Base" feature to agents that allows attaching domain-specific information (documents, URLs, and text snippets) to help agents answer questions more accurately. This is inspired by ElevenLabs' agent knowledge base implementation and leverages existing infrastructure in the codebase.
Problem Statement
Currently, users must copy-paste large amounts of documentation, guides, or reference material directly into an agent's system prompt. This makes:
Proposed Solution
Add an "Agent Knowledge Base" section to the agent configuration that supports three input methods:
All knowledge base content is automatically loaded and appended to the agent's system prompt at runtime.
UI Reference (ElevenLabs Implementation)
The following screenshots show ElevenLabs' knowledge base implementation, which serves as our design inspiration:
Main Knowledge Base View
Shows the main knowledge base interface with document list, search, and action buttons
Document Library with Multiple Input Methods
Displays all available documents with search functionality and three input methods: Add URL, Add Files, Create Text
File Upload Modal
Drag-and-drop file upload interface showing supported formats and size limits
Create Text Modal
Simple form for creating text snippets directly in the UI
Add URL Modal
URL input form for scraping web page content
User Experience (Based on ElevenLabs Pattern)
Main Knowledge Base View
Upload Files Modal
Add URL Modal
Create Text Modal
Technical Implementation
Architecture
The feature leverages existing infrastructure:
/src/lib/file-storage/)instructionsJSON field (no DB migration)buildUserSystemPrompt()to load knowledgeData Structure
Extend
AgentInstructionsSchema:System Prompt Integration
API Endpoints
New endpoints needed:
POST
/api/agent/knowledge/upload- Upload fileagents/{agentId}/knowledge/POST
/api/agent/knowledge/url- Fetch URL contentPOST
/api/agent/knowledge/text- Create text itemDELETE
/api/agent/knowledge/:id- Delete knowledge itemPATCH
/api/agent/:agentId/knowledge/reorder- Reorder itemsWeb Scraping Strategy
Option 1: Use existing web content tool (if available in codebase)
Option 2: Add simple scraper
Configuration
.md,.txt,.json,.pdf(requires PDF parser)Benefits
Implementation Phases
Phase 1: MVP - File Upload (Week 1)
Goal: Basic file upload and system prompt integration
AgentInstructionsSchemawithknowledgeBasefieldbuildUserSystemPrompt()to load knowledge items.mdand.txtfiles onlyDeliverable: Can upload markdown/text files to agents and they appear in context
Phase 2: Enhanced Upload UX (Week 2)
Goal: Polished file upload experience
.jsonfile supportDeliverable: Professional file upload UX matching ElevenLabs quality
Phase 3: Create Text Feature (Week 3)
Goal: Allow inline text creation
Deliverable: Can create text snippets without uploading files
Phase 4: URL Ingestion (Week 4)
Goal: Scrape and store web page content
Deliverable: Can add documentation from URLs
Phase 5: Advanced Features (Week 5)
Goal: Polish and optimization
Deliverable: Feature-complete knowledge base system
Phase 6: Shared Knowledge Library (Future)
Goal: Reuse knowledge across agents
Deliverable: ElevenLabs-style document library
Files to be Modified
Backend
src/types/agent.ts- Type definitionssrc/lib/ai/prompts.ts- System prompt builder (make async, load knowledge)src/app/api/chat/route.ts- Handle async promptssrc/app/api/chat/openai-realtime/route.ts- Handle async promptssrc/app/api/agent/knowledge/upload/route.ts- New filesrc/app/api/agent/knowledge/url/route.ts- New filesrc/app/api/agent/knowledge/text/route.ts- New filesrc/app/api/agent/knowledge/[id]/route.ts- New file (delete)src/lib/scraper/web-content.ts- New file (URL scraping)Frontend
src/components/agent/edit-agent.tsx- Main UI additionssrc/components/agent/knowledge-base-section.tsx- New filesrc/components/agent/knowledge-base-item.tsx- New filesrc/components/agent/add-knowledge-dropdown.tsx- New filesrc/components/agent/modals/upload-files-modal.tsx- New filesrc/components/agent/modals/add-url-modal.tsx- New filesrc/components/agent/modals/create-text-modal.tsx- New fileDocumentation
docs/features/KNOWLEDGE_BASE.md- New file (user guide)docs/architecture/KNOWLEDGE_BASE_ARCHITECTURE.md- New file (dev docs)Dependencies
Required Libraries
{ "dependencies": { // For web scraping (choose one) "@mozilla/readability": "^0.5.0", // Clean article extraction "turndown": "^7.1.2", // HTML to Markdown "jsdom": "^23.0.0", // DOM parsing // For PDF support (Phase 5) "pdf-parse": "^1.1.1", // PDF text extraction // Already available (likely) "zod": "^3.x", // Validation "@vercel/blob": "^0.x" // Storage } }Estimated Effort
Total MVP (Phases 1-2): ~14-18 hours (~15-20 min with Claude Code CLI)
Total Feature-Complete (Phases 1-5): ~32-41 hours (~30-40 min with Claude Code CLI)
Example Use Cases
1. Customer Support Agent
Knowledge Base:
2. Code Review Agent
Knowledge Base:
3. Content Writing Agent
Knowledge Base:
4. SEO Optimization Agent
Knowledge Base:
Edge Cases & Considerations
1. File Size Management
Problem: Knowledge base too large for context window
Solution:
2. Stale URL Content
Problem: Web page content changes after scraping
Solution:
3. Failed File Downloads
Problem: File deleted from storage or download fails
Solution:
4. Large File Processing
Problem: 100KB text file takes time to load
Solution:
Promise.all)5. Encoding Issues
Problem: Non-UTF-8 files fail to parse
Solution:
6. PDF Parsing Quality
Problem: Complex PDFs don't parse well
Solution:
pdf-parse)Security Considerations
Success Metrics
Future Enhancements (Post-Launch)
Questions for Discussion
Should we support RAG for large knowledge bases? (Phase 6+)
Should knowledge items be editable after creation?
Should we support folders/categories for organization?
Should URL scraping be recursive (follow links)?
Should we support collaborative knowledge bases (team feature)?
Comparison with ElevenLabs
Conclusion
This feature is highly feasible and aligns perfectly with the existing architecture. The ElevenLabs pattern is well-designed and user-friendly, and we can implement a similar experience while leveraging our existing file storage, agent system, and UI components.
Recommended Approach:
The phased approach allows us to ship value quickly while building toward a comprehensive knowledge base system.
Beta Was this translation helpful? Give feedback.
All reactions