Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -112,9 +112,11 @@ df_cate = pd.DataFrame(categories)
|
|
112 |
|
113 |
### Functions needed for Split Files
|
114 |
|
115 |
-
def functionCall(fi_input, dropdown, choice):
|
116 |
if choice == "Intelligent split":
|
117 |
return split_in_df(fi_input)
|
|
|
|
|
118 |
else:
|
119 |
return split_by_keywords(fi_input,dropdown)
|
120 |
|
@@ -122,9 +124,11 @@ def change_textbox(dropdown,radio):
|
|
122 |
if len(dropdown) == 0 :
|
123 |
dropdown = ["introduction", "objective", "summary", "conclusion"]
|
124 |
if radio == "Intelligent split by keywords":
|
125 |
-
return gr.Dropdown(dropdown, multiselect=True, visible=True, allow_custom_value=True)
|
|
|
|
|
126 |
else:
|
127 |
-
return gr.Dropdown(dropdown,
|
128 |
|
129 |
### Split files end
|
130 |
|
@@ -222,11 +226,13 @@ with gr.Blocks() as demo:
|
|
222 |
with gr.Tab("Split Files"):
|
223 |
gr.Markdown("### Upload your standard documentation (pdf, doc, docx) to split it into paragraphs in an Excel file")
|
224 |
radio = gr.Radio(
|
225 |
-
["Intelligent split", "Intelligent split by keywords"], label="Choose your selection", value = "Intelligent split"
|
226 |
)
|
227 |
dropdown_split = gr.Dropdown(["introduction", "objective", "conclusion", "summary"], multiselect=True, visible=False, allow_custom_value=True, label="Select or add keywords")
|
|
|
228 |
|
229 |
fi_input = gr.File(file_count='multiple')
|
|
|
230 |
|
231 |
with gr.Tab("Ask LLM"):
|
232 |
gr.Markdown("### This section utilizes Large Language Models (LLMs) to query rows in an Excel file")
|
@@ -323,8 +329,9 @@ with gr.Blocks() as demo:
|
|
323 |
|
324 |
# Split files
|
325 |
#fi_input.upload(split_in_df, inputs=fi_input, outputs=fi_excel)
|
326 |
-
fi_input.upload(functionCall, inputs=[fi_input, dropdown_split, radio], outputs=fi_excel)
|
327 |
-
|
|
|
328 |
|
329 |
#llm
|
330 |
mist_button.click(chat_with_mistral, inputs=[dd_source_ask, tb_destcol, dd_prompt, fi_excel, dd_url, dd_searchcol, dd_keywords, dd_llm, st_user], outputs=[fi_excel, df_output, dd_prompt, dd_keywords, st_user, fi_config])
|
|
|
112 |
|
113 |
### Functions needed for Split Files
|
114 |
|
115 |
+
def functionCall(fi_input, dropdown, choice, chunk_size):
|
116 |
if choice == "Intelligent split":
|
117 |
return split_in_df(fi_input)
|
118 |
+
elif choice == "Non intelligent split":
|
119 |
+
return non_intelligent_split(fi_input, chunk_size)
|
120 |
else:
|
121 |
return split_by_keywords(fi_input,dropdown)
|
122 |
|
|
|
124 |
if len(dropdown) == 0 :
|
125 |
dropdown = ["introduction", "objective", "summary", "conclusion"]
|
126 |
if radio == "Intelligent split by keywords":
|
127 |
+
return gr.Dropdown(dropdown, multiselect=True, visible=True, allow_custom_value=True), gr.Number(visible=False)
|
128 |
+
elif radio == "Non intelligent split":
|
129 |
+
return gr.Dropdown(dropdown, visible=False),gr.Number(label="Chunk size", value=1000, interactive=True, visible=True)
|
130 |
else:
|
131 |
+
return gr.Dropdown(dropdown, visible=False),gr.Number(visible=False)
|
132 |
|
133 |
### Split files end
|
134 |
|
|
|
226 |
with gr.Tab("Split Files"):
|
227 |
gr.Markdown("### Upload your standard documentation (pdf, doc, docx) to split it into paragraphs in an Excel file")
|
228 |
radio = gr.Radio(
|
229 |
+
["Intelligent split", "Intelligent split by keywords", "Non intelligent split"], label="Choose your selection", value = "Intelligent split"
|
230 |
)
|
231 |
dropdown_split = gr.Dropdown(["introduction", "objective", "conclusion", "summary"], multiselect=True, visible=False, allow_custom_value=True, label="Select or add keywords")
|
232 |
+
nb_split = gr.Number(label="Chunk size", value=1000, interactive=True, visible=False)
|
233 |
|
234 |
fi_input = gr.File(file_count='multiple')
|
235 |
+
btn_split = gr.Button("Split")
|
236 |
|
237 |
with gr.Tab("Ask LLM"):
|
238 |
gr.Markdown("### This section utilizes Large Language Models (LLMs) to query rows in an Excel file")
|
|
|
329 |
|
330 |
# Split files
|
331 |
#fi_input.upload(split_in_df, inputs=fi_input, outputs=fi_excel)
|
332 |
+
fi_input.upload(functionCall, inputs=[fi_input, dropdown_split, radio, nb_split], outputs=fi_excel)
|
333 |
+
btn_split.click(functionCall, inputs=[fi_input, dropdown_split, radio, nb_split], outputs=fi_excel)
|
334 |
+
radio.change(fn=change_textbox, inputs=[dropdown_split,radio], outputs=[dropdown_split, nb_split])
|
335 |
|
336 |
#llm
|
337 |
mist_button.click(chat_with_mistral, inputs=[dd_source_ask, tb_destcol, dd_prompt, fi_excel, dd_url, dd_searchcol, dd_keywords, dd_llm, st_user], outputs=[fi_excel, df_output, dd_prompt, dd_keywords, st_user, fi_config])
|