Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -995,7 +995,7 @@ elif st.session_state.view_mode == "select_family_for_library":
|
|
| 995 |
for family_name, use_cases in st.session_state.editable_prompts.items():
|
| 996 |
family_filtered_use_cases = {}
|
| 997 |
for uc_name, uc_config in use_cases.items():
|
| 998 |
-
|
| 999 |
match_search = True
|
| 1000 |
if search_term_lib:
|
| 1001 |
match_search = (search_term_lib in uc_name.lower() or
|
|
@@ -1452,7 +1452,7 @@ elif st.session_state.view_mode == "generator":
|
|
| 1452 |
safe_family_key_part = str(generator_family).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1453 |
safe_uc_key_part = str(generator_use_case).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1454 |
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)
|
| 1455 |
-
|
| 1456 |
new_desc = st.text_area("Description (aide pour l'utilisateur):", value=current_prompt_config.get('description', ''), height=100, key=f"desc_text_area_{safe_family_key_part}_{safe_uc_key_part}")
|
| 1457 |
st.markdown("##### Variables disponibles à insérer :"); variables_config = current_prompt_config.get('variables', [])
|
| 1458 |
if not variables_config: st.caption("Aucune variable définie pour ce prompt. Ajoutez-en ci-dessous.")
|
|
@@ -1469,234 +1469,234 @@ elif st.session_state.view_mode == "generator":
|
|
| 1469 |
save_editable_prompts_to_local_and_hf()
|
| 1470 |
st.success("Template et Description sauvegardés!");
|
| 1471 |
st.rerun()
|
| 1472 |
-
st.markdown("---"); st.subheader("Variables du Prompt"); current_variables_list = current_prompt_config.get('variables', [])
|
| 1473 |
-
if not current_variables_list: st.info("Aucune variable définie.")
|
| 1474 |
-
else: pass
|
| 1475 |
-
for idx, var_data in enumerate(list(current_variables_list)):
|
| 1476 |
-
var_id_for_key = var_data.get('name', f"varidx{idx}").replace(" ", "_"); action_key_prefix = f"var_action_{generator_family.replace(' ','_')}_{generator_use_case.replace(' ','_')}_{var_id_for_key}"
|
| 1477 |
-
col_info, col_up, col_down, col_edit, col_delete = st.columns([3, 0.5, 0.5, 0.8, 0.8])
|
| 1478 |
-
with col_info: st.markdown(f"**{idx + 1}. {var_data.get('name', 'N/A')}** ({var_data.get('label', 'N/A')})\n*Type: `{var_data.get('type', 'N/A')}`*")
|
| 1479 |
-
with col_up:
|
| 1480 |
-
disable_up_button = (idx == 0)
|
| 1481 |
-
if st.button("↑", key=f"{action_key_prefix}_up", help="Monter cette variable", disabled=disable_up_button, use_container_width=True): current_variables_list[idx], current_variables_list[idx-1] = current_variables_list[idx-1], current_variables_list[idx]; current_prompt_config["variables"] = current_variables_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf(); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.rerun()
|
| 1482 |
-
with col_down:
|
| 1483 |
-
disable_down_button = (idx == len(current_variables_list) - 1)
|
| 1484 |
-
if st.button("↓", key=f"{action_key_prefix}_down", help="Descendre cette variable", disabled=disable_down_button, use_container_width=True): current_variables_list[idx], current_variables_list[idx+1] = current_variables_list[idx+1], current_variables_list[idx]; current_prompt_config["variables"] = current_variables_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf(); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.rerun()
|
| 1485 |
-
with col_edit:
|
| 1486 |
-
if st.button("Modifier", key=f"{action_key_prefix}_edit", use_container_width=True): st.session_state.editing_variable_info = { "family": generator_family, "use_case": generator_use_case, "index": idx, "data": copy.deepcopy(var_data) }; st.session_state.variable_type_to_create = var_data.get('type'); st.rerun()
|
| 1487 |
-
with col_delete:
|
| 1488 |
-
if st.button("Suppr.", key=f"{action_key_prefix}_delete", type="secondary", use_container_width=True): variable_name_to_delete = current_variables_list.pop(idx).get('name', 'Variable inconnue'); current_prompt_config["variables"] = current_variables_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf(); st.success(f"Variable '{variable_name_to_delete}' supprimée."); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.rerun()
|
| 1489 |
-
st.markdown("---"); st.subheader("Ajouter une Variable"); is_editing_var = False; variable_data_for_form = {"name": "", "label": "", "type": "", "options": "", "default": ""}
|
| 1490 |
-
if st.session_state.editing_variable_info and st.session_state.editing_variable_info.get("family") == generator_family and st.session_state.editing_variable_info.get("use_case") == generator_use_case:
|
| 1491 |
-
edit_var_idx = st.session_state.editing_variable_info["index"]
|
| 1492 |
-
if edit_var_idx < len(current_prompt_config.get('variables',[])):
|
| 1493 |
-
is_editing_var = True; current_editing_data_snapshot = current_prompt_config['variables'][edit_var_idx]; variable_data_for_form.update(copy.deepcopy(current_editing_data_snapshot))
|
| 1494 |
-
if isinstance(variable_data_for_form.get("options"), list): variable_data_for_form["options"] = ", ".join(map(str, variable_data_for_form["options"]))
|
| 1495 |
-
raw_def_edit_form = variable_data_for_form.get("default")
|
| 1496 |
-
if isinstance(raw_def_edit_form, date): variable_data_for_form["default"] = raw_def_edit_form.strftime("%Y-%m-%d")
|
| 1497 |
-
elif raw_def_edit_form is not None: variable_data_for_form["default"] = str(raw_def_edit_form)
|
| 1498 |
-
else: variable_data_for_form["default"] = ""
|
| 1499 |
-
else: st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.warning("La variable que vous tentiez de modifier n'existe plus. Annulation de l'édition."); st.rerun() # pragma: no cover
|
| 1500 |
-
if not is_editing_var and st.session_state.variable_type_to_create is None:
|
| 1501 |
-
st.markdown("##### 1. Choisissez le type de variable à créer :"); variable_types_map = { "Zone de texte (courte)": "text_input", "Liste choix": "selectbox", "Date": "date_input", "Nombre": "number_input", "Zone de texte (longue)": "text_area" }; num_type_buttons = len(variable_types_map); cols_type_buttons = st.columns(min(num_type_buttons, 5)); button_idx = 0
|
| 1502 |
-
for btn_label, type_val in variable_types_map.items():
|
| 1503 |
-
if cols_type_buttons[button_idx % len(cols_type_buttons)].button(btn_label, key=f"btn_type_{type_val}_{generator_use_case.replace(' ','_')}", use_container_width=True): st.session_state.variable_type_to_create = type_val; st.rerun()
|
| 1504 |
-
button_idx += 1
|
| 1505 |
-
st.markdown("---")
|
| 1506 |
-
if st.session_state.variable_type_to_create:
|
| 1507 |
-
current_type_for_form = st.session_state.variable_type_to_create
|
| 1508 |
-
variable_types_map_display = {
|
| 1509 |
-
"text_input": "Zone de texte (courte)", "selectbox": "Liste choix",
|
| 1510 |
-
"date_input": "Date", "number_input": "Nombre", "text_area": "Zone de texte (longue)"
|
| 1511 |
-
}
|
| 1512 |
-
readable_type = variable_types_map_display.get(current_type_for_form, "Type Inconnu")
|
| 1513 |
-
form_title = f"Modifier Variable : {variable_data_for_form.get('name','N/A')} ({readable_type})" if is_editing_var else f"Nouvelle Variable : {readable_type}"
|
| 1514 |
-
st.markdown(f"##### 2. Configurez la variable")
|
| 1515 |
-
|
| 1516 |
-
form_key_suffix = f"_edit_{st.session_state.editing_variable_info['index']}" if is_editing_var and st.session_state.editing_variable_info else "_create"
|
| 1517 |
-
form_var_specific_key = f"form_var_{current_type_for_form}_{generator_use_case.replace(' ','_')}{form_key_suffix}"
|
| 1518 |
-
|
| 1519 |
-
with st.form(key=form_var_specific_key, clear_on_submit=(not is_editing_var)):
|
| 1520 |
-
st.subheader(form_title)
|
| 1521 |
-
var_name_input_form = st.text_input(
|
| 1522 |
-
"Nom technique (ex : nom_client. Sans espaces, accents ou caractères spéciaux)",
|
| 1523 |
-
value=variable_data_for_form.get("name", ""),
|
| 1524 |
-
key=f"{form_var_specific_key}_name",
|
| 1525 |
-
disabled=is_editing_var
|
| 1526 |
-
)
|
| 1527 |
-
var_label_input_form = st.text_input(
|
| 1528 |
-
"Label pour l'utilisateur (description affichée)",
|
| 1529 |
-
value=variable_data_for_form.get("label", ""),
|
| 1530 |
-
key=f"{form_var_specific_key}_label"
|
| 1531 |
-
)
|
| 1532 |
-
var_options_str_input_form = ""
|
| 1533 |
-
if current_type_for_form == "selectbox":
|
| 1534 |
-
var_options_str_input_form = st.text_input(
|
| 1535 |
-
"Options (séparées par une virgule)",
|
| 1536 |
-
value=variable_data_for_form.get("options", ""),
|
| 1537 |
-
key=f"{form_var_specific_key}_options"
|
| 1538 |
-
)
|
| 1539 |
-
date_hint = " (Format AAAA-MM-JJ)" if current_type_for_form == "date_input" else ""
|
| 1540 |
-
var_default_val_str_input_form = st.text_input(
|
| 1541 |
-
f"Valeur par défaut{date_hint}",
|
| 1542 |
-
value=str(variable_data_for_form.get("default", "")),
|
| 1543 |
-
key=f"{form_var_specific_key}_default"
|
| 1544 |
-
)
|
| 1545 |
-
|
| 1546 |
-
min_val_input_form, max_val_input_form, step_val_input_form, height_val_input_form = None, None, None, None
|
| 1547 |
-
if current_type_for_form == "number_input":
|
| 1548 |
-
num_cols_var_form = st.columns(3)
|
| 1549 |
-
min_val_edit_default = variable_data_for_form.get("min_value")
|
| 1550 |
-
max_val_edit_default = variable_data_for_form.get("max_value")
|
| 1551 |
-
step_val_edit_default = variable_data_for_form.get("step", 1.0)
|
| 1552 |
-
min_val_input_form = num_cols_var_form[0].number_input("Valeur minimale (optionnel)", value=float(min_val_edit_default) if min_val_edit_default is not None else None, format="%g", key=f"{form_var_specific_key}_min")
|
| 1553 |
-
max_val_input_form = num_cols_var_form[1].number_input("Valeur maximale (optionnel)", value=float(max_val_edit_default) if max_val_edit_default is not None else None, format="%g", key=f"{form_var_specific_key}_max")
|
| 1554 |
-
step_val_input_form = num_cols_var_form[2].number_input("Pas (incrément)", value=float(step_val_edit_default), format="%g", min_value=1e-9, key=f"{form_var_specific_key}_step")
|
| 1555 |
-
if current_type_for_form == "text_area":
|
| 1556 |
-
height_val_input_form = st.number_input("Hauteur de la zone de texte (pixels)", value=int(variable_data_for_form.get("height", 100)), min_value=68, step=25, key=f"{form_var_specific_key}_height")
|
| 1557 |
-
|
| 1558 |
-
submit_button_label_form = "Sauvegarder Modifications" if is_editing_var else "Ajouter Variable"
|
| 1559 |
-
submitted_specific_var_form = st.form_submit_button(submit_button_label_form)
|
| 1560 |
-
|
| 1561 |
-
if submitted_specific_var_form:
|
| 1562 |
-
var_name_val_submit = var_name_input_form.strip()
|
| 1563 |
-
if not var_name_val_submit or not var_label_input_form.strip(): st.error("Le nom technique et le label de la variable sont requis.")
|
| 1564 |
-
elif not var_name_val_submit.isidentifier(): st.error("Nom technique invalide. Utilisez lettres, chiffres, underscores. Ne pas commencer par un chiffre. Ne pas utiliser de mot-clé Python.")
|
| 1565 |
-
elif current_type_for_form == "selectbox" and not [opt.strip() for opt in var_options_str_input_form.split(',') if opt.strip()]: st.error("Pour une variable de type 'Liste choix', au moins une option est requise.")
|
| 1566 |
-
else:
|
| 1567 |
-
new_var_data_to_submit = { "name": var_name_val_submit, "label": var_label_input_form.strip(), "type": current_type_for_form }; parsed_def_val_submit = parse_default_value(var_default_val_str_input_form.strip(), current_type_for_form)
|
| 1568 |
-
if current_type_for_form == "selectbox":
|
| 1569 |
-
options_list_submit = [opt.strip() for opt in var_options_str_input_form.split(',') if opt.strip()]; new_var_data_to_submit["options"] = options_list_submit
|
| 1570 |
-
if options_list_submit:
|
| 1571 |
-
if parsed_def_val_submit not in options_list_submit: st.warning(f"La valeur par défaut '{parsed_def_val_submit}' n'est pas dans la liste d'options. La première option '{options_list_submit[0]}' sera utilisée comme défaut."); new_var_data_to_submit["default"] = options_list_submit[0]
|
| 1572 |
-
else: new_var_data_to_submit["default"] = parsed_def_val_submit
|
| 1573 |
-
else: new_var_data_to_submit["default"] = ""
|
| 1574 |
-
else: new_var_data_to_submit["default"] = parsed_def_val_submit
|
| 1575 |
-
if current_type_for_form == "number_input":
|
| 1576 |
-
if min_val_input_form is not None: new_var_data_to_submit["min_value"] = float(min_val_input_form)
|
| 1577 |
-
if max_val_input_form is not None: new_var_data_to_submit["max_value"] = float(max_val_input_form)
|
| 1578 |
-
if step_val_input_form is not None: new_var_data_to_submit["step"] = float(step_val_input_form)
|
| 1579 |
-
else: new_var_data_to_submit["step"] = 1.0
|
| 1580 |
-
if current_type_for_form == "text_area" and height_val_input_form is not None:
|
| 1581 |
-
new_var_data_to_submit["height"] = int(height_val_input_form)
|
| 1582 |
-
|
| 1583 |
-
can_proceed_with_save = True; target_vars_list = current_prompt_config.get('variables', [])
|
| 1584 |
-
if is_editing_var:
|
| 1585 |
-
idx_to_edit_submit_form = st.session_state.editing_variable_info["index"]; target_vars_list[idx_to_edit_submit_form] = new_var_data_to_submit; st.success(f"Variable '{var_name_val_submit}' mise à jour avec succès."); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None
|
| 1586 |
-
else:
|
| 1587 |
-
existing_var_names_in_uc = [v['name'] for v in target_vars_list]
|
| 1588 |
-
if var_name_val_submit in existing_var_names_in_uc: st.error(f"Une variable avec le nom technique '{var_name_val_submit}' existe déjà pour ce cas d'usage."); can_proceed_with_save = False
|
| 1589 |
-
else: target_vars_list.append(new_var_data_to_submit); st.success(f"Variable '{var_name_val_submit}' ajoutée avec succès.")
|
| 1590 |
-
if can_proceed_with_save:
|
| 1591 |
-
current_prompt_config["variables"] = target_vars_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf()
|
| 1592 |
-
if not is_editing_var: st.session_state.variable_type_to_create = None
|
| 1593 |
-
st.rerun()
|
| 1594 |
-
|
| 1595 |
-
cancel_button_label_form = "Annuler Modification" if is_editing_var else "Changer de Type / Annuler Création"
|
| 1596 |
-
cancel_btn_key = f"cancel_var_action_btn_{form_var_specific_key}_outside"
|
| 1597 |
-
|
| 1598 |
-
if st.button(cancel_button_label_form, key=cancel_btn_key, help="Réinitialise le formulaire de variable."):
|
| 1599 |
-
st.session_state.variable_type_to_create = None
|
| 1600 |
-
if is_editing_var:
|
| 1601 |
-
st.session_state.editing_variable_info = None
|
| 1602 |
-
st.rerun()
|
| 1603 |
# --- TEMPORARILY COMMENTED OUT FOR GLITCH TESTING ---
|
| 1604 |
-
# st.markdown("---"); st.subheader("
|
| 1605 |
-
#
|
| 1606 |
-
#
|
| 1607 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1608 |
# --- TEMPORARILY COMMENTED OUT FOR GLITCH TESTING ---
|
| 1609 |
-
# st.markdown("---")
|
| 1610 |
-
# st.
|
| 1611 |
-
|
| 1612 |
-
#
|
| 1613 |
-
#
|
| 1614 |
-
#
|
| 1615 |
-
|
| 1616 |
-
#
|
| 1617 |
-
#
|
| 1618 |
-
#
|
| 1619 |
-
|
| 1620 |
-
#
|
| 1621 |
-
#
|
| 1622 |
-
#
|
| 1623 |
-
#
|
| 1624 |
-
#
|
| 1625 |
-
#
|
| 1626 |
-
#
|
| 1627 |
-
|
| 1628 |
-
#
|
| 1629 |
-
#
|
| 1630 |
-
#
|
| 1631 |
-
#
|
| 1632 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1633 |
# )
|
| 1634 |
-
|
| 1635 |
-
#
|
| 1636 |
-
#
|
| 1637 |
-
#
|
| 1638 |
-
#
|
| 1639 |
-
#
|
| 1640 |
-
#
|
| 1641 |
-
|
| 1642 |
-
#
|
| 1643 |
-
#
|
| 1644 |
-
#
|
| 1645 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1646 |
# )
|
| 1647 |
|
| 1648 |
-
#
|
| 1649 |
-
|
| 1650 |
-
#
|
| 1651 |
-
#
|
| 1652 |
-
#
|
| 1653 |
-
|
| 1654 |
-
# if not
|
| 1655 |
-
#
|
| 1656 |
-
#
|
| 1657 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1658 |
# else:
|
| 1659 |
-
#
|
| 1660 |
-
#
|
| 1661 |
-
#
|
| 1662 |
-
#
|
| 1663 |
-
#
|
| 1664 |
-
#
|
| 1665 |
-
#
|
| 1666 |
-
|
| 1667 |
-
#
|
| 1668 |
-
#
|
| 1669 |
-
#
|
| 1670 |
-
#
|
| 1671 |
-
#
|
| 1672 |
-
#
|
| 1673 |
-
#
|
| 1674 |
-
|
| 1675 |
-
|
| 1676 |
-
#
|
| 1677 |
-
#
|
| 1678 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1679 |
# st.rerun()
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
|
| 1683 |
-
|
| 1684 |
-
|
| 1685 |
-
|
| 1686 |
-
|
| 1687 |
-
|
| 1688 |
-
|
| 1689 |
-
|
| 1690 |
-
|
| 1691 |
-
|
| 1692 |
-
|
| 1693 |
-
|
| 1694 |
-
|
| 1695 |
-
|
| 1696 |
-
|
| 1697 |
-
|
| 1698 |
-
|
| 1699 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1700 |
|
| 1701 |
if st.session_state.get('go_to_config_section'):
|
| 1702 |
st.session_state.go_to_config_section = False
|
|
@@ -1837,7 +1837,7 @@ elif st.session_state.view_mode == "assistant_creation": # Cette vue gère maint
|
|
| 1837 |
temp_form_values = {}
|
| 1838 |
for var_info in ASSISTANT_FORM_VARIABLES:
|
| 1839 |
field_key = f"assistant_form_{var_info['name']}"
|
| 1840 |
-
|
| 1841 |
value_for_widget = st.session_state.assistant_form_values.get(var_info['name'], var_info['default'])
|
| 1842 |
|
| 1843 |
if var_info["type"] == "text_input":
|
|
|
|
| 995 |
for family_name, use_cases in st.session_state.editable_prompts.items():
|
| 996 |
family_filtered_use_cases = {}
|
| 997 |
for uc_name, uc_config in use_cases.items():
|
| 998 |
+
Apply same filtering logic as in library view
|
| 999 |
match_search = True
|
| 1000 |
if search_term_lib:
|
| 1001 |
match_search = (search_term_lib in uc_name.lower() or
|
|
|
|
| 1452 |
safe_family_key_part = str(generator_family).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1453 |
safe_uc_key_part = str(generator_use_case).replace(' ', '_').replace('.', '_').replace('{', '_').replace('}', '_').replace('(', '_').replace(')', '_')
|
| 1454 |
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)
|
| 1455 |
+
Description
|
| 1456 |
new_desc = st.text_area("Description (aide pour l'utilisateur):", value=current_prompt_config.get('description', ''), height=100, key=f"desc_text_area_{safe_family_key_part}_{safe_uc_key_part}")
|
| 1457 |
st.markdown("##### Variables disponibles à insérer :"); variables_config = current_prompt_config.get('variables', [])
|
| 1458 |
if not variables_config: st.caption("Aucune variable définie pour ce prompt. Ajoutez-en ci-dessous.")
|
|
|
|
| 1469 |
save_editable_prompts_to_local_and_hf()
|
| 1470 |
st.success("Template et Description sauvegardés!");
|
| 1471 |
st.rerun()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1472 |
# --- TEMPORARILY COMMENTED OUT FOR GLITCH TESTING ---
|
| 1473 |
+
# st.markdown("---"); st.subheader("Variables du Prompt"); current_variables_list = current_prompt_config.get('variables', [])
|
| 1474 |
+
# if not current_variables_list: st.info("Aucune variable définie.")
|
| 1475 |
+
# else: pass
|
| 1476 |
+
# for idx, var_data in enumerate(list(current_variables_list)):
|
| 1477 |
+
# var_id_for_key = var_data.get('name', f"varidx{idx}").replace(" ", "_"); action_key_prefix = f"var_action_{generator_family.replace(' ','_')}_{generator_use_case.replace(' ','_')}_{var_id_for_key}"
|
| 1478 |
+
# col_info, col_up, col_down, col_edit, col_delete = st.columns([3, 0.5, 0.5, 0.8, 0.8])
|
| 1479 |
+
# with col_info: st.markdown(f"**{idx + 1}. {var_data.get('name', 'N/A')}** ({var_data.get('label', 'N/A')})\n*Type: `{var_data.get('type', 'N/A')}`*")
|
| 1480 |
+
# with col_up:
|
| 1481 |
+
# disable_up_button = (idx == 0)
|
| 1482 |
+
# if st.button("↑", key=f"{action_key_prefix}_up", help="Monter cette variable", disabled=disable_up_button, use_container_width=True): current_variables_list[idx], current_variables_list[idx-1] = current_variables_list[idx-1], current_variables_list[idx]; current_prompt_config["variables"] = current_variables_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf(); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.rerun()
|
| 1483 |
+
# with col_down:
|
| 1484 |
+
# disable_down_button = (idx == len(current_variables_list) - 1)
|
| 1485 |
+
# if st.button("↓", key=f"{action_key_prefix}_down", help="Descendre cette variable", disabled=disable_down_button, use_container_width=True): current_variables_list[idx], current_variables_list[idx+1] = current_variables_list[idx+1], current_variables_list[idx]; current_prompt_config["variables"] = current_variables_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf(); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.rerun()
|
| 1486 |
+
# with col_edit:
|
| 1487 |
+
# if st.button("Modifier", key=f"{action_key_prefix}_edit", use_container_width=True): st.session_state.editing_variable_info = { "family": generator_family, "use_case": generator_use_case, "index": idx, "data": copy.deepcopy(var_data) }; st.session_state.variable_type_to_create = var_data.get('type'); st.rerun()
|
| 1488 |
+
# with col_delete:
|
| 1489 |
+
# if st.button("Suppr.", key=f"{action_key_prefix}_delete", type="secondary", use_container_width=True): variable_name_to_delete = current_variables_list.pop(idx).get('name', 'Variable inconnue'); current_prompt_config["variables"] = current_variables_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf(); st.success(f"Variable '{variable_name_to_delete}' supprimée."); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.rerun()
|
| 1490 |
# --- TEMPORARILY COMMENTED OUT FOR GLITCH TESTING ---
|
| 1491 |
+
# st.markdown("---"); st.subheader("Ajouter une Variable"); is_editing_var = False; variable_data_for_form = {"name": "", "label": "", "type": "", "options": "", "default": ""}
|
| 1492 |
+
# if st.session_state.editing_variable_info and st.session_state.editing_variable_info.get("family") == generator_family and st.session_state.editing_variable_info.get("use_case") == generator_use_case:
|
| 1493 |
+
# edit_var_idx = st.session_state.editing_variable_info["index"]
|
| 1494 |
+
# if edit_var_idx < len(current_prompt_config.get('variables',[])):
|
| 1495 |
+
# is_editing_var = True; current_editing_data_snapshot = current_prompt_config['variables'][edit_var_idx]; variable_data_for_form.update(copy.deepcopy(current_editing_data_snapshot))
|
| 1496 |
+
# if isinstance(variable_data_for_form.get("options"), list): variable_data_for_form["options"] = ", ".join(map(str, variable_data_for_form["options"]))
|
| 1497 |
+
# raw_def_edit_form = variable_data_for_form.get("default")
|
| 1498 |
+
# if isinstance(raw_def_edit_form, date): variable_data_for_form["default"] = raw_def_edit_form.strftime("%Y-%m-%d")
|
| 1499 |
+
# elif raw_def_edit_form is not None: variable_data_for_form["default"] = str(raw_def_edit_form)
|
| 1500 |
+
# else: variable_data_for_form["default"] = ""
|
| 1501 |
+
# else: st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None; st.warning("La variable que vous tentiez de modifier n'existe plus. Annulation de l'édition."); st.rerun() # pragma: no cover
|
| 1502 |
+
# if not is_editing_var and st.session_state.variable_type_to_create is None:
|
| 1503 |
+
# st.markdown("##### 1. Choisissez le type de variable à créer :"); variable_types_map = { "Zone de texte (courte)": "text_input", "Liste choix": "selectbox", "Date": "date_input", "Nombre": "number_input", "Zone de texte (longue)": "text_area" }; num_type_buttons = len(variable_types_map); cols_type_buttons = st.columns(min(num_type_buttons, 5)); button_idx = 0
|
| 1504 |
+
# for btn_label, type_val in variable_types_map.items():
|
| 1505 |
+
# if cols_type_buttons[button_idx % len(cols_type_buttons)].button(btn_label, key=f"btn_type_{type_val}_{generator_use_case.replace(' ','_')}", use_container_width=True): st.session_state.variable_type_to_create = type_val; st.rerun()
|
| 1506 |
+
# button_idx += 1
|
| 1507 |
+
# st.markdown("---")
|
| 1508 |
+
# if st.session_state.variable_type_to_create:
|
| 1509 |
+
# current_type_for_form = st.session_state.variable_type_to_create
|
| 1510 |
+
# variable_types_map_display = {
|
| 1511 |
+
# "text_input": "Zone de texte (courte)", "selectbox": "Liste choix",
|
| 1512 |
+
# "date_input": "Date", "number_input": "Nombre", "text_area": "Zone de texte (longue)"
|
| 1513 |
+
# }
|
| 1514 |
+
# readable_type = variable_types_map_display.get(current_type_for_form, "Type Inconnu")
|
| 1515 |
+
# form_title = f"Modifier Variable : {variable_data_for_form.get('name','N/A')} ({readable_type})" if is_editing_var else f"Nouvelle Variable : {readable_type}"
|
| 1516 |
+
# st.markdown(f"##### 2. Configurez la variable")
|
| 1517 |
+
|
| 1518 |
+
# form_key_suffix = f"_edit_{st.session_state.editing_variable_info['index']}" if is_editing_var and st.session_state.editing_variable_info else "_create"
|
| 1519 |
+
# form_var_specific_key = f"form_var_{current_type_for_form}_{generator_use_case.replace(' ','_')}{form_key_suffix}"
|
| 1520 |
+
|
| 1521 |
+
# with st.form(key=form_var_specific_key, clear_on_submit=(not is_editing_var)):
|
| 1522 |
+
# st.subheader(form_title)
|
| 1523 |
+
# var_name_input_form = st.text_input(
|
| 1524 |
+
# "Nom technique (ex : nom_client. Sans espaces, accents ou caractères spéciaux)",
|
| 1525 |
+
# value=variable_data_for_form.get("name", ""),
|
| 1526 |
+
# key=f"{form_var_specific_key}_name",
|
| 1527 |
+
# disabled=is_editing_var
|
| 1528 |
# )
|
| 1529 |
+
# var_label_input_form = st.text_input(
|
| 1530 |
+
# "Label pour l'utilisateur (description affichée)",
|
| 1531 |
+
# value=variable_data_for_form.get("label", ""),
|
| 1532 |
+
# key=f"{form_var_specific_key}_label"
|
| 1533 |
+
# )
|
| 1534 |
+
# var_options_str_input_form = ""
|
| 1535 |
+
# if current_type_for_form == "selectbox":
|
| 1536 |
+
# var_options_str_input_form = st.text_input(
|
| 1537 |
+
# "Options (séparées par une virgule)",
|
| 1538 |
+
# value=variable_data_for_form.get("options", ""),
|
| 1539 |
+
# key=f"{form_var_specific_key}_options"
|
| 1540 |
+
# )
|
| 1541 |
+
# date_hint = " (Format AAAA-MM-JJ)" if current_type_for_form == "date_input" else ""
|
| 1542 |
+
# var_default_val_str_input_form = st.text_input(
|
| 1543 |
+
# f"Valeur par défaut{date_hint}",
|
| 1544 |
+
# value=str(variable_data_for_form.get("default", "")),
|
| 1545 |
+
# key=f"{form_var_specific_key}_default"
|
| 1546 |
# )
|
| 1547 |
|
| 1548 |
+
# min_val_input_form, max_val_input_form, step_val_input_form, height_val_input_form = None, None, None, None
|
| 1549 |
+
# if current_type_for_form == "number_input":
|
| 1550 |
+
# num_cols_var_form = st.columns(3)
|
| 1551 |
+
# min_val_edit_default = variable_data_for_form.get("min_value")
|
| 1552 |
+
# max_val_edit_default = variable_data_for_form.get("max_value")
|
| 1553 |
+
# step_val_edit_default = variable_data_for_form.get("step", 1.0)
|
| 1554 |
+
# min_val_input_form = num_cols_var_form[0].number_input("Valeur minimale (optionnel)", value=float(min_val_edit_default) if min_val_edit_default is not None else None, format="%g", key=f"{form_var_specific_key}_min")
|
| 1555 |
+
# max_val_input_form = num_cols_var_form[1].number_input("Valeur maximale (optionnel)", value=float(max_val_edit_default) if max_val_edit_default is not None else None, format="%g", key=f"{form_var_specific_key}_max")
|
| 1556 |
+
# step_val_input_form = num_cols_var_form[2].number_input("Pas (incrément)", value=float(step_val_edit_default), format="%g", min_value=1e-9, key=f"{form_var_specific_key}_step")
|
| 1557 |
+
# if current_type_for_form == "text_area":
|
| 1558 |
+
# height_val_input_form = st.number_input("Hauteur de la zone de texte (pixels)", value=int(variable_data_for_form.get("height", 100)), min_value=68, step=25, key=f"{form_var_specific_key}_height")
|
| 1559 |
+
|
| 1560 |
+
# submit_button_label_form = "Sauvegarder Modifications" if is_editing_var else "Ajouter Variable"
|
| 1561 |
+
# submitted_specific_var_form = st.form_submit_button(submit_button_label_form)
|
| 1562 |
+
|
| 1563 |
+
# if submitted_specific_var_form:
|
| 1564 |
+
# var_name_val_submit = var_name_input_form.strip()
|
| 1565 |
+
# if not var_name_val_submit or not var_label_input_form.strip(): st.error("Le nom technique et le label de la variable sont requis.")
|
| 1566 |
+
# elif not var_name_val_submit.isidentifier(): st.error("Nom technique invalide. Utilisez lettres, chiffres, underscores. Ne pas commencer par un chiffre. Ne pas utiliser de mot-clé Python.")
|
| 1567 |
+
# elif current_type_for_form == "selectbox" and not [opt.strip() for opt in var_options_str_input_form.split(',') if opt.strip()]: st.error("Pour une variable de type 'Liste choix', au moins une option est requise.")
|
| 1568 |
# else:
|
| 1569 |
+
# new_var_data_to_submit = { "name": var_name_val_submit, "label": var_label_input_form.strip(), "type": current_type_for_form }; parsed_def_val_submit = parse_default_value(var_default_val_str_input_form.strip(), current_type_for_form)
|
| 1570 |
+
# if current_type_for_form == "selectbox":
|
| 1571 |
+
# options_list_submit = [opt.strip() for opt in var_options_str_input_form.split(',') if opt.strip()]; new_var_data_to_submit["options"] = options_list_submit
|
| 1572 |
+
# if options_list_submit:
|
| 1573 |
+
# if parsed_def_val_submit not in options_list_submit: st.warning(f"La valeur par défaut '{parsed_def_val_submit}' n'est pas dans la liste d'options. La première option '{options_list_submit[0]}' sera utilisée comme défaut."); new_var_data_to_submit["default"] = options_list_submit[0]
|
| 1574 |
+
# else: new_var_data_to_submit["default"] = parsed_def_val_submit
|
| 1575 |
+
# else: new_var_data_to_submit["default"] = ""
|
| 1576 |
+
# else: new_var_data_to_submit["default"] = parsed_def_val_submit
|
| 1577 |
+
# if current_type_for_form == "number_input":
|
| 1578 |
+
# if min_val_input_form is not None: new_var_data_to_submit["min_value"] = float(min_val_input_form)
|
| 1579 |
+
# if max_val_input_form is not None: new_var_data_to_submit["max_value"] = float(max_val_input_form)
|
| 1580 |
+
# if step_val_input_form is not None: new_var_data_to_submit["step"] = float(step_val_input_form)
|
| 1581 |
+
# else: new_var_data_to_submit["step"] = 1.0
|
| 1582 |
+
# if current_type_for_form == "text_area" and height_val_input_form is not None:
|
| 1583 |
+
# new_var_data_to_submit["height"] = int(height_val_input_form)
|
| 1584 |
+
|
| 1585 |
+
# can_proceed_with_save = True; target_vars_list = current_prompt_config.get('variables', [])
|
| 1586 |
+
# if is_editing_var:
|
| 1587 |
+
# idx_to_edit_submit_form = st.session_state.editing_variable_info["index"]; target_vars_list[idx_to_edit_submit_form] = new_var_data_to_submit; st.success(f"Variable '{var_name_val_submit}' mise à jour avec succès."); st.session_state.editing_variable_info = None; st.session_state.variable_type_to_create = None
|
| 1588 |
+
# else:
|
| 1589 |
+
# existing_var_names_in_uc = [v['name'] for v in target_vars_list]
|
| 1590 |
+
# if var_name_val_submit in existing_var_names_in_uc: st.error(f"Une variable avec le nom technique '{var_name_val_submit}' existe déjà pour ce cas d'usage."); can_proceed_with_save = False
|
| 1591 |
+
# else: target_vars_list.append(new_var_data_to_submit); st.success(f"Variable '{var_name_val_submit}' ajoutée avec succès.")
|
| 1592 |
+
# if can_proceed_with_save:
|
| 1593 |
+
# current_prompt_config["variables"] = target_vars_list; current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf()
|
| 1594 |
+
# if not is_editing_var: st.session_state.variable_type_to_create = None
|
| 1595 |
+
# st.rerun()
|
| 1596 |
+
|
| 1597 |
+
# cancel_button_label_form = "Annuler Modification" if is_editing_var else "Changer de Type / Annuler Création"
|
| 1598 |
+
# cancel_btn_key = f"cancel_var_action_btn_{form_var_specific_key}_outside"
|
| 1599 |
+
|
| 1600 |
+
# if st.button(cancel_button_label_form, key=cancel_btn_key, help="Réinitialise le formulaire de variable."):
|
| 1601 |
+
# st.session_state.variable_type_to_create = None
|
| 1602 |
+
# if is_editing_var:
|
| 1603 |
+
# st.session_state.editing_variable_info = None
|
| 1604 |
# st.rerun()
|
| 1605 |
+
st.markdown("---"); st.subheader("🏷️ Tags"); current_tags_str = ", ".join(current_prompt_config.get("tags", []))
|
| 1606 |
+
new_tags_str_input = st.text_input("Tags (séparés par des virgules):", value=current_tags_str, key=f"tags_input_{generator_family}_{generator_use_case}")
|
| 1607 |
+
if st.button("Sauvegarder Tags", key=f"save_tags_btn_{generator_family}_{generator_use_case}"): current_prompt_config["tags"] = sorted(list(set(t.strip() for t in new_tags_str_input.split(',') if t.strip()))); current_prompt_config["updated_at"] = datetime.now().isoformat(); save_editable_prompts_to_local_and_hf(); st.success("Tags sauvegardés!"); st.rerun()
|
| 1608 |
+
|
| 1609 |
+
st.markdown("---")
|
| 1610 |
+
st.subheader("Actions sur le Cas d'Usage")
|
| 1611 |
+
|
| 1612 |
+
if st.session_state.duplicating_use_case_details and \
|
| 1613 |
+
st.session_state.duplicating_use_case_details["family"] == generator_family and \
|
| 1614 |
+
st.session_state.duplicating_use_case_details["use_case"] == generator_use_case:
|
| 1615 |
+
|
| 1616 |
+
original_uc_name_for_dup_form = st.session_state.duplicating_use_case_details["use_case"]
|
| 1617 |
+
original_family_name_for_dup = st.session_state.duplicating_use_case_details["family"]
|
| 1618 |
+
st.markdown(f"#### Dupliquer '{original_uc_name_for_dup_form}' (depuis: {original_family_name_for_dup})")
|
| 1619 |
+
|
| 1620 |
+
form_key_duplicate = f"form_duplicate_name_{original_family_name_for_dup.replace(' ','_')}_{original_uc_name_for_dup_form.replace(' ','_')}"
|
| 1621 |
+
with st.form(key=form_key_duplicate):
|
| 1622 |
+
available_families_list = list(st.session_state.editable_prompts.keys())
|
| 1623 |
+
try:
|
| 1624 |
+
default_family_idx = available_families_list.index(original_family_name_for_dup)
|
| 1625 |
+
except ValueError:
|
| 1626 |
+
default_family_idx = 0
|
| 1627 |
+
|
| 1628 |
+
selected_target_family_for_duplicate = st.selectbox(
|
| 1629 |
+
"Choisir la famille de destination pour la copie :",
|
| 1630 |
+
options=available_families_list,
|
| 1631 |
+
index=default_family_idx,
|
| 1632 |
+
key=f"target_family_dup_select_{form_key_duplicate}"
|
| 1633 |
+
)
|
| 1634 |
+
|
| 1635 |
+
suggested_new_name_base = f"{original_uc_name_for_dup_form} (copie)"
|
| 1636 |
+
suggested_new_name = suggested_new_name_base
|
| 1637 |
+
temp_copy_count = 1
|
| 1638 |
+
while suggested_new_name in st.session_state.editable_prompts.get(selected_target_family_for_duplicate, {}):
|
| 1639 |
+
suggested_new_name = f"{suggested_new_name_base} {temp_copy_count}"
|
| 1640 |
+
temp_copy_count += 1
|
| 1641 |
+
|
| 1642 |
+
new_duplicated_uc_name_input = st.text_input(
|
| 1643 |
+
"Nouveau nom pour le cas d'usage dupliqué:",
|
| 1644 |
+
value=suggested_new_name,
|
| 1645 |
+
key=f"new_dup_name_input_{form_key_duplicate}"
|
| 1646 |
+
)
|
| 1647 |
+
|
| 1648 |
+
submitted_duplicate_form = st.form_submit_button("✅ Confirmer la Duplication", use_container_width=True)
|
| 1649 |
+
|
| 1650 |
+
if submitted_duplicate_form:
|
| 1651 |
+
new_uc_name_val_from_form = new_duplicated_uc_name_input.strip()
|
| 1652 |
+
target_family_on_submit = selected_target_family_for_duplicate
|
| 1653 |
+
|
| 1654 |
+
if not new_uc_name_val_from_form:
|
| 1655 |
+
st.error("Le nom du nouveau cas d'usage ne peut pas être vide.")
|
| 1656 |
+
elif new_uc_name_val_from_form in st.session_state.editable_prompts.get(target_family_on_submit, {}):
|
| 1657 |
+
st.error(f"Un cas d'usage nommé '{new_uc_name_val_from_form}' existe déjà dans la famille '{target_family_on_submit}'.")
|
| 1658 |
+
else:
|
| 1659 |
+
st.session_state.editable_prompts[target_family_on_submit][new_uc_name_val_from_form] = copy.deepcopy(current_prompt_config)
|
| 1660 |
+
now_iso_dup_create, now_iso_dup_update = get_default_dates()
|
| 1661 |
+
st.session_state.editable_prompts[target_family_on_submit][new_uc_name_val_from_form]["created_at"] = now_iso_dup_create
|
| 1662 |
+
st.session_state.editable_prompts[target_family_on_submit][new_uc_name_val_from_form]["updated_at"] = now_iso_dup_update
|
| 1663 |
+
st.session_state.editable_prompts[target_family_on_submit][new_uc_name_val_from_form]["usage_count"] = 0
|
| 1664 |
+
save_editable_prompts_to_local_and_hf()
|
| 1665 |
+
st.success(f"Cas d'usage '{original_uc_name_for_dup_form}' dupliqué en '{new_uc_name_val_from_form}' dans la famille '{target_family_on_submit}'.")
|
| 1666 |
+
|
| 1667 |
+
st.session_state.duplicating_use_case_details = None
|
| 1668 |
+
st.session_state.force_select_family_name = target_family_on_submit
|
| 1669 |
+
st.session_state.force_select_use_case_name = new_uc_name_val_from_form
|
| 1670 |
+
st.session_state.active_generated_prompt = ""
|
| 1671 |
+
st.session_state.variable_type_to_create = None
|
| 1672 |
+
st.session_state.editing_variable_info = None
|
| 1673 |
+
st.session_state.go_to_config_section = True
|
| 1674 |
+
st.rerun()
|
| 1675 |
+
|
| 1676 |
+
cancel_key_duplicate = f"cancel_dup_process_{original_family_name_for_dup.replace(' ','_')}_{original_uc_name_for_dup_form.replace(' ','_')}"
|
| 1677 |
+
if st.button("❌ Annuler la Duplication", key=cancel_key_duplicate, use_container_width=True):
|
| 1678 |
+
st.session_state.duplicating_use_case_details = None
|
| 1679 |
+
st.rerun()
|
| 1680 |
+
else:
|
| 1681 |
+
action_cols_manage = st.columns(2)
|
| 1682 |
+
with action_cols_manage[0]:
|
| 1683 |
+
dup_key_init = f"initiate_dup_uc_btn_{generator_family.replace(' ','_')}_{generator_use_case.replace(' ','_')}"
|
| 1684 |
+
if st.button("🔄 Dupliquer ce Cas d'Usage", key=dup_key_init, use_container_width=True):
|
| 1685 |
+
st.session_state.duplicating_use_case_details = {
|
| 1686 |
+
"family": generator_family,
|
| 1687 |
+
"use_case": generator_use_case
|
| 1688 |
+
}
|
| 1689 |
+
st.session_state.go_to_config_section = True
|
| 1690 |
+
st.rerun()
|
| 1691 |
+
|
| 1692 |
+
with action_cols_manage[1]:
|
| 1693 |
+
del_uc_key_exp_main = f"del_uc_btn_exp_main_{generator_family.replace(' ','_')}_{generator_use_case.replace(' ','_')}"
|
| 1694 |
+
is_confirming_this_uc_delete_main = bool(st.session_state.confirming_delete_details and \
|
| 1695 |
+
st.session_state.confirming_delete_details.get("family") == generator_family and \
|
| 1696 |
+
st.session_state.confirming_delete_details.get("use_case") == generator_use_case)
|
| 1697 |
+
if st.button("🗑️ Supprimer Cas d'Usage", key=del_uc_key_exp_main, type="secondary", disabled=is_confirming_this_uc_delete_main, use_container_width=True):
|
| 1698 |
+
st.session_state.confirming_delete_details = {"family": generator_family, "use_case": generator_use_case}
|
| 1699 |
+
st.rerun()
|
| 1700 |
|
| 1701 |
if st.session_state.get('go_to_config_section'):
|
| 1702 |
st.session_state.go_to_config_section = False
|
|
|
|
| 1837 |
temp_form_values = {}
|
| 1838 |
for var_info in ASSISTANT_FORM_VARIABLES:
|
| 1839 |
field_key = f"assistant_form_{var_info['name']}"
|
| 1840 |
+
Utilise la valeur de session_state pour ce champ ou la valeur par défaut si non trouvée
|
| 1841 |
value_for_widget = st.session_state.assistant_form_values.get(var_info['name'], var_info['default'])
|
| 1842 |
|
| 1843 |
if var_info["type"] == "text_input":
|