function main_v2
Command-line interface function that orchestrates the generation of enhanced meeting minutes from transcript files and PowerPoint presentations using various LLM models (GPT-4o, Azure GPT-4o, or Gemini).
/tf/active/vicechatdev/leexi/enhanced_meeting_minutes_generator.py
1145 - 1246
complex
Purpose
This is the main entry point for a meeting minutes generation application. It handles command-line argument parsing, validates API keys, initializes the appropriate LLM generator, processes input files (transcript and optional PowerPoint), generates enhanced meeting minutes using AI, validates output quality, and saves results to disk. It supports multiple LLM backends and can operate with or without PowerPoint content.
Source Code
def main():
"""Main function to process transcript and PowerPoint to generate enhanced meeting minutes."""
parser = argparse.ArgumentParser(description='Generate enhanced meeting minutes from transcript and PowerPoint using LLM')
parser.add_argument('--model', choices=['gpt-4o', 'azure-gpt-4o', 'gemini'], default='gpt-4o',
help='LLM model to use (default: gpt-4o)')
parser.add_argument('--transcript', type=str,
default='/tf/active/leexi/leexi-20250618-transcript-development_team_meeting.md',
help='Path to transcript file')
parser.add_argument('--powerpoint', type=str,
default='/tf/active/leexi/2025 06 18 Development Team meeting.pptx',
help='Path to PowerPoint file')
parser.add_argument('--output', type=str,
help='Output path for meeting minutes (auto-generated if not specified)')
parser.add_argument('--title', type=str,
default='Development Team Meeting',
help='Meeting title for the minutes')
parser.add_argument('--no-powerpoint', action='store_true',
help='Skip PowerPoint processing and use transcript only')
args = parser.parse_args()
# Auto-generate output path if not specified
if not args.output:
timestamp = datetime.now().strftime('%Y-%m-%d')
model_suffix = args.model.replace('-', '_')
ppt_suffix = "_with_ppt" if not args.no_powerpoint else ""
args.output = f"/tf/active/leexi/enhanced_meeting_minutes_{timestamp}_{model_suffix}{ppt_suffix}.md"
# Check API keys
if args.model == 'gpt-4o':
api_key = os.getenv('OPENAI_API_KEY')
if not api_key:
print("Error: OPENAI_API_KEY environment variable not set")
print("Please set your OpenAI API key:")
print("export OPENAI_API_KEY='your-api-key-here'")
return
elif args.model == 'gemini':
api_key = os.getenv('GEMINI_API_KEY')
if not api_key:
print("Error: GEMINI_API_KEY environment variable not set")
print("Please set your Gemini API key:")
print("export GEMINI_API_KEY='your-api-key-here'")
return
try:
# Initialize enhanced generator
print(f"Initializing {args.model.upper()} enhanced generator...")
generator = EnhancedMeetingMinutesGenerator(model=args.model)
# Load transcript
print(f"Loading transcript from: {args.transcript}")
transcript = generator.load_transcript(args.transcript)
# Process PowerPoint content if not skipped
ppt_content = None
if not args.no_powerpoint:
print(f"Processing PowerPoint presentation: {args.powerpoint}")
ppt_content = generator.process_powerpoint_content(args.powerpoint)
if ppt_content:
print(f"✅ Extracted {len(ppt_content.get('text_chunks', []))} text chunks and {len(ppt_content.get('table_chunks', []))} table chunks from PowerPoint")
else:
print("⚠️ No PowerPoint content extracted")
else:
print("Skipping PowerPoint processing (--no-powerpoint flag used)")
# Generate enhanced meeting minutes
print(f"Generating enhanced meeting minutes using {args.model.upper()}...")
minutes = generator.generate_enhanced_meeting_minutes(
transcript,
ppt_content,
args.title
)
# Validate output quality
minutes = generator._validate_output_quality(minutes, transcript, ppt_content)
# Save results
generator.save_minutes(minutes, args.output)
print("✅ Enhanced meeting minutes generation completed successfully!")
print(f"📄 Output saved to: {args.output}")
# Also save PowerPoint content summary for reference if processed
if ppt_content and not args.no_powerpoint:
ppt_summary_path = args.output.replace('.md', '_powerpoint_summary.md')
with open(ppt_summary_path, 'w', encoding='utf-8') as f:
f.write("# PowerPoint Content Summary\n\n")
f.write(generator.format_powerpoint_content(ppt_content))
print(f"📊 PowerPoint content summary saved to: {ppt_summary_path}")
# Print a preview
print("\n" + "="*50)
print("PREVIEW OF GENERATED MINUTES:")
print("="*50)
print(minutes[:1000] + "..." if len(minutes) > 1000 else minutes)
except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc()
Return Value
Returns None. The function performs side effects including printing status messages to stdout, writing generated meeting minutes to a file, and optionally saving a PowerPoint content summary. Exits early (returns None) if required API keys are not set.
Dependencies
argparseosdatetimeopenaigoogle-generativeaipptxtracebackpathlibtyping
Required Imports
import argparse
import os
from datetime import datetime
import openai
import google.generativeai as genai
import pptx
import traceback
Conditional/Optional Imports
These imports are only needed under specific conditions:
import openai
Condition: only if using gpt-4o or azure-gpt-4o models
Optionalimport google.generativeai as genai
Condition: only if using gemini model
Optionalimport pptx
Condition: only if processing PowerPoint files (not using --no-powerpoint flag)
OptionalUsage Example
# Run from command line with default settings:
# python script.py
# Run with custom model and files:
# python script.py --model gemini --transcript /path/to/transcript.md --powerpoint /path/to/slides.pptx --output /path/to/output.md --title "Q4 Planning Meeting"
# Run without PowerPoint processing:
# python script.py --no-powerpoint --transcript /path/to/transcript.md
# Set required environment variable first:
# export OPENAI_API_KEY='sk-...'
# python script.py --model gpt-4o
# From Python code (not typical usage):
if __name__ == '__main__':
main()
Best Practices
- Always set the appropriate API key environment variable (OPENAI_API_KEY or GEMINI_API_KEY) before running
- Ensure the EnhancedMeetingMinutesGenerator class is properly defined with all required methods (load_transcript, process_powerpoint_content, generate_enhanced_meeting_minutes, _validate_output_quality, save_minutes, format_powerpoint_content)
- Verify input file paths exist and are readable before execution
- Use --no-powerpoint flag if PowerPoint processing is not needed to save processing time
- The function auto-generates output filenames with timestamps if not specified, preventing accidental overwrites
- Check console output for status messages and error details during execution
- The function prints a preview of generated content; redirect stdout if running in automated pipelines
- Handle exceptions appropriately as the function catches all exceptions and prints tracebacks
- Ensure sufficient disk space for output files, especially when processing large PowerPoint presentations
- The function is designed to be called as a script entry point, typically not imported and called from other modules
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function main_v14 90.4% similar
-
function main_v27 76.7% similar
-
class MeetingMinutesGenerator_v1 73.5% similar
-
class MeetingMinutesGenerator 69.2% similar
-
function generate_minutes 65.1% similar