decode#
- scikitplot.cleanprompt.decode(reply, handle, *, strict=False)[source]#
Put the original values back into a model’s reply.
- Parameters:
- replystr
Text containing placeholders.
- handleHandle
The handle
encodereturned.- strictbool, default=False
Raise when the reply contains a placeholder the handle never issued.
- Returns:
- str
The reply with values restored.
- Raises:
- TypeError
If
handleis not aHandle.- PolicyError
If the handle has been cleared.
- RestorationError
Under
strict, when a placeholder is unknown.
- Parameters:
- Return type:
Notes
User notes.
strictis off by default because a model can invent a placeholder that was never issued, and failing the whole reply over one hallucinated token is rarely what you want. UseSession.decode_reportwhen you need to know.Examples
>>> safe, handle = encode("Call +1 555 010 4477") >>> decode("Ring [PHONE-1] tomorrow", handle) 'Ring +1 555 010 4477 tomorrow'
Gallery examples#
Cleanprompt Basics: Hide a Value, Then Get It Back
Cleanprompt Basics: Hide a Value, Then Get It Back
Cleanprompt from Python: Single Calls and Edge Cases
Cleanprompt from Python: Single Calls and Edge Cases