These, are helper utilities to convert a python dictionary object (well, anything that can be json.dumps) into a serialized string without special characters.
They are used to wrap the inputs to the "prompt" (lambdaprompt definition of prompt) that takes in a few inputs and provides completion.
Because the fields in prompt_kwargs are processed to be strings using the to_b64 function, they now are able to be passed as params to the prompt completion endpoint without any messy serialization.
In summary: the point is to serialize and deserialize the information that is used by the prompt into a format that makes it possible to send over requests so that the prompt can be completed by the remote lambdaprompt server (when SKETCH_USE_REMOTE_LAMBDAPROMPT==True)
to_b64
is "to base64",from_b64
is "from base64"These, are helper utilities to convert a python dictionary object (well, anything that can be
json.dumps
) into a serialized string without special characters.They are used to wrap the inputs to the "prompt" (
lambdaprompt
definition of prompt) that takes in a few inputs and provides completion.See these lines for the
prompt_kwargs
creation https://github.com/approximatelabs/sketch/blob/b4d5f257e1d9d0da423562f0d80ac343624b7ede/sketch/pandas_extension.py#L152This is now immediately usable by the
requests
lib, when calling a prompt remotelyBecause the fields in
prompt_kwargs
are processed to be strings using theto_b64
function, they now are able to be passed as params to the prompt completion endpoint without any messy serialization.In summary: the point is to serialize and deserialize the information that is used by the prompt into a format that makes it possible to send over requests so that the prompt can be completed by the remote lambdaprompt server (when
SKETCH_USE_REMOTE_LAMBDAPROMPT==True
)