Spaces:
Running
Running
Clear API key input when a different LLM is selected
Browse files
app.py
CHANGED
@@ -105,6 +105,14 @@ def handle_error(error_msg: str, should_log: bool):
|
|
105 |
st.error(error_msg)
|
106 |
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
APP_TEXT = _load_strings()
|
109 |
|
110 |
# Session variables
|
@@ -133,6 +141,7 @@ with st.sidebar:
|
|
133 |
options=[f'{k} ({v["description"]})' for k, v in GlobalConfig.VALID_MODELS.items()],
|
134 |
index=GlobalConfig.DEFAULT_MODEL_INDEX,
|
135 |
help=GlobalConfig.LLM_PROVIDER_HELP,
|
|
|
136 |
).split(' ')[0]
|
137 |
|
138 |
# The API key/access token
|
@@ -143,6 +152,7 @@ with st.sidebar:
|
|
143 |
' *Optional* for HF Mistral LLMs but still encouraged.\n\n'
|
144 |
),
|
145 |
type='password',
|
|
|
146 |
)
|
147 |
|
148 |
|
|
|
105 |
st.error(error_msg)
|
106 |
|
107 |
|
108 |
+
def reset_api_key():
|
109 |
+
"""
|
110 |
+
Clear API key input when a different LLM is selected from the dropdown list.
|
111 |
+
"""
|
112 |
+
|
113 |
+
st.session_state.api_key_input = ''
|
114 |
+
|
115 |
+
|
116 |
APP_TEXT = _load_strings()
|
117 |
|
118 |
# Session variables
|
|
|
141 |
options=[f'{k} ({v["description"]})' for k, v in GlobalConfig.VALID_MODELS.items()],
|
142 |
index=GlobalConfig.DEFAULT_MODEL_INDEX,
|
143 |
help=GlobalConfig.LLM_PROVIDER_HELP,
|
144 |
+
on_change=reset_api_key
|
145 |
).split(' ')[0]
|
146 |
|
147 |
# The API key/access token
|
|
|
152 |
' *Optional* for HF Mistral LLMs but still encouraged.\n\n'
|
153 |
),
|
154 |
type='password',
|
155 |
+
key='api_key_input'
|
156 |
)
|
157 |
|
158 |
|