File size: 9,071 Bytes
efa9b10
e798441
 
 
68bf5c0
56f5312
783a6b1
efa9b10
06cb213
def0304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f02448c
 
 
 
efa9b10
783a6b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
efa9b10
 
3b26dac
 
 
7cb2e91
 
 
 
efa9b10
3b26dac
efa9b10
7cb2e91
efa9b10
6fdd23e
efa9b10
783a6b1
2011f34
def0304
 
 
 
efa9b10
 
 
11711e5
3b26dac
 
6fdd23e
2b6d359
 
f02448c
11711e5
 
2b6d359
 
56f5312
 
3b26dac
56f5312
3b26dac
56f5312
 
 
 
 
3b26dac
56f5312
 
 
 
efa9b10
3b26dac
efa9b10
 
783a6b1
 
 
 
 
 
7cb2e91
7854dd4
 
def0304
56f5312
7cb2e91
56f5312
783a6b1
56f5312
3b26dac
56f5312
83736e3
56f5312
 
 
 
 
 
f02448c
efa9b10
724556d
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import gradio as gr
from scrape_3gpp import *
from excel_chat import *
from classification import *
from chart_generation import *
from charts_advanced import *
from users_management import *

users = load_from_json()

# Categories
categories = [
{
  "topic": "Confidentiality and Privacy Protection",
  "description": "This topic covers the protection of confidentiality, privacy, and integrity in security systems. It also includes authentication and authorization processes.",
  "experts": ["Mireille"]
},
{
  "topic": "Distributed Trust and End-User Trust Models",
  "description": "This topic focuses on distributed trust models and how end-users establish trust in secure systems.",
  "experts": ["Mireille", "Khawla"]
},
{
  "topic": "Secure Element and Key Provisioning",
  "description": "This topic involves the secure element in systems and the process of key provisioning.",
  "experts": ["Mireille"]
},
{
  "topic": "Residential Gateway Security",
  "description": "This topic covers the security aspects of Residential Gateways.",
  "experts": ["Mireille"]
},
{
  "topic": "Standalone Non-Public Network (SNPN) Inter-Connection and Cybersecurity",
  "description": "This topic focuses on the inter-connection of Standalone Non-Public Networks and related cyber-security topics.",
  "experts": ["Khawla"]
},
{
  "topic": "Distributed Ledger and Blockchain in SNPN",
  "description": "This topic covers the use of distributed ledger technology and blockchain in securing Standalone Non-Public Networks.",
  "experts": ["Khawla"]
},
{
  "topic": "Distributed Networks and Communication",
  "description": "This topic involves distributed networks such as mesh networks, ad-hoc networks, and multi-hop networks, and their cyber-security aspects.",
  "experts": ["Guillaume"]
},
{
  "topic": "Swarm of Drones and Unmanned Aerial Vehicles Network Infrastructure",
  "description": "This topic covers the network infrastructure deployed by Swarm of Drones and Unmanned Aerial Vehicles.",
  "experts": ["Guillaume"]
},
{
  "topic": "USIM and Over-the-Air Services",
  "description": "This topic involves USIM and related over-the-air services such as Steering of Roaming, roaming services, network selection, and UE configuration.",
  "experts": ["Vincent"]
},
{
  "topic": "Eco-Design and Societal Impact of Technology",
  "description": "This topic covers eco-design concepts, including energy saving, energy efficiency, carbon emissions, and the societal impact of technology.",
  "experts": ["Pierre"]
},
{
  "topic": "Service Requirements of New Services",
  "description": "This topic involves defining service requirements for new services, detecting low signals of new trends and technologies, and assessing their impact on USIM services or over-the-air services.",
  "experts": ["Ly-Thanh"]
},
{
  "topic": "Satellite and Non Terrestrial Networks",
  "description": "This topic covers satellite networks, Non Terrestrial Networks, Private Networks, IoT, Inter Satellite communication, and Radio Access Network.",
  "experts": ["Nicolas"]
},
{
  "topic": "Public Safety and Emergency Communication",
  "description": "This topic involves Public Safety Communication, Military Communication, Emergency Calls, Emergency Services, Disaster Communication Access, and other related areas.",
  "experts": ["Dorin"]
}
]

