YchKhan's picture
Update app.py
fd9e955 verified
raw
history blame
1.76 kB
import gradio as gr
from scrape_3gpp import *
from excel_chat import *
from classification import *
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.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, 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])
demo.launch(debug=True)