Prompt¶
- class opik.Prompt(name: str, prompt: str, metadata: Dict[str, Any] | None = None)¶
Bases:
object
Prompt class represents a prompt with a name, prompt text/template and commit hash.
- __init__(name: str, prompt: str, metadata: Dict[str, Any] | None = None) None ¶
Initializes a new instance of the class with the given parameters. Creates a new prompt using the opik client and sets the initial state of the instance attributes based on the created prompt.
- Parameters:
name – The name for the prompt.
prompt – The template for the prompt.
- property name: str¶
The name of the prompt.
- property prompt: str¶
The latest template of the prompt.
- property commit: str¶
The commit hash of the prompt.
- property metadata: Dict[str, Any] | None¶
The metadata dictionary associated with the prompt
- format(**kwargs: Any) str ¶
Replaces placeholders in the template with provided keyword arguments.
- Parameters:
**kwargs – Arbitrary keyword arguments where the key represents the placeholder in the template and the value is the value to replace the placeholder with.
- Returns:
A string with all placeholders replaced by their corresponding values from kwargs.