# /Users/amogh/Documents/amogh/projects/crew-ai/script_gen/src/script_gen/tools/video_tool.py from crewai.tools import BaseTool from typing import Dict, Any import logging # Import the video generator from script_gen.video_gen_new import SizzleReelVideoGenerator class VideoGenerationTool(BaseTool): """ Custom tool for generating sizzle reel videos """ name: str = "Video Generation Tool" description: str = ( "Generates a sizzle reel video from a prepared script. " "Takes a JSON script and an app name, and produces a video path." ) def __init__(self): super().__init__() def _run( self, script_json: Dict[str, Any], app_name: str = "CleverApp" ) -> str: """ Generate a sizzle reel video from the provided script Args: script_json (Dict): The script for the sizzle reel app_name (str, optional): Name of the app. Defaults to "CleverApp". Returns: str: Path to the generated video Raises: ValueError: If video generation fails """ try: # Log the start of video generation logging.info(f"Starting video generation for {app_name}") self.video_generator = SizzleReelVideoGenerator() # Generate the video video_path = self.video_generator.generate_sizzle_reel( script_json=script_json, app_name=app_name ) # Validate video generation if not video_path: raise ValueError("Video generation failed: No video path returned") # Log successful generation logging.info(f"Video generated successfully: {video_path}") return video_path except Exception as e: # Log any errors during video generation logging.error(f"Error in video generation: {e}") raise ValueError(f"Video generation failed: {str(e)}") # Create a single instance of the tool video_tool = VideoGenerationTool()