File size: 1,474 Bytes
4032614
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
47
48
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()