Refiner
This module defines the main PromptRefiner
class and associated functions
for modifying and enhancing prompts using various strategies.
PromptRefiner(strategies)
Bases: object
A class for refining prompt using multiple strategies.
This class applies a series of transformations to enhance a given input prompt. It supports multiple strategies, such as "few_shot" and "meta".
Attributes:
Name | Type | Description |
---|---|---|
strategies |
list[str | BaseStrategy]
|
A list of strategies to be applied to the prompt. |
Initialize the PromptRefiner
with list of strategies.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
strategies
|
list
|
A list of supported strategies. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If provided strategy is not supported. |
Source code in promptrefiner/refiner.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
refine(prompt)
Applies all strategies in sequence and returns refined prompt.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
str
|
The input prompt. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The refined prompt after applying strategies. |
Source code in promptrefiner/refiner.py
62 63 64 65 66 67 68 69 70 71 72 73 74 |
|