Overview
The AI Highlight Selection feature uses OpenAI’s GPT-4o-mini model to automatically analyze full video transcripts and identify the most engaging 2-minute segments. This eliminates the need for manual video review and ensures highlights are selected based on content quality rather than arbitrary timestamps.How It Works
TheGetHighlight function in Components/LanguageTasks.py:52 orchestrates the entire selection process:
Transcript Analysis
The complete timestamped transcription is sent to GPT-4o-mini along with selection criteria.
LLM Evaluation
The model analyzes the content and selects a 2-minute segment that is interesting, useful, surprising, controversial, or thought-provoking.
Structured Output
Returns a JSON object with
start, content, and end fields using function calling for reliable parsing.Function Signature
Components/LanguageTasks.py
Selection Criteria
The system prompt defines what makes a good highlight:Components/LanguageTasks.py:27-43
Complete Sentences: The AI is specifically instructed to avoid cutting sentences mid-way, ensuring the selected clip has proper narrative flow.
LLM Configuration
The model is configured with specific parameters for reliable highlight selection:Components/LanguageTasks.py:56-60
The OpenAI model used for analysis. GPT-4o-mini provides a good balance of cost and quality.
Controls creativity in selection. Higher values (1.0) allow more diverse segment choices.
OpenAI API key from
.env file (OPENAI_API variable).Structured Output Schema
The response follows a strict Pydantic schema for reliable parsing:Components/LanguageTasks.py:12-25
Components/LanguageTasks.py:69
Response Validation
The function performs comprehensive validation to ensure usable output:Validation Checks
Validation Checks
Components/LanguageTasks.py:74-100
Regeneration Workflow
If the AI selects identical start and end times (invalid segment), users are prompted to regenerate:Components/LanguageTasks.py:109-113
Error Handling
Comprehensive exception handling ensures graceful failures:Components/LanguageTasks.py:116-127
Customizing Selection Criteria
To modify what the AI considers “interesting”:Edit the System Prompt
Modify the
system variable in Components/LanguageTasks.py:27 to change selection criteria.Adjust Temperature
Change
temperature in the ChatOpenAI initialization (line 58). Lower values (0.5) make selections more conservative, higher values (1.5) more creative.Output Format
After selection, detailed information is logged:Components/LanguageTasks.py:102-107
Performance
- Latency: ~2-5 seconds per video (depends on transcript length)
- Cost: ~$0.001 per analysis with GPT-4o-mini
- Accuracy: Selects complete sentences with proper narrative flow
- Reliability: Structured output with function calling ensures 99%+ valid responses
