Update main.py
Browse files
main.py
CHANGED
@@ -26,13 +26,11 @@ from langgraph.checkpoint.memory import MemorySaver
|
|
26 |
from langchain_openai import ChatOpenAI
|
27 |
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
|
28 |
|
29 |
-
from dash_socketio import DashSocketIO
|
30 |
import dash
|
31 |
from dash.dependencies import Input, Output, State
|
32 |
from dash import Dash, html, dcc, callback, callback_context, ctx, Output, Input, dash_table, State, no_update, _dash_renderer, clientside_callback
|
33 |
from dash import html
|
34 |
|
35 |
-
import dash_bootstrap_components as dbc
|
36 |
import dash_bootstrap_components as dbc
|
37 |
from dash.exceptions import PreventUpdate
|
38 |
import dash_mantine_components as dmc
|
@@ -40,7 +38,6 @@ from dash_iconify import DashIconify
|
|
40 |
_dash_renderer._set_react_version("18.2.0")
|
41 |
import flask
|
42 |
from flask_login import LoginManager, UserMixin, login_user, current_user, login_required, logout_user
|
43 |
-
from flask_socketio import SocketIO, emit
|
44 |
from datetime import timedelta
|
45 |
|
46 |
from IPython.display import display, HTML
|
@@ -591,7 +588,7 @@ def build_workflow(num_bcc,file,pathname) -> StateGraph:
|
|
591 |
|
592 |
return workflow
|
593 |
|
594 |
-
def init_agent_state(current_url, num,
|
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
|
@@ -625,61 +622,37 @@ def init_agent_state(current_url, num, socket_id, pathname) -> AgentState:
|
|
625 |
if task == "load_and_preprocess":
|
626 |
if key == "current_file":
|
627 |
result += f"Traitement du fichier {taskInfo['current_file']} en cours...\n"
|
628 |
-
emit("stream", f"Traitement du fichier {taskInfo['current_file']} en cours... Création des catégories d'enseignements en cours...\n", namespace="/", to=socket_id)
|
629 |
-
time.sleep(0.05)
|
630 |
if task == "classify_teachings":
|
631 |
if key == "status":
|
632 |
for key, value in taskInfo['classified_teachings'].items():
|
633 |
result += f"\n\n-**Enseignement classé dans la catégorie '{key}'** : "
|
634 |
-
emit("stream", f"\n\nEnseignement classé dans la catégorie '{key}' : ", namespace="/", to=socket_id)
|
635 |
-
time.sleep(1.0)
|
636 |
for enseignement in value:
|
637 |
result += f"{enseignement}, "
|
638 |
-
emit("stream", f"{enseignement}, ", namespace="/", to=socket_id)
|
639 |
-
time.sleep(0.05)
|
640 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
641 |
-
emit("stream", f"\n\nTraitement de la tâche : {taskInfo['status']}... Création des situations d'apprentissage en cours...\n", namespace="/", to=socket_id)
|
642 |
-
time.sleep(0.05)
|
643 |
if task == "create_categories":
|
644 |
if key == "status":
|
645 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
646 |
-
emit("stream", f"\n\nTraitement de la tâche : {taskInfo['status']}... Classification des enseignements en cours...\n", namespace="/", to=socket_id)
|
647 |
-
time.sleep(0.05)
|
648 |
if task == "create_learning_situations":
|
649 |
if key == "status":
|
650 |
if taskInfo['learning_situations'].items():
|
651 |
for key, value in taskInfo['learning_situations'].items():
|
652 |
result += f"\n\n-**Situation d'apprentissage créée pour la catégorie '{key}'** : {value}\n"
|
653 |
-
emit("stream", f"\n\nSituation d'apprentissage créée pour la catégorie '{key}' : {value}\n", namespace="/", to=socket_id)
|
654 |
-
time.sleep(1.0)
|
655 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
656 |
-
emit("stream", f"\n\nTraitement de la tâche : {taskInfo['status']}... Création des BCC en cours...\n", namespace="/", to=socket_id)
|
657 |
-
time.sleep(0.05)
|
658 |
else:
|
659 |
result += f"\n\nTraitement de la tâche : pas de situations d'apprentissage créées\n"
|
660 |
-
emit("stream", f"\n\nTraitement de la tâche : pas de situations d'apprentissage créées\n", namespace="/", to=socket_id)
|
661 |
-
time.sleep(0.05)
|
662 |
if task == "create_academic_competencies":
|
663 |
if key == "dataframe":
|
664 |
df = taskInfo['dataframe']
|
665 |
if key == "status":
|
666 |
if taskInfo['academic_competencies'].items():
|
667 |
for key, value in taskInfo['academic_competencies'].items():
|
668 |
-
result += f"\n\n-**Compétence académique créée pour la catégorie '{key}'** : {value}\n"
|
669 |
-
emit("stream", f"\n\nCompétence académique créée pour la catégorie '{key}' : {value}\n", namespace="/", to=socket_id)
|
670 |
-
time.sleep(1.0)
|
671 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
672 |
-
emit("stream", f"\n\nTraitement de la tâche : {taskInfo['status']}...\n", namespace="/", to=socket_id)
|
673 |
-
time.sleep(0.05)
|
674 |
else:
|
675 |
result += f"\n\nTraitement de la tâche : pas de BCC créés\n"
|
676 |
-
emit("stream", f"\n\nTraitement de la tâche : pas de BCC créés\n", namespace="/", to=socket_id)
|
677 |
-
time.sleep(0.05)
|
678 |
if task == "export_to_excel_2":
|
679 |
if key == "status":
|
680 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
681 |
-
emit("stream", f"\n\nTraitement de la tâche : {taskInfo['status']}...\n", namespace="/", to=socket_id)
|
682 |
-
time.sleep(0.05)
|
683 |
|
684 |
except Exception as e:
|
685 |
print(f"Erreur lors de l'exécution du workflow: {e}")
|
@@ -801,7 +774,6 @@ app = dash.Dash(__name__, server=server, external_stylesheets=[dmc.styles.ALL, d
|
|
801 |
update_title='Chargement...',
|
802 |
suppress_callback_exceptions=True)
|
803 |
|
804 |
-
socketio = SocketIO(app.server)
|
805 |
# Updating the Flask Server configuration with Secret Key to encrypt the user session cookie
|
806 |
server.config['REMEMBER_COOKIE_DURATION'] = timedelta(seconds=3600)
|
807 |
|
@@ -1134,7 +1106,7 @@ app_page = dmc.MantineProvider(
|
|
1134 |
className="g-0"
|
1135 |
),
|
1136 |
html.H4(id="text-enseignement-dropdown", className="mb-3 text-success", style={"font-size": "0.7rem"}),
|
1137 |
-
dbc.Textarea(id="enseignement-dropdown", className="mb-3", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),
|
1138 |
], md=6),
|
1139 |
dbc.Col([
|
1140 |
dbc.Row(
|
@@ -1148,7 +1120,7 @@ app_page = dmc.MantineProvider(
|
|
1148 |
className="g-0"
|
1149 |
),
|
1150 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
1151 |
-
dbc.Textarea(id="classification-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),
|
1152 |
], md=6)
|
1153 |
]),
|
1154 |
dbc.Row([
|
@@ -1164,7 +1136,7 @@ app_page = dmc.MantineProvider(
|
|
1164 |
className="g-0"
|
1165 |
),
|
1166 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
1167 |
-
dbc.Textarea(id="situation-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),
|
1168 |
], md=6),
|
1169 |
dbc.Col([
|
1170 |
dbc.Row(
|
@@ -1292,9 +1264,8 @@ app_page = dmc.MantineProvider(
|
|
1292 |
align="left",
|
1293 |
className="g-0"
|
1294 |
),
|
1295 |
-
html.Div(id='output-response', style={"color":"rgb(90, 242, 156)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(90, 242, 156, 0.2)","padding":"5px"}),
|
1296 |
-
|
1297 |
-
DashSocketIO(id='socketio', eventNames=["notification", "stream"]),
|
1298 |
], width=12)
|
1299 |
])
|
1300 |
], className="mt-5")],
|
@@ -1675,9 +1646,8 @@ app_avid_page = dmc.MantineProvider(
|
|
1675 |
align="left",
|
1676 |
className="g-0"
|
1677 |
),
|
1678 |
-
html.Div(id='output-response-avid', style={"color":"rgb(156, 242, 242)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(156, 242, 242, 0.2)","padding":"5px"}),
|
1679 |
-
|
1680 |
-
DashSocketIO(id='socketio-avid', eventNames=["notification", "stream"]),
|
1681 |
], width=12)
|
1682 |
])
|
1683 |
], className="mt-5")],
|
@@ -2215,129 +2185,66 @@ def display_page(pathname):
|
|
2215 |
# You could also return a 404 "URL not found" page here
|
2216 |
return view, url
|
2217 |
|
2218 |
-
@socketio.on("connect")
|
2219 |
-
def on_connect():
|
2220 |
-
print("Client connected")
|
2221 |
-
|
2222 |
-
@socketio.on("disconnect")
|
2223 |
-
def on_disconnect():
|
2224 |
-
print("Client disconnected")
|
2225 |
-
|
2226 |
-
|
2227 |
@callback(
|
2228 |
Output("output-response", "children"),
|
2229 |
-
Output("notification_wrapper", "children", allow_duplicate=True),
|
2230 |
Input("num-bcc", "value"),
|
2231 |
Input("maquette-dropdown", "value"),
|
2232 |
Input("submit-button", "n_clicks"),
|
2233 |
-
State("socketio", "socketId"),
|
2234 |
State("url", "pathname"),
|
2235 |
-
running=[[Output("output-response", "children"), "", None]],
|
2236 |
prevent_initial_call=True,
|
2237 |
)
|
2238 |
-
def display_status(num, current, n_clicks,
|
2239 |
-
if not n_clicks
|
2240 |
-
return no_update
|
2241 |
|
2242 |
if not current:
|
2243 |
print(f"Erreur: Il n'y a pas de fichier dans le répertoire.")
|
2244 |
-
return no_update
|
2245 |
if not num:
|
2246 |
print(f"Erreur: Il n'y a pas de nombre de BCC à générer.")
|
2247 |
-
return no_update
|
2248 |
|
2249 |
current_url = current
|
2250 |
|
2251 |
print(f"Fichier Maquette sélectionné: {current_url}")
|
2252 |
-
agent = init_agent_state(current_url, num,
|
2253 |
try:
|
2254 |
df = agent[0]
|
2255 |
result = agent[1]
|
2256 |
-
return html.Div(children=[dbc.Table.from_dataframe(df[["diplome", "RNCP", "Année d'étude", "Semestre", "BCC", "UE", "ECUE","exemple_situation_apprentissage"]], striped=True, bordered=True, hover=True, index=False), dcc.Markdown(f"""{result}""", style={"color":"white","font-size":"0.75rem"})])
|
2257 |
except:
|
2258 |
-
return html.Div(dcc.Markdown(f"""{agent}""", style={"color":"white","font-size":"0.75rem"}))
|
2259 |
|
2260 |
@callback(
|
2261 |
Output("output-response-avid", "children"),
|
2262 |
-
Output("notification_wrapper-avid", "children", allow_duplicate=True),
|
2263 |
Input("num-bcc-avid", "value"),
|
2264 |
Input("maquette-dropdown-avid", "value"),
|
2265 |
Input("submit-button-avid", "n_clicks"),
|
2266 |
-
State("socketio-avid", "socketId"),
|
2267 |
State("url", "pathname"),
|
2268 |
-
running=[[Output("output-response-avid", "children"), "", None]],
|
2269 |
prevent_initial_call=True,
|
2270 |
)
|
2271 |
-
def display_status(num, current, n_clicks,
|
2272 |
-
if not n_clicks
|
2273 |
-
return no_update
|
2274 |
|
2275 |
if not current:
|
2276 |
print(f"Erreur: Il n'y a pas de fichier dans le répertoire.")
|
2277 |
-
return no_update
|
2278 |
if not num:
|
2279 |
print(f"Erreur: Il n'y a pas de nombre de BCC à générer.")
|
2280 |
-
return no_update
|
2281 |
|
2282 |
current_url = current
|
2283 |
|
2284 |
print(f"Fichier Maquette sélectionné: {current_url}")
|
2285 |
|
2286 |
-
agent = init_agent_state(current_url, num,
|
2287 |
try:
|
2288 |
df = agent[0]
|
2289 |
result = agent[1]
|
2290 |
-
return html.Div(children=[dbc.Table.from_dataframe(df[["diplome", "RNCP", "Année d'étude", "Semestre", "BCC", "UE", "ECUE","exemple_situation_apprentissage"]], striped=True, bordered=True, hover=True, index=False), dcc.Markdown(f"""{result}""", style={"color":"white","font-size":"0.75rem"})])
|
2291 |
except:
|
2292 |
-
return html.Div(dcc.Markdown(f"""{agent}""", style={"color":"white","font-size":"0.75rem"}))
|
2293 |
-
|
2294 |
-
clientside_callback(
|
2295 |
-
"""connected => !connected""",
|
2296 |
-
Output("submit-button", "disabled"),
|
2297 |
-
Input("socketio", "connected"),
|
2298 |
-
)
|
2299 |
-
|
2300 |
-
clientside_callback(
|
2301 |
-
"""(notification) => {
|
2302 |
-
if (!notification) return dash_clientside.no_update
|
2303 |
-
return notification
|
2304 |
-
}""",
|
2305 |
-
Output("notification_wrapper", "children", allow_duplicate=True),
|
2306 |
-
Input("socketio", "data-notification"),
|
2307 |
-
prevent_initial_call=True,
|
2308 |
-
)
|
2309 |
-
|
2310 |
-
clientside_callback(
|
2311 |
-
"""(word, text) => text + word""",
|
2312 |
-
Output("output-response", "children", allow_duplicate=True),
|
2313 |
-
Input("socketio", "data-stream"),
|
2314 |
-
State("output-response", "children"),
|
2315 |
-
prevent_initial_call=True,
|
2316 |
-
)
|
2317 |
-
|
2318 |
-
clientside_callback(
|
2319 |
-
"""connected => !connected""",
|
2320 |
-
Output("submit-button-avid", "disabled"),
|
2321 |
-
Input("socketio-avid", "connected"),
|
2322 |
-
)
|
2323 |
-
|
2324 |
-
clientside_callback(
|
2325 |
-
"""(notification) => {
|
2326 |
-
if (!notification) return dash_clientside.no_update
|
2327 |
-
return notification
|
2328 |
-
}""",
|
2329 |
-
Output("notification_wrapper-avid", "children", allow_duplicate=True),
|
2330 |
-
Input("socketio-avid", "data-notification"),
|
2331 |
-
prevent_initial_call=True,
|
2332 |
-
)
|
2333 |
-
|
2334 |
-
clientside_callback(
|
2335 |
-
"""(word, text) => text + word""",
|
2336 |
-
Output("output-response-avid", "children", allow_duplicate=True),
|
2337 |
-
Input("socketio-avid", "data-stream"),
|
2338 |
-
State("output-response-avid", "children"),
|
2339 |
-
prevent_initial_call=True,
|
2340 |
-
)
|
2341 |
|
2342 |
if __name__ == '__main__':
|
2343 |
app.run_server(debug=True)
|
|
|
26 |
from langchain_openai import ChatOpenAI
|
27 |
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage
|
28 |
|
|
|
29 |
import dash
|
30 |
from dash.dependencies import Input, Output, State
|
31 |
from dash import Dash, html, dcc, callback, callback_context, ctx, Output, Input, dash_table, State, no_update, _dash_renderer, clientside_callback
|
32 |
from dash import html
|
33 |
|
|
|
34 |
import dash_bootstrap_components as dbc
|
35 |
from dash.exceptions import PreventUpdate
|
36 |
import dash_mantine_components as dmc
|
|
|
38 |
_dash_renderer._set_react_version("18.2.0")
|
39 |
import flask
|
40 |
from flask_login import LoginManager, UserMixin, login_user, current_user, login_required, logout_user
|
|
|
41 |
from datetime import timedelta
|
42 |
|
43 |
from IPython.display import display, HTML
|
|
|
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
|
|
|
622 |
if task == "load_and_preprocess":
|
623 |
if key == "current_file":
|
624 |
result += f"Traitement du fichier {taskInfo['current_file']} en cours...\n"
|
|
|
|
|
625 |
if task == "classify_teachings":
|
626 |
if key == "status":
|
627 |
for key, value in taskInfo['classified_teachings'].items():
|
628 |
result += f"\n\n-**Enseignement classé dans la catégorie '{key}'** : "
|
|
|
|
|
629 |
for enseignement in value:
|
630 |
result += f"{enseignement}, "
|
|
|
|
|
631 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
|
|
|
|
632 |
if task == "create_categories":
|
633 |
if key == "status":
|
634 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
|
|
|
|
635 |
if task == "create_learning_situations":
|
636 |
if key == "status":
|
637 |
if taskInfo['learning_situations'].items():
|
638 |
for key, value in taskInfo['learning_situations'].items():
|
639 |
result += f"\n\n-**Situation d'apprentissage créée pour la catégorie '{key}'** : {value}\n"
|
|
|
|
|
640 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
|
|
|
|
641 |
else:
|
642 |
result += f"\n\nTraitement de la tâche : pas de situations d'apprentissage créées\n"
|
|
|
|
|
643 |
if task == "create_academic_competencies":
|
644 |
if key == "dataframe":
|
645 |
df = taskInfo['dataframe']
|
646 |
if key == "status":
|
647 |
if taskInfo['academic_competencies'].items():
|
648 |
for key, value in taskInfo['academic_competencies'].items():
|
649 |
+
result += f"\n\n-**Compétence académique créée pour la catégorie '{key}'** : {value}\n"
|
|
|
|
|
650 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
|
|
|
|
651 |
else:
|
652 |
result += f"\n\nTraitement de la tâche : pas de BCC créés\n"
|
|
|
|
|
653 |
if task == "export_to_excel_2":
|
654 |
if key == "status":
|
655 |
result += f"\n\nTraitement de la tâche : {taskInfo['status']}...\n"
|
|
|
|
|
656 |
|
657 |
except Exception as e:
|
658 |
print(f"Erreur lors de l'exécution du workflow: {e}")
|
|
|
774 |
update_title='Chargement...',
|
775 |
suppress_callback_exceptions=True)
|
776 |
|
|
|
777 |
# Updating the Flask Server configuration with Secret Key to encrypt the user session cookie
|
778 |
server.config['REMEMBER_COOKIE_DURATION'] = timedelta(seconds=3600)
|
779 |
|
|
|
1106 |
className="g-0"
|
1107 |
),
|
1108 |
html.H4(id="text-enseignement-dropdown", className="mb-3 text-success", style={"font-size": "0.7rem"}),
|
1109 |
+
dcc.Loading(dbc.Textarea(id="enseignement-dropdown", className="mb-3", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),),
|
1110 |
], md=6),
|
1111 |
dbc.Col([
|
1112 |
dbc.Row(
|
|
|
1120 |
className="g-0"
|
1121 |
),
|
1122 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
1123 |
+
dcc.Loading(dbc.Textarea(id="classification-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),),
|
1124 |
], md=6)
|
1125 |
]),
|
1126 |
dbc.Row([
|
|
|
1136 |
className="g-0"
|
1137 |
),
|
1138 |
html.H4("Choisir d'abord une maquette de formation avec propositions BCC", className="mb-3", style={"font-size": "0.7rem"}),
|
1139 |
+
dcc.Loading(dbc.Textarea(id="situation-dropdown", className="mb-3", placeholder="Choisir d'abord une maquette avec propositions BCC", style={"height":"200px", "max-height":"250px", "font-size": "0.75rem","color":"white","border":"border 1px solid rgb(67,167,255)!important", "background-color":"transparent"}),),
|
1140 |
], md=6),
|
1141 |
dbc.Col([
|
1142 |
dbc.Row(
|
|
|
1264 |
align="left",
|
1265 |
className="g-0"
|
1266 |
),
|
1267 |
+
dcc.Loading(html.Div(id='output-response', style={"color":"rgb(90, 242, 156)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(90, 242, 156, 0.2)","padding":"5px"}),),
|
1268 |
+
|
|
|
1269 |
], width=12)
|
1270 |
])
|
1271 |
], className="mt-5")],
|
|
|
1646 |
align="left",
|
1647 |
className="g-0"
|
1648 |
),
|
1649 |
+
dcc.Loading(html.Div(id='output-response-avid', style={"color":"rgb(156, 242, 242)","border-radius":"3px","border":"1px solid rgb(255,255,255)!important","background-color":"rgba(156, 242, 242, 0.2)","padding":"5px"}),),
|
1650 |
+
|
|
|
1651 |
], width=12)
|
1652 |
])
|
1653 |
], className="mt-5")],
|
|
|
2185 |
# You could also return a 404 "URL not found" page here
|
2186 |
return view, url
|
2187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2188 |
@callback(
|
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 |
|
2200 |
if not current:
|
2201 |
print(f"Erreur: Il n'y a pas de fichier dans le répertoire.")
|
2202 |
+
return no_update
|
2203 |
if not num:
|
2204 |
print(f"Erreur: Il n'y a pas de nombre de BCC à générer.")
|
2205 |
+
return no_update
|
2206 |
|
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]
|
2214 |
+
return html.Div(children=[dbc.Table.from_dataframe(df[["diplome", "RNCP", "Année d'étude", "Semestre", "BCC", "UE", "ECUE","exemple_situation_apprentissage"]], striped=True, bordered=True, hover=True, index=False), dcc.Markdown(f"""{result}""", style={"color":"white","font-size":"0.75rem"})])
|
2215 |
except:
|
2216 |
+
return html.Div(dcc.Markdown(f"""{agent}""", style={"color":"white","font-size":"0.75rem"}))
|
2217 |
|
2218 |
@callback(
|
2219 |
Output("output-response-avid", "children"),
|
|
|
2220 |
Input("num-bcc-avid", "value"),
|
2221 |
Input("maquette-dropdown-avid", "value"),
|
2222 |
Input("submit-button-avid", "n_clicks"),
|
|
|
2223 |
State("url", "pathname"),
|
|
|
2224 |
prevent_initial_call=True,
|
2225 |
)
|
2226 |
+
def display_status(num, current, n_clicks, pathname):
|
2227 |
+
if not n_clicks:
|
2228 |
+
return no_update
|
2229 |
|
2230 |
if not current:
|
2231 |
print(f"Erreur: Il n'y a pas de fichier dans le répertoire.")
|
2232 |
+
return no_update
|
2233 |
if not num:
|
2234 |
print(f"Erreur: Il n'y a pas de nombre de BCC à générer.")
|
2235 |
+
return no_update
|
2236 |
|
2237 |
current_url = current
|
2238 |
|
2239 |
print(f"Fichier Maquette sélectionné: {current_url}")
|
2240 |
|
2241 |
+
agent = init_agent_state(current_url, num, pathname)
|
2242 |
try:
|
2243 |
df = agent[0]
|
2244 |
result = agent[1]
|
2245 |
+
return html.Div(children=[dbc.Table.from_dataframe(df[["diplome", "RNCP", "Année d'étude", "Semestre", "BCC", "UE", "ECUE","exemple_situation_apprentissage"]], striped=True, bordered=True, hover=True, index=False), dcc.Markdown(f"""{result}""", style={"color":"white","font-size":"0.75rem"})])
|
2246 |
except:
|
2247 |
+
return html.Div(dcc.Markdown(f"""{agent}""", style={"color":"white","font-size":"0.75rem"}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2248 |
|
2249 |
if __name__ == '__main__':
|
2250 |
app.run_server(debug=True)
|