df_cate = pd.DataFrame(categories)

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


with gr.Blocks() as demo:
    
    with gr.Row():
        with gr.Column():
            gr.Markdown("## Extaction, Classification and AI tool")
        with gr.Column():
            md_username = gr.Markdown()
            btn_logout = gr.Button("Logout")
    with gr.Accordion(label="**Login** to keep user preferences", open=False):
        st_user = gr.State()
        with gr.Column():
            tb_user = gr.Textbox(label='Username')
            tb_pwd = gr.Textbox(label='Password', type='password')
        with gr.Row():
            btn_login = gr.Button('Login')

    with gr.Tab("File extraction"):
        gr.Markdown(" Put either just a link, or a link and an excel file with an 'Actions' column")
        with gr.Row():
            dd_url = gr.Dropdown(label="(e.g. https://www.3gpp.org/ftp/TSG_SA/WG1_Serv/TSGS1_105_Athens/Docs)", multiselect=False, value="https://www.3gpp.org/ftp/", allow_custom_value=True, scale=9)
            btn_search = gr.Button("Search")
        with gr.Accordion("Filter by file status", open=False):
            with gr.Row():
                dd_status =  gr.Dropdown(label="Status to look for (Optional)", allow_custom_value=True, multiselect=True, scale=7)
                btn_search_status = gr.Button("Search for status", scale=2)
        btn_extract = gr.Button("Extract excel from URL")
        tb_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)")
        dd_prompt = gr.Dropdown(label="Prompt", multiselect=False, allow_custom_value=True)
        rd_llm = gr.Radio(["Mistral", "Claude", "Groq"], label="Choose your LLM")
        with gr.Accordion("Filters", open=False):
            with gr.Row():
                dd_searchcol = gr.Dropdown(label="Column to look into (Optional)", multiselect=False, scale=4)
                dd_keywords =  gr.Dropdown(label="Words to look for (Optional)", multiselect=True, allow_custom_value=True, scale=5)
        mist_button = gr.Button("Ask AI")
            
    with gr.Tab("Classification by topic"):
        dd_source_class = gr.Dropdown(label="Source Column", multiselect=False)
        gr.Markdown("### The predefined categories can be modified at any time")
        df_category = gr.DataFrame(label='categories', value=df_cate, interactive=True)
        btn_classif = gr.Button("Categorize")

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

    with gr.Tab("Chart Generation"):
        gr.Markdown("## 🚧 Actuellement en maintenance 🚧")
        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("Company info")
        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")

    # authentication
    btn_login.click(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
    tb_pwd.submit(auth_user, inputs=[tb_user, tb_pwd], outputs=[st_user, md_username, dd_prompt, dd_keywords])
    btn_logout.click(logout, inputs=None, outputs=[st_user, md_username, dd_prompt, dd_keywords])
    

    btn_search_status.click(extract_statuses, inputs=dd_url, outputs=dd_status)
    btn_search.click(browse_folder, inputs=dd_url, outputs=dd_url)
    dd_url.change(browse_folder, inputs=dd_url, outputs=dd_url)
    fi_excel.change(get_columns, inputs=[fi_excel], outputs=[dd_source_ask, dd_source_class, dd_label1, dd_label2, dd_searchcol, df_output])
    
    btn_extract.click(extractionPrincipale, inputs=[dd_url, fi_excel, dd_status], outputs=[fi_excel, tb_message])
    
    mist_button.click(chat_with_mistral, inputs=[dd_source_ask, tb_destcol, dd_prompt, fi_excel, dd_url, dd_searchcol, dd_keywords, rd_llm, st_user], outputs=[fi_excel, df_output])
    
    btn_classif.click(classification, inputs=[dd_source_class, fi_excel, df_category], 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)