ConseillerAugmente / pages /chapter_params.py
feat : add difficult diagnostic pages
abe2bca
import streamlit as st
from db.db import DatabaseHandler
# Instanciation de la base de données
db = DatabaseHandler()
def area_change(key, ):
new_value = st.session_state[key]
key = key[5:] # remove 'area_' prefix
db.update_prompt(key, prompt=new_value)
def page():
st.subheader("Définissez vos paramètres")
type = st.selectbox("Type de diagnostique", ["Installation", "Difficulté"], key="mode")
if(type == "Installation"):
diag_type = "installation"
else:
diag_type = "difficult"
# Chargement de l'enregistrement correspondant aux filtres
chapters = db.get_prompt_by_filters(type_=diag_type)
parts_sorted = sorted(chapters, key=lambda part: part.get('num', float('inf')))
# Création de tabs pour chaque 'part' trié
tabs = st.tabs([part['title'] for part in parts_sorted])
for part, tab in zip(parts_sorted, tabs):
with tab:
k = f"area_{part['num']}"
st.text_area(
"Prompt System",
part['prompt_system'],
key=k,
on_change=area_change,
args=(k,),
height=400)
page()