# Upload a document
!add
# (Attach PDF, TXT, or MD file to the message)
# Basic search (shows search results with reaction buttons)
!ask What is the main topic of the documents?
# Search with specific LLM providers
!ask openai How does authentication work?
!ask gemini What are the security best practices?
!ask anthropic Summarize the deployment process
!ask gpt Explain the error handling strategy
!ask google What are the performance optimizations?
# Document management
!list # List your documents
!delete doc-uuid-123 # Delete a document
!status # Check system health
!help # Show help# Basic search
/ask query: What is the API rate limiting strategy?
# Search with LLM provider
/ask query: How does caching work? provider: openai
/ask query: Explain the vector embeddings provider: claude- Basic Search: Use
!ask <question>to get search results - AI Enhancement: React with π€ (OpenAI), π§ (Gemini), or π¬ (Claude)
- Direct AI: Use
!ask openai <question>for immediate AI response
# Example: Processing a technical documentation PDF
# Input: 50-page API documentation PDF
# Output:
# - 45 semantic chunks (avg 1000 tokens each)
# - 384-dimensional embeddings per chunk
# - Metadata: filename, page numbers, sections
# - Stored in Qdrant with user-specific filtering
# Query example:
# !ask openai "How do I authenticate API requests?"
#
# Result:
# - Retrieves top 5 relevant chunks about authentication
# - Generates context-aware prompt with source citations
# - Returns comprehensive answer with source references# Example: Processing code documentation
# Input: README.md, CONTRIBUTING.md, API_GUIDE.md
# Output:
# - Intelligent chunking by headers and paragraphs
# - Preserved formatting and code blocks
# - Cross-referenced sections
# - Searchable by functionality, setup steps, examples
# Query example:
# !ask anthropic "What are the environment variables needed?"
#
# Result: Lists all env vars with descriptions and examplesUSE_OPENAI=true
OPENAI_API_KEY=sk-your-key
OPENAI_MODEL=gpt-3.5-turbo
# Smaller chunks for faster processing
CHUNK_SIZE=800
RETRIEVAL_K=3
CACHE_TTL=7200 # 2 hours cache
# Lower costs: ~$0.002 per queryUSE_ANTHROPIC=true
ANTHROPIC_API_KEY=sk-ant-your-key
ANTHROPIC_MODEL=claude-3-sonnet-20240229
# Larger chunks for better context
CHUNK_SIZE=1500
RETRIEVAL_K=5
CACHE_TTL=3600 # 1 hour cache
# Higher quality: ~$0.015 per queryUSE_OPENAI=true
USE_GEMINI=true
USE_ANTHROPIC=true
# Different models for different use cases:
# OpenAI: Quick answers, summarization
# Gemini: Complex reasoning, math
# Claude: Detailed analysis, creative tasksDocument Upload (10MB PDF):
βββ Text extraction: 2-5 seconds
βββ Chunking: 1-2 seconds
βββ Embedding generation: 5-15 seconds
βββ Qdrant storage: 1-3 seconds
βββ Total: 9-25 seconds
Query Processing:
βββ Vector search: 100-300ms
βββ LLM call (OpenAI): 1-3 seconds
βββ LLM call (Claude): 2-5 seconds
βββ LLM call (Gemini): 1-4 seconds
βββ Response formatting: 50-100ms
Cache Hit: 50-150ms total
Storage Capacity:
βββ 1,000 documents: ~500MB vectors, 2GB text
βββ 10,000 documents: ~5GB vectors, 20GB text
βββ Query time: O(log n) - scales logarithmically
Cost Analysis (monthly):
βββ Infrastructure: $15-50 (Zerops)
βββ LLM API: $10-100 (usage-based)
βββ Storage: $5-20 (documents + vectors)
βββ Total: $30-170/month
# Process multiple documents efficiently:
# 1. Upload multiple files in sequence
!add # Upload doc1.pdf
!add # Upload doc2.pdf
!add # Upload doc3.pdf
# 2. Wait for processing (check status)
!status
# 3. Query across all documents
!ask openai "Compare the approaches mentioned in these documents"# Build conversational context using caching:
# 1. Ask initial question
!ask anthropic "What is the system architecture?"
# 2. Follow-up questions leverage cache
!ask anthropic "How does the authentication in this architecture work?"
!ask anthropic "What are potential security issues with this approach?"
# Cache ensures consistent context across questions# Always check sources in AI responses:
# Query: "What is the recommended database setup?"
# Response includes:
# - AI-generated answer
# - Source documents with scores
# - Relevant text excerpts
# - Confidence indicators
# Verify by asking for specific sources:
!ask "Show me the exact quote about database configuration"- Use descriptive filenames:
api-authentication-guide.pdf - Structure content clearly: Use headers, bullet points
- Keep documents focused: One topic per document
- Update regularly: Delete outdated documents
- Be specific: "How to configure Redis caching?" vs "Redis?"
- Use context: "In the deployment guide, what are the requirements?"
- Ask follow-ups: Build on previous questions for context
- Choose the right LLM:
- OpenAI: Quick factual answers
- Claude: Detailed analysis
- Gemini: Complex reasoning
- Use caching: Identical queries are cached
- Optimize chunks: Balance context vs cost
- Monitor usage: Check logs for expensive queries
- Choose models wisely: GPT-3.5 vs GPT-4 vs Claude
# Problem: !ask "project setup" returns no results
# Solutions:
1. Check if documents are processed: !status
2. Try broader terms: !ask "installation configuration"
3. List documents: !list
4. Upload relevant docs: !add (with setup guide)# Problem: AI gives generic responses
# Solutions:
1. Upload more specific documents
2. Ask more detailed questions
3. Try different LLM providers
4. Check if documents contain the information# Problem: Slow responses
# Check:
1. System status: !status
2. Document count: !list
3. Query complexity
4. Network connectivity
# Optimize:
1. Reduce CHUNK_SIZE for faster embedding
2. Lower RETRIEVAL_K for fewer chunks
3. Use cache-friendly queries-- Query performance by LLM provider
SELECT
llm_provider,
AVG(processing_time) as avg_time,
COUNT(*) as query_count,
AVG(token_count) as avg_tokens
FROM llm_interactions
WHERE timestamp > NOW() - INTERVAL '24 HOURS'
GROUP BY llm_provider;
-- Most common queries
SELECT
LEFT(query, 50) as query_preview,
COUNT(*) as frequency,
AVG(processing_time) as avg_time
FROM llm_interactions
GROUP BY LEFT(query, 50)
ORDER BY frequency DESC
LIMIT 10;
-- User activity patterns
SELECT
DATE(timestamp) as date,
COUNT(*) as queries,
COUNT(DISTINCT user_id) as active_users
FROM llm_interactions
GROUP BY DATE(timestamp)
ORDER BY date DESC;This comprehensive setup gives you a production-ready, cost-effective, and highly capable Discord RAG bot that leverages the best of modern LLM technology while maintaining security and performance! π