function main_v3
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, saving generated meeting minutes to a markdown file, optionally saving a PowerPoint content summary, and printing a preview of the generated content. On error, it prints error messages and stack traces.
Dependencies
argparseosdatetimepathlibopenaigoogle-generativeaipptxtraceback
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 GPT-4o model:
# python script.py
# Run with Gemini model and custom 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 variables first:
# export OPENAI_API_KEY='sk-...'
# export GEMINI_API_KEY='AIza...'
# If calling from Python code:
if __name__ == '__main__':
main()
Best Practices
- Always set the appropriate API key environment variable (OPENAI_API_KEY or GEMINI_API_KEY) before running
- Ensure input files (transcript and PowerPoint) exist and are readable before execution
- Use --no-powerpoint flag if PowerPoint processing is not needed to speed up execution
- The function auto-generates output filenames with timestamps if not specified, preventing accidental overwrites
- Check the preview output and full saved files to verify quality of generated minutes
- The function includes error handling and validation, but ensure EnhancedMeetingMinutesGenerator class is properly implemented
- Default file paths are hardcoded to /tf/active/leexi/ - modify these for your environment
- The function saves both the main minutes and a PowerPoint summary file for reference
- Use appropriate model selection based on your API access and cost considerations
Tags
Similar Components
AI-powered semantic similarity - components with related functionality:
-
function main_v6 90.2% similar
-
function main_v15 76.7% similar
-
class MeetingMinutesGenerator_v1 72.8% similar
-
class MeetingMinutesGenerator 68.4% similar
-
function generate_minutes 64.9% similar