Module prompt_engineering
Class PromptEngineering
Facilitates the creation of structured prompts for language models,
enabling dynamic interactions based on given templates and arguments.
Attributes:
Methods:
-
init
(self, model_name='gpt-3.5-turbo')Initializes with a specified language model name.
Args: model_name (str): Name of the language model. Defaults to 'gpt-3.5-turbo'.
-
generate_prompt
(self, template, **kwargs)Generates a formatted prompt from a template and arguments.
Args: template (str): Template string with placeholders. **kwargs: Keyword arguments to fill in the placeholders.
Returns: str: Formatted prompt string.
Example: >>> prompt_engine = PromptEngineering() >>> prompt = prompt_engine.generate_prompt("Translate '{text}' to French.", text="Hello") >>> print(prompt) Translate 'Hello' to French.