Spaces:
Sleeping
Sleeping
Update refApp.py
Browse files
refApp.py
CHANGED
|
@@ -1295,86 +1295,81 @@ elif st.session_state.view_mode == "generator":
|
|
| 1295 |
if not isinstance(variables_for_form, list):
|
| 1296 |
variables_for_form = []
|
| 1297 |
|
| 1298 |
-
|
| 1299 |
-
|
| 1300 |
-
|
| 1301 |
-
|
| 1302 |
-
|
| 1303 |
-
|
| 1304 |
-
|
| 1305 |
-
|
| 1306 |
-
|
| 1307 |
-
|
| 1308 |
-
|
| 1309 |
-
|
| 1310 |
-
|
| 1311 |
-
|
| 1312 |
-
|
| 1313 |
-
|
| 1314 |
-
|
| 1315 |
-
|
| 1316 |
-
|
| 1317 |
idx = 0
|
| 1318 |
-
|
| 1319 |
-
|
| 1320 |
-
|
| 1321 |
-
|
| 1322 |
-
|
| 1323 |
-
|
| 1324 |
-
|
| 1325 |
-
|
| 1326 |
-
|
| 1327 |
-
|
| 1328 |
-
|
| 1329 |
-
|
| 1330 |
-
|
| 1331 |
-
|
| 1332 |
-
|
| 1333 |
-
|
| 1334 |
-
|
| 1335 |
-
|
| 1336 |
-
|
| 1337 |
-
|
| 1338 |
-
|
| 1339 |
-
|
| 1340 |
-
|
| 1341 |
-
|
| 1342 |
-
|
| 1343 |
-
|
| 1344 |
-
|
| 1345 |
-
|
| 1346 |
-
|
| 1347 |
-
|
| 1348 |
-
|
| 1349 |
-
|
| 1350 |
-
|
| 1351 |
-
|
| 1352 |
-
|
| 1353 |
-
|
| 1354 |
-
|
| 1355 |
-
|
| 1356 |
-
|
| 1357 |
-
|
| 1358 |
-
|
| 1359 |
-
|
| 1360 |
-
|
| 1361 |
-
if height_val is not None:
|
| 1362 |
-
try:
|
| 1363 |
-
h = int(height_val)
|
| 1364 |
-
if h >= 68:
|
| 1365 |
-
final_height = h
|
| 1366 |
-
else:
|
| 1367 |
-
final_height = 68
|
| 1368 |
-
except (ValueError, TypeError):
|
| 1369 |
-
final_height = None
|
| 1370 |
else:
|
| 1371 |
-
final_height =
|
| 1372 |
-
|
| 1373 |
-
|
| 1374 |
-
|
| 1375 |
-
|
| 1376 |
-
|
| 1377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1378 |
|
| 1379 |
if st.form_submit_button("🚀 Générer Prompt"):
|
| 1380 |
processed_values_for_template = {}
|
|
@@ -1429,25 +1424,20 @@ elif st.session_state.view_mode == "generator":
|
|
| 1429 |
key=f"editable_generated_prompt_output_{generator_family}_{generator_use_case}",
|
| 1430 |
label_visibility="collapsed"
|
| 1431 |
)
|
| 1432 |
-
|
| 1433 |
-
st.session_state.active_generated_prompt = edited_prompt_value
|
| 1434 |
|
| 1435 |
-
|
| 1436 |
-
with col_caption:
|
| 1437 |
-
st.caption("Prompt généré (pour relecture et copie manuelle) :")
|
| 1438 |
-
with col_indicator:
|
| 1439 |
-
st.markdown("<div style='color:red; text-align:right; font-size:0.9em; padding-right:0.9em;'>Copier ici : 👇</div>", unsafe_allow_html=True)
|
| 1440 |
|
| 1441 |
if st.session_state.active_generated_prompt:
|
| 1442 |
-
st.code(st.session_state.active_generated_prompt, language='markdown', line_numbers=
|
| 1443 |
else:
|
| 1444 |
st.markdown("*Aucun prompt généré à afficher.*")
|
| 1445 |
|
| 1446 |
-
# ⚙️ Paramétrage du Prompt - Configuration Feature (Generator Mode)
|
| 1447 |
-
should_expand_config = SHOW_CONFIG_SECTION and st.session_state.get('go_to_config_section', False)
|
| 1448 |
-
if SHOW_CONFIG_SECTION:
|
| 1449 |
-
|
| 1450 |
-
|
| 1451 |
safe_family_key_part = str(generator_family).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1452 |
safe_uc_key_part = str(generator_use_case).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1453 |
template_text_area_key = f"template_text_area_{safe_family_key_part}_{safe_uc_key_part}"; new_tpl = st.text_area("Template:", value=current_prompt_config.get('template', ''), height=200, key=template_text_area_key)
|
|
@@ -1909,11 +1899,7 @@ elif st.session_state.view_mode == "assistant_creation": # Cette vue gère maint
|
|
| 1909 |
|
| 1910 |
# Affichage commun du méta-prompt généré (qu'il vienne de la création ou de l'amélioration)
|
| 1911 |
if st.session_state.generated_meta_prompt_for_llm:
|
| 1912 |
-
|
| 1913 |
-
with col_subheader_assist:
|
| 1914 |
-
st.subheader("📋 Instruction Générée (à coller dans votre LLM) :")
|
| 1915 |
-
with col_indicator_assist:
|
| 1916 |
-
st.markdown("<div style='color:red; text-align:right; font-size:0.9em; padding-top:1.9em;padding-right:0.9em;'>Copier ici : 👇</div>", unsafe_allow_html=True)
|
| 1917 |
|
| 1918 |
st.code(st.session_state.generated_meta_prompt_for_llm, language='markdown', line_numbers=True)
|
| 1919 |
st.caption("<span style='color:gray; font-size:0.9em;'>Utilisez l'icône en haut à droite du bloc de code pour copier l'instruction.</span>", unsafe_allow_html=True)
|
|
|
|
| 1295 |
if not isinstance(variables_for_form, list):
|
| 1296 |
variables_for_form = []
|
| 1297 |
|
| 1298 |
+
# Simplified layout to prevent glitch - removed dynamic columns
|
| 1299 |
+
for var_info in variables_for_form:
|
| 1300 |
+
widget_key = f"gen_input_{generator_family}_{generator_use_case}_{var_info['name']}"
|
| 1301 |
+
field_default = var_info.get("default")
|
| 1302 |
+
var_type = var_info.get("type")
|
| 1303 |
+
|
| 1304 |
+
if var_type == "text_input":
|
| 1305 |
+
gen_form_values[var_info["name"]] = st.text_input(
|
| 1306 |
+
var_info["label"],
|
| 1307 |
+
value=str(field_default or ""),
|
| 1308 |
+
key=widget_key
|
| 1309 |
+
)
|
| 1310 |
+
elif var_type == "selectbox":
|
| 1311 |
+
opts = var_info.get("options", [])
|
| 1312 |
+
idx = 0
|
| 1313 |
+
if opts:
|
| 1314 |
+
try:
|
| 1315 |
+
idx = opts.index(field_default) if field_default in opts else 0
|
| 1316 |
+
except ValueError:
|
| 1317 |
idx = 0
|
| 1318 |
+
gen_form_values[var_info["name"]] = st.selectbox(
|
| 1319 |
+
var_info["label"],
|
| 1320 |
+
options=opts,
|
| 1321 |
+
index=idx,
|
| 1322 |
+
key=widget_key
|
| 1323 |
+
)
|
| 1324 |
+
elif var_type == "date_input":
|
| 1325 |
+
val_date = field_default if isinstance(field_default, date) else datetime.now().date()
|
| 1326 |
+
gen_form_values[var_info["name"]] = st.date_input(
|
| 1327 |
+
var_info["label"],
|
| 1328 |
+
value=val_date,
|
| 1329 |
+
key=widget_key
|
| 1330 |
+
)
|
| 1331 |
+
elif var_type == "number_input":
|
| 1332 |
+
current_value_default_gen = var_info.get("default")
|
| 1333 |
+
min_val_config_gen = var_info.get("min_value")
|
| 1334 |
+
max_val_config_gen = var_info.get("max_value")
|
| 1335 |
+
step_config_gen = var_info.get("step")
|
| 1336 |
+
val_num_gen = float(current_value_default_gen) if isinstance(current_value_default_gen, (int, float)) else 0.0
|
| 1337 |
+
min_val_gen = float(min_val_config_gen) if min_val_config_gen is not None else None
|
| 1338 |
+
max_val_gen = float(max_val_config_gen) if max_val_config_gen is not None else None
|
| 1339 |
+
step_val_gen = float(step_config_gen) if step_config_gen is not None else 1.0
|
| 1340 |
+
if min_val_gen is not None and val_num_gen < min_val_gen:
|
| 1341 |
+
val_num_gen = min_val_gen
|
| 1342 |
+
if max_val_gen is not None and val_num_gen > max_val_gen:
|
| 1343 |
+
val_num_gen = max_val_gen
|
| 1344 |
+
gen_form_values[var_info["name"]] = st.number_input(
|
| 1345 |
+
var_info["label"],
|
| 1346 |
+
value=val_num_gen,
|
| 1347 |
+
min_value=min_val_gen,
|
| 1348 |
+
max_value=max_val_gen,
|
| 1349 |
+
step=step_val_gen,
|
| 1350 |
+
key=widget_key,
|
| 1351 |
+
format="%.2f"
|
| 1352 |
+
)
|
| 1353 |
+
elif var_type == "text_area":
|
| 1354 |
+
height_val = var_info.get("height")
|
| 1355 |
+
final_height = None
|
| 1356 |
+
if height_val is not None:
|
| 1357 |
+
try:
|
| 1358 |
+
h = int(height_val)
|
| 1359 |
+
if h >= 68:
|
| 1360 |
+
final_height = h
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1361 |
else:
|
| 1362 |
+
final_height = 68
|
| 1363 |
+
except (ValueError, TypeError):
|
| 1364 |
+
final_height = None
|
| 1365 |
+
else:
|
| 1366 |
+
final_height = None
|
| 1367 |
+
gen_form_values[var_info["name"]] = st.text_area(
|
| 1368 |
+
var_info["label"],
|
| 1369 |
+
value=str(field_default or ""),
|
| 1370 |
+
height=final_height,
|
| 1371 |
+
key=widget_key
|
| 1372 |
+
)
|
| 1373 |
|
| 1374 |
if st.form_submit_button("🚀 Générer Prompt"):
|
| 1375 |
processed_values_for_template = {}
|
|
|
|
| 1424 |
key=f"editable_generated_prompt_output_{generator_family}_{generator_use_case}",
|
| 1425 |
label_visibility="collapsed"
|
| 1426 |
)
|
| 1427 |
+
# Removed session state update to prevent auto-restart loop
|
|
|
|
| 1428 |
|
| 1429 |
+
st.caption("Prompt généré (pour relecture et copie manuelle) - Utilisez l'icône de copie en haut à droite du bloc :")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1430 |
|
| 1431 |
if st.session_state.active_generated_prompt:
|
| 1432 |
+
st.code(st.session_state.active_generated_prompt, language='markdown', line_numbers=False)
|
| 1433 |
else:
|
| 1434 |
st.markdown("*Aucun prompt généré à afficher.*")
|
| 1435 |
|
| 1436 |
+
# ⚙️ Paramétrage du Prompt - Configuration Feature (Generator Mode) - COMMENTED OUT TO TEST GLITCH
|
| 1437 |
+
# should_expand_config = SHOW_CONFIG_SECTION and st.session_state.get('go_to_config_section', False)
|
| 1438 |
+
# if SHOW_CONFIG_SECTION:
|
| 1439 |
+
# with st.expander(f"⚙️ Paramétrage du Prompt: {generator_use_case}", expanded=should_expand_config):
|
| 1440 |
+
# st.subheader("Template du Prompt")
|
| 1441 |
safe_family_key_part = str(generator_family).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1442 |
safe_uc_key_part = str(generator_use_case).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1443 |
template_text_area_key = f"template_text_area_{safe_family_key_part}_{safe_uc_key_part}"; new_tpl = st.text_area("Template:", value=current_prompt_config.get('template', ''), height=200, key=template_text_area_key)
|
|
|
|
| 1899 |
|
| 1900 |
# Affichage commun du méta-prompt généré (qu'il vienne de la création ou de l'amélioration)
|
| 1901 |
if st.session_state.generated_meta_prompt_for_llm:
|
| 1902 |
+
st.subheader("📋 Instruction Générée (à coller dans votre LLM) :")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1903 |
|
| 1904 |
st.code(st.session_state.generated_meta_prompt_for_llm, language='markdown', line_numbers=True)
|
| 1905 |
st.caption("<span style='color:gray; font-size:0.9em;'>Utilisez l'icône en haut à droite du bloc de code pour copier l'instruction.</span>", unsafe_allow_html=True)
|