import gradio as gr import pandas as pd # Exemple de données d'historique historique_data = pd.DataFrame({ "Opération": ["Ajout", "Suppression", "Mise à jour"], "Date": ["2025-09-17", "2025-09-16", "2025-09-15"] }) # Exemple de résultats avec scores resultats = [("Alice", 95), ("Bob", 87), ("Charlie", 78)] def get_historique(): return historique_data def get_resultats(): return "\n".join([f"{nom}: {score}" for nom, score in resultats]) # Chatbot : simple écho def chatbot(message, history): history.append(("Vous: " + message, "Bot: " + message[::-1])) return history, history def get_historique(file): """Renvoie le contenu du fichier csv passé en argument""" try: data = pd.read_csv(file) return data except pd.errors.EmptyDataError: return pd.DataFrame() with gr.Blocks() as demo: with gr.Row(): with gr.Column(): gr.Label("Historique des opérations") historique = gr.Dataframe(value=historique_data, interactive=False) with gr.Column(): gr.Label("Résultat") resultats_box = gr.Textbox(value=get_resultats(), lines=6, interactive=False) chatbot_ui = gr.Chatbot(label="ChatBot") msg = gr.Textbox(placeholder="Écrivez un message...") clear = gr.Button("Effacer") msg.submit(chatbot, [msg, chatbot_ui], [chatbot_ui, chatbot_ui]) clear.click(lambda: None, None, chatbot_ui, queue=False) demo.launch()