replicate / all-mpnet-base-v2

A cog model for the all-mpnet-base-v2 sentence-transformers embedding model.
https://replicate.com/replicate/all-mpnet-base-v2
Apache License 2.0
10 stars 7 forks source link

Use getpass to get Replicate API key in notebook #2

Closed zeke closed 1 year ago

zeke commented 1 year ago

You can do something like this to keep users from pasting their API key into a notebook and possibly accidentally exposing it:

# get a token: https://replicate.com/account
from getpass import getpass
import os

REPLICATE_API_TOKEN = getpass()
os.environ["REPLICATE_API_TOKEN"] = REPLICATE_API_TOKEN

cc @joehoover

Found this technique via @cbh123's Replicate notebook

joehoover commented 1 year ago

@zeke , the input() function I call opens a modal with a text input, so users would have to intentionally alter the code and add their API key.

Do you think that sufficiently mitigates your concern?

zeke commented 1 year ago

Sorry I misread your code. That's even more elegant!