PromptTemplate
This module defines the PromptTemplate class which is used for generating prompts with variable values.
PromptTemplate
A class for generating prompts with variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompt |
str
|
The prompt string with variables. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
prompt |
str
|
The prompt string with variables. |
variables |
List[str]
|
A list of variable names in the prompt string. |
Source code in llmflows/prompts/prompt_template.py
get_prompt(**kwargs)
Returns the prompt string with variables replaced by the provided values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs |
str
|
A dictionary of variable names and their values. |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
The prompt string with variables replaced by the provided values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided variables do not match the defined ones. |