def run(
        self,
        collection_id: str,
        job_type: str,
        prompt: str,
        image_to_image: Optional[dict] = None,
        text_to_image: Optional[dict] = None,
        *args,
        **kwargs,
    ) -> AgentResponse:
        """
        Process the prompt to generate the image.

        :param str prompt: prompt for image generation.
        :param args: Additional positional arguments.
        :param kwargs: Additional keyword arguments.
        :return: The response containing information about generated image.
        :rtype: AgentResponse
        """
        try:
            self.videodb_tool = VideoDBTool(collection_id=collection_id)
            self.output_message.actions.append("Processing prompt..")
            image_content = ImageContent(
                agent_name=self.agent_name,
                status=MsgStatus.progress,
                status_message="Generating image...",
            )
            self.output_message.content.append(image_content)
            self.output_message.push_update()

            output_image_url = ""
            if job_type == "text_to_image":
                engine = text_to_image.get("engine", "videodb") if text_to_image else "videodb"
                if engine == "flux":
                    flux_output = flux_dev(prompt)
                    if not flux_output:
                        image_content.status = MsgStatus.error
                        image_content.status_message = "Error in generating image."
                        self.output_message.publish()
                        error_message = "Agent failed with error in replicate."
                        return AgentResponse(
                            status=AgentStatus.ERROR, message=error_message
                        )
                    output_image_url = flux_output[0].url
                    image_content.image = ImageData(url=output_image_url)
                    image_content.status = MsgStatus.success
                    image_content.status_message = "Here is your generated image"
                else:
                    generated_image = self.videodb_tool.generate_image(prompt)
                    image_content.image = ImageData(**generated_image)
                    image_content.status = MsgStatus.success
                    image_content.status_message = "Here is your generated image"
            elif job_type == "image_to_image":
                FAL_KEY = os.getenv("FAL_KEY")
                image_id = image_to_image.get("image_id")

                if not image_id:
                    raise ValueError(
                        "Missing required parameter: 'image_id' for image-to-video generation"
                    )

                image_data = self.videodb_tool.get_image(image_id)
                if not image_data:
                    raise ValueError(
                        f"Image with ID '{image_id}' not found in collection "
                        f"'{collection_id}'. Please verify the image ID."
                    )

                image_url = None
                if isinstance(image_data.get("url"), str) and image_data.get("url"):
                    image_url = image_data["url"]
                else:
                    image_url = self.videodb_tool.generate_image_url(image_id)

                fal_tool = FalVideoGenerationTool(api_key=FAL_KEY)
                config = image_to_image.get("fal_config", {})
                fal_output = fal_tool.image_to_image(
                    image_url=image_url,
                    prompt=prompt,
                    config=config,
                )
                output_image_url = fal_output[0]["url"]
            else:
                raise Exception(f"{job_type} not supported")
            
            self.output_message.publish()
        except Exception as e:
            logger.exception(f"Error in {self.agent_name}")
            image_content.status = MsgStatus.error
            image_content.status_message = "Error in generating image."
            self.output_message.publish()
            error_message = f"Agent failed with error {e}"
            return AgentResponse(status=AgentStatus.ERROR, message=error_message)
        return AgentResponse(
            status=AgentStatus.SUCCESS,
            message=f"Agent {self.name} completed successfully.",
            data={"image_content": image_content},
        )

        Process the prompt to generate the image.

        :param str prompt: prompt for image generation.
        :param args: Additional positional arguments.
        :param kwargs: Additional keyword arguments.
        :return: The response containing information about generated image.
        :rtype: AgentResponse
        
backend/director/agents/image_generation.py