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 encode returned.

strictbool, default=False

Raise when the reply contains a placeholder the handle never issued.

Returns:
str

The reply with values restored.

Raises:
TypeError

If handle is not a Handle.

PolicyError

If the handle has been cleared.

RestorationError

Under strict, when a placeholder is unknown.

Parameters:
Return type:

str

Notes

User notes. strict is 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. Use Session.decode_report when 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'