Update main.py
Browse files
main.py
CHANGED
@@ -427,7 +427,7 @@ def create_learning_situations(state: AgentState, pathname: str = "") -> AgentSt
|
|
427 |
"status": "learning_situations_created"
|
428 |
}
|
429 |
|
430 |
-
def create_academic_competencies(state: AgentState, pathname: str = "") -> AgentState:
|
431 |
"""
|
432 |
Crée 4 compétences académiques, une pour chaque catégorie thématique.
|
433 |
|
@@ -449,7 +449,10 @@ def create_academic_competencies(state: AgentState, pathname: str = "") -> Agent
|
|
449 |
cat_name = category["nom"]
|
450 |
cat_desc = category["description"]
|
451 |
teachings = classified_teachings.get(cat_name, [])
|
452 |
-
|
|
|
|
|
|
|
453 |
|
454 |
if not teachings:
|
455 |
print(f"Aucun enseignement classé dans la catégorie '{cat_name}'. Passage à la suivante.")
|
@@ -546,7 +549,7 @@ def create_academic_competencies(state: AgentState, pathname: str = "") -> Agent
|
|
546 |
"status": "academic_competencies_created"
|
547 |
}
|
548 |
|
549 |
-
def build_workflow(num_bcc,file,pathname) -> StateGraph:
|
550 |
"""Construit le graphe de workflow LangGraph."""
|
551 |
|
552 |
# Initialiser le graphe
|
@@ -558,7 +561,7 @@ def build_workflow(num_bcc,file,pathname) -> StateGraph:
|
|
558 |
workflow.add_node("classify_teachings", lambda state: classify_teachings(state, num_bcc))
|
559 |
workflow.add_node("create_learning_situations", lambda state: create_learning_situations(state, pathname))
|
560 |
#workflow.add_node("export_to_excel_1", lambda state: export_to_excel(state))
|
561 |
-
workflow.add_node("create_academic_competencies", lambda state: create_academic_competencies(state, pathname))
|
562 |
#workflow.add_node("export_to_excel_2", lambda state: export_to_excel(state, "_BCC"))
|
563 |
#workflow.add_node("process_next_file", get_next_file)
|
564 |
|
@@ -588,7 +591,7 @@ def build_workflow(num_bcc,file,pathname) -> StateGraph:
|
|
588 |
|
589 |
return workflow
|
590 |
|
591 |
-
def init_agent_state(current_url, num, pathname) -> AgentState:
|
592 |
initial_state: AgentState = {
|
593 |
#"files_list": csv_files[1:], # Tous les fichiers sauf le premier
|
594 |
#"current_file": csv_files[0], # Premier fichier à traiter
|
@@ -603,7 +606,7 @@ def init_agent_state(current_url, num, pathname) -> AgentState:
|
|
603 |
}
|
604 |
|
605 |
# Construire le workflow
|
606 |
-
workflow = build_workflow(num,current_url,pathname)
|
607 |
|
608 |
# Compiler le graphe
|
609 |
app = workflow.compile()
|
@@ -1251,6 +1254,7 @@ app_page = dmc.MantineProvider(
|
|
1251 |
style={"color": "rgb(80,106,139)","font-size": "0.75rem","border":"border 1px solid rgb(67,167,255)!important","margin-bottom":"0.5rem"},
|
1252 |
),sm=6),
|
1253 |
]),
|
|
|
1254 |
dbc.Row(dbc.Col(dbc.Button('Créer les nouveaux BCC et les nouvelles situations', id='submit-button', n_clicks=0, style={"background":"linear-gradient(to right, #00F3FF 0%, #7f00b2 100%)","color":"white","font-size": "0.75rem","margin-bottom":"2rem"}),sm=12))
|
1255 |
], width=12)
|
1256 |
]),
|
@@ -2189,11 +2193,12 @@ def display_page(pathname):
|
|
2189 |
Output("output-response", "children"),
|
2190 |
Input("num-bcc", "value"),
|
2191 |
Input("maquette-dropdown", "value"),
|
|
|
2192 |
Input("submit-button", "n_clicks"),
|
2193 |
State("url", "pathname"),
|
2194 |
prevent_initial_call=True,
|
2195 |
)
|
2196 |
-
def display_status(num, current, n_clicks, pathname):
|
2197 |
if not n_clicks:
|
2198 |
return no_update
|
2199 |
|
@@ -2207,7 +2212,7 @@ def display_status(num, current, n_clicks, pathname):
|
|
2207 |
current_url = current
|
2208 |
|
2209 |
print(f"Fichier Maquette sélectionné: {current_url}")
|
2210 |
-
agent = init_agent_state(current_url, num, pathname)
|
2211 |
try:
|
2212 |
df = agent[0]
|
2213 |
result = agent[1]
|
|
|
427 |
"status": "learning_situations_created"
|
428 |
}
|
429 |
|
430 |
+
def create_academic_competencies(state: AgentState, checked:bool, pathname: str = "") -> AgentState:
|
431 |
"""
|
432 |
Crée 4 compétences académiques, une pour chaque catégorie thématique.
|
433 |
|
|
|
449 |
cat_name = category["nom"]
|
450 |
cat_desc = category["description"]
|
451 |
teachings = classified_teachings.get(cat_name, [])
|
452 |
+
if checked == False:
|
453 |
+
situation = ""
|
454 |
+
else:
|
455 |
+
situation = learning_situations.get(cat_name, "")
|
456 |
|
457 |
if not teachings:
|
458 |
print(f"Aucun enseignement classé dans la catégorie '{cat_name}'. Passage à la suivante.")
|
|
|
549 |
"status": "academic_competencies_created"
|
550 |
}
|
551 |
|
552 |
+
def build_workflow(num_bcc,file,checked,pathname) -> StateGraph:
|
553 |
"""Construit le graphe de workflow LangGraph."""
|
554 |
|
555 |
# Initialiser le graphe
|
|
|
561 |
workflow.add_node("classify_teachings", lambda state: classify_teachings(state, num_bcc))
|
562 |
workflow.add_node("create_learning_situations", lambda state: create_learning_situations(state, pathname))
|
563 |
#workflow.add_node("export_to_excel_1", lambda state: export_to_excel(state))
|
564 |
+
workflow.add_node("create_academic_competencies", lambda state: create_academic_competencies(state, checked, pathname))
|
565 |
#workflow.add_node("export_to_excel_2", lambda state: export_to_excel(state, "_BCC"))
|
566 |
#workflow.add_node("process_next_file", get_next_file)
|
567 |
|
|
|
591 |
|
592 |
return workflow
|
593 |
|
594 |
+
def init_agent_state(current_url, num, checked, pathname) -> AgentState:
|
595 |
initial_state: AgentState = {
|
596 |
#"files_list": csv_files[1:], # Tous les fichiers sauf le premier
|
597 |
#"current_file": csv_files[0], # Premier fichier à traiter
|
|
|
606 |
}
|
607 |
|
608 |
# Construire le workflow
|
609 |
+
workflow = build_workflow(num,current_url,checked,pathname)
|
610 |
|
611 |
# Compiler le graphe
|
612 |
app = workflow.compile()
|
|
|
1254 |
style={"color": "rgb(80,106,139)","font-size": "0.75rem","border":"border 1px solid rgb(67,167,255)!important","margin-bottom":"0.5rem"},
|
1255 |
),sm=6),
|
1256 |
]),
|
1257 |
+
dbc.Row(dbc.Col(dmc.Checkbox(id="is-situation", label="Prendre en compte les situations d'apprentissage dans la génération des BCC", checked=False, mb=10),)),
|
1258 |
dbc.Row(dbc.Col(dbc.Button('Créer les nouveaux BCC et les nouvelles situations', id='submit-button', n_clicks=0, style={"background":"linear-gradient(to right, #00F3FF 0%, #7f00b2 100%)","color":"white","font-size": "0.75rem","margin-bottom":"2rem"}),sm=12))
|
1259 |
], width=12)
|
1260 |
]),
|
|
|
2193 |
Output("output-response", "children"),
|
2194 |
Input("num-bcc", "value"),
|
2195 |
Input("maquette-dropdown", "value"),
|
2196 |
+
Input("is-situation", "checked"),
|
2197 |
Input("submit-button", "n_clicks"),
|
2198 |
State("url", "pathname"),
|
2199 |
prevent_initial_call=True,
|
2200 |
)
|
2201 |
+
def display_status(num, current, checked, n_clicks, pathname):
|
2202 |
if not n_clicks:
|
2203 |
return no_update
|
2204 |
|
|
|
2212 |
current_url = current
|
2213 |
|
2214 |
print(f"Fichier Maquette sélectionné: {current_url}")
|
2215 |
+
agent = init_agent_state(current_url, num, checked, pathname)
|
2216 |
try:
|
2217 |
df = agent[0]
|
2218 |
result = agent[1]
|