prompt_factory¶
Overview¶
Prompt factory helps getting the right sub class of Prompt depending on |
Classes¶
- class prompt_factory.PromptFactory(ml_gateway: vikit.gateways.ML_models_gateway.MLModelsGateway = None, prompt_build_settings: vikit.prompt.prompt_build_settings.PromptBuildSettings = None)¶
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_path, text)Create a prompt object from a prompt image path
create_prompt_from_text(prompt_text)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
- create_prompt_from_image(image_path: str = None, text: str = None)¶
Create a prompt object from a prompt image path
- Parameters:
prompt_image (-) -- the image of the prompt
- Returns:
self
- async create_prompt_from_text(prompt_text: 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
- 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:
- async get_reengineered_prompt_text_from_raw_text(prompt: str, prompt_build_settings: vikit.prompt.prompt_build_settings.PromptBuildSettings) str¶
Get a reengineered prompt from a raw text , using build settings to guide how we should build the prompt