The Language Tasks component uses OpenAI’s GPT-4o-mini to analyze video transcriptions and intelligently select the most engaging 2-minute highlight segment.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/SamurAIGPT/AI-Youtube-Shorts-Generator/llms.txt
Use this file to discover all available pages before exploring further.
Functions
GetHighlight
Analyzes a timestamped transcription and selects the most interesting 2-minute segment using AI.Timestamped transcription text in the format:
Start time of the selected highlight segment in seconds
End time of the selected highlight segment in seconds
Returns
(None, None) if the AI fails to generate a valid response or encounters an error.Selection Criteria
The AI selects segments that are:- Interesting: Contains valuable or engaging content
- Useful: Provides actionable information or insights
- Surprising: Includes unexpected or novel information
- Controversial: Presents thought-provoking viewpoints
- Complete: Contains only full sentences forming complete thoughts
- Duration: Approximately 2 minutes long
Features
- Smart Segment Selection: Uses GPT-4o-mini to understand context and content quality
- Complete Sentences: Ensures selected text doesn’t cut sentences mid-way
- Structured Output: Uses function calling for reliable JSON responses
- Validation: Checks for valid time ranges and positive durations
- Error Recovery: Interactive retry option if segment selection fails
- Detailed Logging: Prints selected segment details for verification
Response Structure
The AI returns a structured response using theJSONResponse Pydantic model:
Validation
The function performs extensive validation:- Response Validation
- Time Validation
- Error Recovery
Detailed Logging
The function provides comprehensive logging:Configuration
OpenAI model used for highlight selection (cost-effective)
Controls randomness in AI responses (1.0 = more creative)
Structured output method for reliable JSON responses
Environment Variables
Error Handling
Comprehensive error handling with detailed diagnostics:- Invalid or missing OpenAI API key
- API rate limiting
- Network connectivity issues
- Malformed transcription data
- AI returns invalid time ranges
System Prompt
The AI uses this system prompt for selection:Dependencies
langchain-openai: For ChatOpenAI interfacepydantic: For structured output validationpython-dotenv: For environment variable loading- OpenAI API key with GPT-4o-mini access
