File size: 1,185 Bytes
fc40f0c
1d77a32
 
 
 
a9a644b
 
 
1d77a32
a9a644b
1d77a32
a9a644b
fc40f0c
 
 
 
abe2bca
1d77a32
 
 
 
 
 
 
 
a9a644b
fc40f0c
 
a9a644b
fc40f0c
 
06eeb91
a9a644b
 
 
 
 
 
 
fc40f0c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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()