Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -239,6 +239,10 @@ def display_docs_modal(docs):
|
|
| 239 |
return output_list
|
| 240 |
|
| 241 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
def ask_llm(system, user_input):
|
| 243 |
messages = [
|
| 244 |
{
|
|
@@ -324,38 +328,38 @@ def auth_user(ui_session_id):
|
|
| 324 |
|
| 325 |
def display_info0(documents):
|
| 326 |
try:
|
| 327 |
-
return gr.Markdown(value=documents.split("\n*§*§*\n")[0], label='Source', visible=True)
|
| 328 |
except Exception as e:
|
| 329 |
gr.Info("No Document")
|
| 330 |
-
return gr.Markdown(label='Source', visible=False)
|
| 331 |
|
| 332 |
def display_info1(documents):
|
| 333 |
try:
|
| 334 |
-
return gr.Markdown(value=documents.split("\n*§*§*\n")[1], label='Source', visible=True)
|
| 335 |
except Exception as e:
|
| 336 |
gr.Info("No Document")
|
| 337 |
-
return gr.Markdown(label='Source', visible=False)
|
| 338 |
|
| 339 |
def display_info2(documents):
|
| 340 |
try:
|
| 341 |
-
return gr.Markdown(value=documents.split("\n*§*§*\n")[2], label='Source', visible=True)
|
| 342 |
except Exception as e:
|
| 343 |
gr.Info("No Document")
|
| 344 |
-
return gr.Markdown(label='Source', visible=False)
|
| 345 |
|
| 346 |
def display_info3(documents):
|
| 347 |
try:
|
| 348 |
-
return gr.Markdown(value=documents.split("\n*§*§*\n")[3], label='Source', visible=True)
|
| 349 |
except Exception as e:
|
| 350 |
gr.Info("No Document")
|
| 351 |
-
return gr.Markdown(label='Source', visible=False)
|
| 352 |
|
| 353 |
def display_info4(documents):
|
| 354 |
try:
|
| 355 |
-
return gr.Markdown(value=documents.split("\n*§*§*\n")[4], label='Source', visible=True)
|
| 356 |
except Exception as e:
|
| 357 |
gr.Info("No Document")
|
| 358 |
-
return gr.Markdown(label='Source', visible=False)
|
| 359 |
|
| 360 |
with gr.Blocks() as demo:
|
| 361 |
gr.Markdown("# Enrich an LLM knowledge with your own documents 🧠🤖")
|
|
@@ -373,6 +377,7 @@ with gr.Blocks() as demo:
|
|
| 373 |
with gr.Row():
|
| 374 |
query_input = gr.Textbox(placeholder="Type your question", label="Question ❔", scale=9, visible=False)
|
| 375 |
btn_askGPT = gr.Button("▶", scale=1, visible=False)
|
|
|
|
| 376 |
with gr.Row():
|
| 377 |
btn1 = gr.Button("Ref 1")
|
| 378 |
btn2 = gr.Button("Ref 2")
|
|
@@ -396,11 +401,12 @@ with gr.Blocks() as demo:
|
|
| 396 |
btn_askGPT.click(ask_gpt, inputs=[query_input, tb_session_id, tb_history], outputs=[answer_output, tb_sources, tb_history])
|
| 397 |
query_input.submit(ask_gpt, inputs=[query_input, tb_session_id, tb_history], outputs=[answer_output, tb_sources, tb_history])
|
| 398 |
|
| 399 |
-
btn1.click(display_info0, inputs=tb_sources, outputs=md_ref)
|
| 400 |
-
btn2.click(display_info1, inputs=tb_sources, outputs=md_ref)
|
| 401 |
-
btn3.click(display_info2, inputs=tb_sources, outputs=md_ref)
|
| 402 |
-
btn4.click(display_info3, inputs=tb_sources, outputs=md_ref)
|
| 403 |
-
btn5.click(display_info4, inputs=tb_sources, outputs=md_ref)
|
|
|
|
| 404 |
|
| 405 |
|
| 406 |
|
|
|
|
| 239 |
return output_list
|
| 240 |
|
| 241 |
|
| 242 |
+
def hide_source():
|
| 243 |
+
return gr.Markdown(value=documents.split(label='Source', visible=False)
|
| 244 |
+
|
| 245 |
+
|
| 246 |
def ask_llm(system, user_input):
|
| 247 |
messages = [
|
| 248 |
{
|
|
|
|
| 328 |
|
| 329 |
def display_info0(documents):
|
| 330 |
try:
|
| 331 |
+
return gr.Markdown(value=documents.split("\n*§*§*\n")[0], label='Source', visible=True), gr.Button('Hide', visible=True)
|
| 332 |
except Exception as e:
|
| 333 |
gr.Info("No Document")
|
| 334 |
+
return gr.Markdown(label='Source', visible=False), gr.Button('Hide', visible=False)
|
| 335 |
|
| 336 |
def display_info1(documents):
|
| 337 |
try:
|
| 338 |
+
return gr.Markdown(value=documents.split("\n*§*§*\n")[1], label='Source', visible=True), gr.Button('Hide', visible=True)
|
| 339 |
except Exception as e:
|
| 340 |
gr.Info("No Document")
|
| 341 |
+
return gr.Markdown(label='Source', visible=False), gr.Button('Hide', visible=False)
|
| 342 |
|
| 343 |
def display_info2(documents):
|
| 344 |
try:
|
| 345 |
+
return gr.Markdown(value=documents.split("\n*§*§*\n")[2], label='Source', visible=True), gr.Button('Hide', visible=True)
|
| 346 |
except Exception as e:
|
| 347 |
gr.Info("No Document")
|
| 348 |
+
return gr.Markdown(label='Source', visible=False), gr.Button('Hide', visible=False)
|
| 349 |
|
| 350 |
def display_info3(documents):
|
| 351 |
try:
|
| 352 |
+
return gr.Markdown(value=documents.split("\n*§*§*\n")[3], label='Source', visible=True), gr.Button('Hide', visible=True)
|
| 353 |
except Exception as e:
|
| 354 |
gr.Info("No Document")
|
| 355 |
+
return gr.Markdown(label='Source', visible=False), gr.Button('Hide', visible=False)
|
| 356 |
|
| 357 |
def display_info4(documents):
|
| 358 |
try:
|
| 359 |
+
return gr.Markdown(value=documents.split("\n*§*§*\n")[4], label='Source', visible=True), gr.Button('Hide', visible=True)
|
| 360 |
except Exception as e:
|
| 361 |
gr.Info("No Document")
|
| 362 |
+
return gr.Markdown(label='Source', visible=False), gr.Button('Hide', visible=False)
|
| 363 |
|
| 364 |
with gr.Blocks() as demo:
|
| 365 |
gr.Markdown("# Enrich an LLM knowledge with your own documents 🧠🤖")
|
|
|
|
| 377 |
with gr.Row():
|
| 378 |
query_input = gr.Textbox(placeholder="Type your question", label="Question ❔", scale=9, visible=False)
|
| 379 |
btn_askGPT = gr.Button("▶", scale=1, visible=False)
|
| 380 |
+
btn_hide_source = gr.Button('Hide', visible=False)
|
| 381 |
with gr.Row():
|
| 382 |
btn1 = gr.Button("Ref 1")
|
| 383 |
btn2 = gr.Button("Ref 2")
|
|
|
|
| 401 |
btn_askGPT.click(ask_gpt, inputs=[query_input, tb_session_id, tb_history], outputs=[answer_output, tb_sources, tb_history])
|
| 402 |
query_input.submit(ask_gpt, inputs=[query_input, tb_session_id, tb_history], outputs=[answer_output, tb_sources, tb_history])
|
| 403 |
|
| 404 |
+
btn1.click(display_info0, inputs=tb_sources, outputs=[md_ref, btn_hide_source])
|
| 405 |
+
btn2.click(display_info1, inputs=tb_sources, outputs=[md_ref, btn_hide_source])
|
| 406 |
+
btn3.click(display_info2, inputs=tb_sources, outputs=[md_ref, btn_hide_source])
|
| 407 |
+
btn4.click(display_info3, inputs=tb_sources, outputs=[md_ref, btn_hide_source])
|
| 408 |
+
btn5.click(display_info4, inputs=tb_sources, outputs=[md_ref, btn_hide_source])
|
| 409 |
+
btn_hide_source.click(hide_source, inputs=None, outputs=md_ref)
|
| 410 |
|
| 411 |
|
| 412 |
|