vikit.prompt.prompt_factory =========================== .. py:module:: vikit.prompt.prompt_factory Overview -------- .. list-table:: Classes :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`PromptFactory ` - Prompt factory helps getting the right sub class of Prompt depending on Classes ------- .. py:class:: PromptFactory(ml_models_gateway: vikit.gateways.ML_models_gateway.MLModelsGateway = None, prompt_build_settings: vikit.prompt.prompt_build_settings.PromptBuildSettings = PromptBuildSettings()) Prompt factory helps getting the right sub class of Prompt depending on the input provided. We use the right builder class to make it clear of the operations required to build each type of prompt and optimize it This is also useful to simplify unit testing of prompts as we will inject custom made Prompt objects instead of letting builders run some complex stuff involving external services .. rubric:: Overview .. list-table:: Methods :header-rows: 0 :widths: auto :class: summarytable * - :py:obj:`create_prompt_from_audio_file `\ (recorded_audio_prompt_path) - Create a prompt object from a recorded audio file * - :py:obj:`create_prompt_from_audio_file_async `\ (recorded_audio_prompt_path) - Create a prompt object from a recorded audio file * - :py:obj:`create_prompt_from_image `\ (image, text, reengineer_text, model_provider, reengineer_text_prompt_from_image_and_text, duration) - Create a prompt object from a prompt image path * - :py:obj:`create_prompt_from_multimodal_async `\ (text, reengineer_text, negative_text, image, audio, video, duration, seed, model_provider, reengineer_text_prompt_from_image_and_text) - Create a prompt object from a prompt image path * - :py:obj:`create_prompt_from_text `\ (prompt_text, negative_prompt) - Create a recorded prompt object from a text by creating * - :py:obj:`get_prompt_handler_chain `\ (prompt_build_settings) - Get the handler chain of the Prompt. Can includes handlers to prepare * - :py:obj:`get_reengineered_prompt_text_from_raw_text `\ (prompt, prompt_build_settings) - Get a reengineered prompt from a raw text , using build settings .. rubric:: Members .. py:method:: create_prompt_from_audio_file(recorded_audio_prompt_path: str = None) :async: Create a prompt object from a recorded audio file :param - recorded_audio_prompt_path: the path to the recorded audio file :returns: self .. py:method:: create_prompt_from_audio_file_async(recorded_audio_prompt_path: str = None) :async: Create a prompt object from a recorded audio file :param - recorded_audio_prompt_path: the path to the recorded audio file :returns: self .. py:method:: create_prompt_from_image(image: str = None, text: str = None, reengineer_text: bool = False, model_provider: str = None, reengineer_text_prompt_from_image_and_text=False, duration: float = None) :async: Create a prompt object from a prompt image path :param - image: the path of the image of the prompt :returns: self .. py:method:: create_prompt_from_multimodal_async(text: str = None, reengineer_text: bool = False, negative_text: str = None, image: str = None, audio: str = None, video: str = None, duration: float = None, seed: int = None, model_provider: str = None, reengineer_text_prompt_from_image_and_text=False) :async: Create a prompt object from a prompt image path :param - text: the text of the prompt :param - reengineer_text: should we reegineer text with an LLM :param - negative_text: negative text prompt for the model (for the moment only applicable for haiper) :param - image: the image base64, URL or URI of the prompt :param - audio: the audio base64, URL or URI of the prompt :param - video: the video base64, URL or URI of the prompt :param - duration: expected duration of the output, should be supported by the model provider :param - seed: seed to give to the model provider :param - model_provider: overide model_provider from the video_build_settings :param - reengineer_text_prompt_from_image_and_text: will use the provided text and image to prompt a vLLM to generate a text that will be sent with the image to the model provider. Useful if text is about something in the image. :returns: self .. py:method:: create_prompt_from_text(prompt_text: str = None, negative_prompt: str = None) :async: Create a recorded prompt object from a text by creating a recorded audio file using a ML Model, then extracting the subtitles, i.e. all the sentences text and timings :param - prompt_text: the text of the prompt :param - negative_prompt: the text for negative prompting (for the moment only applicable for haiper) :returns: a RecordedPrompt object .. py:method:: get_prompt_handler_chain(prompt_build_settings: vikit.prompt.prompt_build_settings.PromptBuildSettings) -> list[vikit.common.handler.Handler] Get the handler chain of the Prompt. Can includes handlers to prepare the prompt text by adding more verbosity, or to filter offensive words, limit the prompt length, etc :param build_settings: The settings to use for building the prompt :type build_settings: PromptBuildSettings :returns: The list of handlers to use for building the video :rtype: list .. py:method:: get_reengineered_prompt_text_from_raw_text(prompt: str, prompt_build_settings: vikit.prompt.prompt_build_settings.PromptBuildSettings = PromptBuildSettings()) -> str :async: Get a reengineered prompt from a raw text , using build settings to guide how we should build the prompt :param prompt: The text prompt :type prompt: str :returns: The prompt object :rtype: Prompt