Spaces:
Runtime error
Runtime error
Added ability to request the hf token be writable, in combination with new environment secret
Browse files- src/common.py +5 -2
src/common.py
CHANGED
@@ -33,11 +33,14 @@ def pop_n(items: List, n: int) -> List:
|
|
33 |
return popped[::-1]
|
34 |
|
35 |
|
36 |
-
def hf_api_token() -> str:
|
37 |
"""
|
38 |
Utility single access point to look up the hugging face access token.
|
39 |
"""
|
40 |
-
|
|
|
|
|
|
|
41 |
if token is None:
|
42 |
raise ValueError('No HF access token found in streamlit secrets')
|
43 |
return token
|
|
|
33 |
return popped[::-1]
|
34 |
|
35 |
|
36 |
+
def hf_api_token(write: bool = False) -> str:
|
37 |
"""
|
38 |
Utility single access point to look up the hugging face access token.
|
39 |
"""
|
40 |
+
if write:
|
41 |
+
token = st.secrets['hf_write_token']
|
42 |
+
else:
|
43 |
+
token = st.secrets['hf_token']
|
44 |
if token is None:
|
45 |
raise ValueError('No HF access token found in streamlit secrets')
|
46 |
return token
|