Core AI Features
Intelligent Chat Assistant
The AI assistant provides context-aware help throughout your learning journey:- Workspace Context: AI has access to all your notes, flashcards, PDFs, quizzes, and other content
- Multi-modal Understanding: Processes text, images, PDFs, videos, and audio transcripts
- Tool Calling: Executes specialized tools to perform actions on your behalf
- Web Search: Retrieves current information from the web when needed
Content Processing
AI can analyze and process various content types:- PDF Analysis: Extracts text and analyzes document structure using Azure Document AI (Mistral OCR)
- Image Understanding: Analyzes images and provides detailed descriptions
- Video Processing: Processes YouTube videos natively for content extraction
- Web Scraping: Fetches and analyzes web page content using Google URL Context API or Firecrawl
Learning Tools
- Flashcard Generation: Creates flashcard decks from any content
- Quiz Creation: Generates interactive quizzes with multiple-choice questions
- Note Taking: Assists in creating structured notes with markdown formatting
- Content Summarization: Distills key information from long documents
Architecture
Chat API Endpoint
Endpoint:POST /api/chat
The main chat endpoint handles streaming conversations with the AI assistant.
Request Body:
- Automatic URL detection and processing
- Context injection from selected cards
- Token usage tracking and optimization
- Message pruning to manage context window
- Smooth streaming with word-based chunking
AI Gateway Integration
ThinkEx uses the Vercel AI SDK Gateway for model routing:google/- Google AI models (Gemini)anthropic/- Anthropic models (Claude) experimental
Thinking Capabilities
Gemini models support structured reasoning:Configuration
Required Environment Variables
Scraping Modes
- hybrid (default): Try Google Context → Firecrawl (if key exists) → Direct fetch
- firecrawl-only: Force Firecrawl for all scraping
- google-only: Force Google Context API only
- direct-only: Force direct HTTP fetch only
Performance Optimizations
Context Window Management
Token Usage Tracking
Caching Strategy
PDF content is cached after OCR extraction:- First access triggers Azure Document AI OCR
- Extracted content stored in database
- Subsequent accesses use cached content
- Set
forceReprocess: trueto bypass cache
Analytics Integration
ThinkEx uses PostHog for AI observability:Error Handling
Timeout Protection
Requests are limited to 30 seconds:Graceful Degradation
- PDF OCR failures fall back to Gemini file analysis
- Web scraping failures try multiple methods
- Missing context returns helpful error messages
Next Steps
AI Tools
Explore available AI tools and their schemas
Supported Models
Learn about supported AI models and configuration