Spaces:
Runtime error
Runtime error
Commit
·
60dab54
1
Parent(s):
c1eb2a5
Update main.py
Browse files
main.py
CHANGED
|
@@ -11,11 +11,11 @@ class UserInterface():
|
|
| 11 |
st.text("An Open Source Chat Application")
|
| 12 |
st.header("Open LLMs")
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
models_name = (
|
| 21 |
"HuggingFaceH4/zephyr-7b-beta",
|
|
@@ -51,19 +51,19 @@ class UserInterface():
|
|
| 51 |
"max_length": self.max_token_length
|
| 52 |
}
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
|
| 57 |
def form_data(self):
|
| 58 |
|
| 59 |
try:
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
| 67 |
if "messages" not in st.session_state:
|
| 68 |
st.session_state.messages = []
|
| 69 |
|
|
|
|
| 11 |
st.text("An Open Source Chat Application")
|
| 12 |
st.header("Open LLMs")
|
| 13 |
|
| 14 |
+
self.API_KEY = st.sidebar.text_input(
|
| 15 |
+
'API Key',
|
| 16 |
+
type='password',
|
| 17 |
+
help="Type in your HuggingFace API key to use this app"
|
| 18 |
+
)
|
| 19 |
|
| 20 |
models_name = (
|
| 21 |
"HuggingFaceH4/zephyr-7b-beta",
|
|
|
|
| 51 |
"max_length": self.max_token_length
|
| 52 |
}
|
| 53 |
|
| 54 |
+
os.environ['HUGGINGFACEHUB_API_TOKEN'] = self.API_KEY
|
| 55 |
|
| 56 |
|
| 57 |
def form_data(self):
|
| 58 |
|
| 59 |
try:
|
| 60 |
+
if not self.API_KEY.startswith('hf_'):
|
| 61 |
+
st.warning('Please enter your API key!', icon='⚠')
|
| 62 |
+
text_input_visibility = True
|
| 63 |
+
else:
|
| 64 |
+
text_input_visibility = False
|
| 65 |
|
| 66 |
+
|
| 67 |
if "messages" not in st.session_state:
|
| 68 |
st.session_state.messages = []
|
| 69 |
|