prompt
ChatCompletion
Prompt
dataclass
A dataclass
representing a Prompt
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
system_prompt |
str
|
the system prompt. |
required |
formatted_prompt |
str
|
the formatted prompt. |
required |
Examples:
>>> from distilabel.tasks.prompt import Prompt
>>> prompt = Prompt(
... system_prompt="You are a helpful assistant.",
... formatted_prompt="What are the first 5 Fibonacci numbers?",
... )
Source code in src/distilabel/tasks/prompt.py
format_as(format)
Formats the prompt as the specified format.
Args:
format (SupportedFormats): the format to be used for the prompt. Available formats are
`default`, `openai`, `llama2`, `chatml`, and `zephyr`.
Returns:
Union[str, List[ChatCompletion]]: the formatted prompt.
Raises:
ValueError: if the specified format is not supported.
Examples:
>>> from distilabel.tasks.prompt import Prompt
>>> prompt = Prompt(
... system_prompt="You are a helpful assistant.",
... formatted_prompt="What are the first 5 Fibonacci numbers?",
... )
>>> prompt.format_as("default")
'You are a helpful assistant.
What are the first 5 Fibonacci numbers?'