Open
Description
Today, I was wondering how to not accidentally commit my open AI key when passing it to a widget.
Even when I import it from another python file that is git-ignored, it would still show up as plain text in the text/plain
notebook metadata.
Therefore, here's a solution I came up with, hope that this will be useful for other people as well! :)
class MyPrivateButton(ipywidgets.Button):
def _repr_mimebundle_(self, *args, **kwargs):
mimebundle = super()._repr_mimebundle_(*args, **kwargs)
mimebundle["text/plain"]= "Button Widget, all private info got removed!"
return mimebundle
MyPrivateButton(description="My Secret Key")