Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -170,34 +170,30 @@ def refresh_all():
|
|
170 |
roles = load_json_or_empty(ASSISTANT_ROLES_PATH)
|
171 |
sp_names, sp_map = load_system_prompts()
|
172 |
|
173 |
-
#
|
174 |
ut_list = list(user_types.keys())
|
175 |
if not ut_list:
|
176 |
ut_list = ["Default"]
|
177 |
-
# keep state shape consistent so later lookups don't explode
|
178 |
if "Default" not in user_types:
|
179 |
user_types = {"Default": {}}
|
180 |
|
181 |
-
#
|
182 |
role_list = list(roles.keys())
|
183 |
if not role_list:
|
184 |
role_list = ["Default"]
|
185 |
if "Default" not in roles:
|
186 |
roles = {"Default": {}}
|
187 |
|
188 |
-
#
|
189 |
if sp_names:
|
190 |
-
sp_update = gr.
|
191 |
else:
|
192 |
-
sp_update = gr.
|
193 |
-
choices=["(no prompts found)"],
|
194 |
-
value="(no prompts found)"
|
195 |
-
)
|
196 |
|
197 |
return (
|
198 |
sp_update,
|
199 |
-
gr.
|
200 |
-
gr.
|
201 |
sp_map, user_types, roles,
|
202 |
f"Loaded {len(sp_names)} prompt(s), {len(ut_list)} user type(s), {len(role_list)} role(s)."
|
203 |
)
|
|
|
170 |
roles = load_json_or_empty(ASSISTANT_ROLES_PATH)
|
171 |
sp_names, sp_map = load_system_prompts()
|
172 |
|
173 |
+
# User Types
|
174 |
ut_list = list(user_types.keys())
|
175 |
if not ut_list:
|
176 |
ut_list = ["Default"]
|
|
|
177 |
if "Default" not in user_types:
|
178 |
user_types = {"Default": {}}
|
179 |
|
180 |
+
# Roles
|
181 |
role_list = list(roles.keys())
|
182 |
if not role_list:
|
183 |
role_list = ["Default"]
|
184 |
if "Default" not in roles:
|
185 |
roles = {"Default": {}}
|
186 |
|
187 |
+
# System Prompts
|
188 |
if sp_names:
|
189 |
+
sp_update = gr.update(choices=sp_names, value=sp_names[0])
|
190 |
else:
|
191 |
+
sp_update = gr.update(choices=["(no prompts found)"], value="(no prompts found)")
|
|
|
|
|
|
|
192 |
|
193 |
return (
|
194 |
sp_update,
|
195 |
+
gr.update(choices=ut_list, value=ut_list[0]),
|
196 |
+
gr.update(choices=role_list, value=role_list[0]),
|
197 |
sp_map, user_types, roles,
|
198 |
f"Loaded {len(sp_names)} prompt(s), {len(ut_list)} user type(s), {len(role_list)} role(s)."
|
199 |
)
|