File size: 3,747 Bytes
efa9b10
e798441
 
 
68bf5c0
56f5312
efa9b10
 
f02448c
 
 
 
efa9b10
 
 
 
 
 
6fdd23e
efa9b10
 
6fdd23e
efa9b10
 
 
 
 
 
6fdd23e
 
2b6d359
 
f02448c
 
 
2b6d359
 
56f5312
 
 
 
 
 
 
 
 
 
 
 
 
 
efa9b10
 
6fdd23e
efa9b10
 
 
f02448c
56f5312
6fdd23e
56f5312
6fdd23e
56f5312
6fdd23e
56f5312
83736e3
56f5312
 
 
 
 
 
f02448c
efa9b10
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import gradio as gr
from scrape_3gpp import *
from excel_chat import *
from classification import *
from chart_generation import *
from charts_advanced import *


# def update_label(label1):
#     return gr.update(choices=list(df.columns))


with gr.Blocks() as demo:
    gr.Markdown("## Extaction, Classification and AI tool")
    with gr.Tab("File extraction"):
        gr.Markdown(" Put either just a link, or a link and an excel file with an 'Actions' column")
        tb_url = gr.Textbox(label="URL (e.g. https://www.3gpp.org/ftp/TSG_SA/WG1_Serv/TSGS1_105_Athens/Docs)")
        btn_extract = gr.Button("Extract excel from URL")
        tb_status_message = gr.Textbox(label="Status")

    with gr.Tab("Query on columns with mistral"):
        dd_source_ask = gr.Dropdown(label="Source Column(s)", multiselect=True)
        tb_destcol = gr.Textbox(label="Destination column label (e.g. Summary, ELI5, PAB)")
        tb_prompt = gr.Textbox(label="Prompt")
        tb_filename = gr.Textbox(label="Specific File Name (Optional)")
        mist_button = gr.Button("Ask AI")
            
    with gr.Tab("Classification by topic"):
        dd_source_class = gr.Dropdown(label="Source Column(s)", multiselect=False)
        btn_classif = gr.Button("Categorize")

    with gr.Tab("Charts Generation"):
        with gr.Row():
            dd_label1 = gr.Dropdown(label="Source Column", multiselect=False)
            dd_label2 = gr.Dropdown(label="Source Column", multiselect=False)
        btn_chart = gr.Button("Generate Bar Plot")
        plt_figure = gr.Plot()

    with gr.Tab("Chart Generation"):
        with gr.Tab("Overall"):
            btn_overall = gr.Button("Overall Review")              
        with gr.Tab("By Expert"):
            rd_exp=gr.Radio(["Satellite Networks / Nicolas", "Emergency Communication / Dorin", "Trend Analysis / Ly-Thanh", "Security Trust / Mireille", "Distributed Networks / Guillaume", "Network Security / Khawla", "USIM Management / Vincent", "Eco-Design / Pierre"], label="Expert Name")
            btn_expert = gr.Button("Top 10 by expert")
        with gr.Tab("By Company"):
            tb_com=gr.Textbox(label="Company Name",info="You can write 1, 2 or 3 company names at the same time")
            btn_type = gr.Button("Document type by company")
        with gr.Row():
            plt_chart = gr.Plot(label="Graphique")
            plt_chart2 = gr.Plot(label="Graphique")
            plt_chart3 = gr.Plot(label="Graphique")
        
    with gr.Accordion("Excel Preview", open=False):
        df_output = gr.DataFrame()
        
    fi_excel = gr.File(label="Excel File")

    fi_excel.change(get_columns, inputs=[fi_excel], outputs=[dd_source_ask, dd_source_class, dd_label1, dd_label2, df_output])
    
    btn_extract.click(extractionPrincipale, inputs=[tb_url, fi_excel], outputs=[fi_excel, tb_status_message])
    
    mist_button.click(chat_with_mistral, inputs=[dd_source_ask, tb_destcol, tb_prompt, tb_filename, fi_excel, tb_url], outputs=[fi_excel, df_output])
    
    btn_classif.click(classification, inputs=[dd_source_class, fi_excel], outputs=[fi_excel, df_output])
    
    btn_chart.click(create_bar_plot, inputs=[fi_excel, dd_label1, dd_label2], outputs=[plt_figure])
    
    btn_overall.click(generate_company_chart,inputs=[fi_excel], outputs=[plt_chart])
    btn_overall.click(status_chart,inputs=[fi_excel], outputs=[plt_chart2])
    btn_overall.click(category_chart,inputs=[fi_excel], outputs=[plt_chart3])
    btn_expert.click(chart_by_expert,inputs=[fi_excel,rd_exp], outputs=[plt_chart])
    btn_type.click(company_document_type,inputs=[fi_excel,tb_com], outputs=[plt_chart])
    # dd_label1.change(update_label, inputs=[dd_label1], outputs=[dd_label2])


demo.launch(debug=True)