vikit.prompt.prompt_factory

Overview

Classes

PromptFactory

Prompt factory helps getting the right sub class of Prompt depending on

Classes

class vikit.prompt.prompt_factory.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

Overview

Methods

create_prompt_from_audio_file(recorded_audio_prompt_path)

Create a prompt object from a recorded audio file

create_prompt_from_audio_file_async(recorded_audio_prompt_path)

Create a prompt object from a recorded audio file

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

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

create_prompt_from_text(prompt_text, negative_prompt)

Create a recorded prompt object from a text by creating

get_prompt_handler_chain(prompt_build_settings)

Get the handler chain of the Prompt. Can includes handlers to prepare

get_reengineered_prompt_text_from_raw_text(prompt, prompt_build_settings)

Get a reengineered prompt from a raw text , using build settings

Members

async create_prompt_from_audio_file(recorded_audio_prompt_path: str = None)

Create a prompt object from a recorded audio file

Parameters:

recorded_audio_prompt_path (-) -- the path to the recorded audio file

Returns:

self

async create_prompt_from_audio_file_async(recorded_audio_prompt_path: str = None)

Create a prompt object from a recorded audio file

Parameters:

recorded_audio_prompt_path (-) -- the path to the recorded audio file

Returns:

self

async 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)

Create a prompt object from a prompt image path

Parameters:

image (-) -- the path of the image of the prompt

Returns:

self

async 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)

Create a prompt object from a prompt image path

Parameters:
  • text (-) -- the text of the prompt

  • reengineer_text (-) -- should we reegineer text with an LLM

  • negative_text (-) -- negative text prompt for the model (for the moment only applicable for haiper)

  • image (-) -- the image base64, URL or URI of the prompt

  • audio (-) -- the audio base64, URL or URI of the prompt

  • video (-) -- the video base64, URL or URI of the prompt

  • duration (-) -- expected duration of the output, should be supported by the model provider

  • seed (-) -- seed to give to the model provider

  • model_provider (-) -- overide model_provider from the video_build_settings

  • 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

async create_prompt_from_text(prompt_text: str = None, negative_prompt: str = None)

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

Parameters:
  • prompt_text (-) -- the text of the prompt

  • negative_prompt (-) -- the text for negative prompting (for the moment only applicable for haiper)

Returns:

a RecordedPrompt object

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

Parameters:

build_settings (PromptBuildSettings) -- The settings to use for building the prompt

Returns:

The list of handlers to use for building the video

Return type:

list

async get_reengineered_prompt_text_from_raw_text(prompt: str, prompt_build_settings: vikit.prompt.prompt_build_settings.PromptBuildSettings = PromptBuildSettings()) str

Get a reengineered prompt from a raw text , using build settings to guide how we should build the prompt

Parameters:

prompt (str) -- The text prompt

Returns:

The prompt object

Return type:

Prompt