Update app.py
Browse files
app.py
CHANGED
@@ -217,10 +217,10 @@ def Chat_Message(history, messages1):
|
|
217 |
for character in response.content:
|
218 |
history[-1][1] += character
|
219 |
time.sleep(0.0025)
|
220 |
-
yield history
|
221 |
-
|
222 |
|
223 |
-
def Internet_Search(history):
|
224 |
messages2 = gr.State(messages1_state)
|
225 |
|
226 |
message=history[-1][0]
|
@@ -254,9 +254,9 @@ def Internet_Search(history):
|
|
254 |
for character in response.content:
|
255 |
history[-1][1] += character
|
256 |
time.sleep(0.0025)
|
257 |
-
yield history
|
258 |
|
259 |
-
def Chart_Generator(history):
|
260 |
messages3 = gr.State(messages1_state)
|
261 |
|
262 |
message = history[-1][0]
|
@@ -298,9 +298,9 @@ def Chart_Generator(history):
|
|
298 |
for character in combined_content:
|
299 |
history[-1][1] += character
|
300 |
time.sleep(0.0025)
|
301 |
-
yield history
|
302 |
|
303 |
-
def Link_Scratch(history):
|
304 |
messages4 = gr.State(messages1_state)
|
305 |
|
306 |
combined_message = history[-1][0]
|
@@ -347,7 +347,7 @@ def Link_Scratch(history):
|
|
347 |
for character in response_message:
|
348 |
history[-1][1] += character
|
349 |
time.sleep(0.0025)
|
350 |
-
yield history
|
351 |
|
352 |
def insert_line_breaks(text, every=8):
|
353 |
return '\n'.join(text[i:i+every] for i in range(0, len(text), every))
|
@@ -363,7 +363,7 @@ def display_file_name(file):
|
|
363 |
else:
|
364 |
raise gr.Error("( Supported File Types Only : PDF , CSV , TXT , DOCX , PPTX , XLSX , JSON , HTML , XML )")
|
365 |
|
366 |
-
def File_Interact(history,filepath):
|
367 |
messages5 = gr.State(messages1_state)
|
368 |
|
369 |
combined_message = history[-1][0]
|
@@ -406,9 +406,9 @@ def File_Interact(history,filepath):
|
|
406 |
for character in response_message:
|
407 |
history[-1][1] += character
|
408 |
time.sleep(0.0025)
|
409 |
-
yield history
|
410 |
|
411 |
-
def Explore_WebSite(history):
|
412 |
messages6 = gr.State(messages1_state)
|
413 |
|
414 |
message=history[-1][0]
|
@@ -443,7 +443,7 @@ def Explore_WebSite(history):
|
|
443 |
for character in response.content:
|
444 |
history[-1][1] += character
|
445 |
time.sleep(0.0025)
|
446 |
-
yield history
|
447 |
|
448 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
449 |
with gr.Row():
|
@@ -470,6 +470,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
470 |
chatbot.like(print_like_dislike, None, None)
|
471 |
|
472 |
with gr.Tab("Internet-Search"):
|
|
|
473 |
chatbot = gr.Chatbot(
|
474 |
[],
|
475 |
elem_id="chatbot",
|
@@ -483,11 +484,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
483 |
|
484 |
clear = gr.ClearButton([msg, chatbot])
|
485 |
|
486 |
-
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, chatbot, chatbot)
|
487 |
-
submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, chatbot, chatbot)
|
488 |
chatbot.like(print_like_dislike, None, None)
|
489 |
|
490 |
with gr.Tab("Chart-Generator"):
|
|
|
491 |
chatbot = gr.Chatbot(
|
492 |
[],
|
493 |
elem_id="chatbot",
|
@@ -502,11 +504,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
502 |
|
503 |
clear = gr.ClearButton([msg, chatbot])
|
504 |
|
505 |
-
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, chatbot, chatbot)
|
506 |
-
submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, chatbot, chatbot)
|
507 |
chatbot.like(print_like_dislike, None, None)
|
508 |
|
509 |
with gr.Tab("Link-Scratch"):
|
|
|
510 |
chatbot = gr.Chatbot(
|
511 |
[],
|
512 |
elem_id="chatbot",
|
@@ -522,12 +525,13 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
522 |
|
523 |
clear = gr.ClearButton([msg2, chatbot, msg1])
|
524 |
|
525 |
-
msg1.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, chatbot, chatbot)
|
526 |
-
msg2.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, chatbot, chatbot)
|
527 |
-
submit.click(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, chatbot, chatbot)
|
528 |
chatbot.like(print_like_dislike, None, None)
|
529 |
|
530 |
with gr.Tab("File-Interact"):
|
|
|
531 |
chatbot = gr.Chatbot(
|
532 |
[],
|
533 |
elem_id="chatbot",
|
@@ -547,11 +551,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
547 |
|
548 |
filepath.upload(display_file_name, inputs=filepath, outputs=file_output)
|
549 |
|
550 |
-
msg.submit(user3, [msg, chatbot, file_output], [msg, chatbot, file_output], queue=True).then(File_Interact, [chatbot, filepath],chatbot)
|
551 |
-
submit.click(user3, [msg, chatbot, file_output], [msg, chatbot, file_output], queue=True).then(File_Interact, [chatbot, filepath],chatbot)
|
552 |
chatbot.like(print_like_dislike, None, None)
|
553 |
|
554 |
with gr.Tab("Explore-WebSite"):
|
|
|
555 |
chatbot = gr.Chatbot(
|
556 |
[],
|
557 |
elem_id="chatbot",
|
@@ -565,8 +570,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
565 |
|
566 |
clear = gr.ClearButton([msg, chatbot])
|
567 |
|
568 |
-
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, chatbot, chatbot)
|
569 |
-
submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, chatbot, chatbot)
|
570 |
chatbot.like(print_like_dislike, None, None)
|
571 |
|
572 |
demo.queue(max_size=10, default_concurrency_limit=4)
|
|
|
217 |
for character in response.content:
|
218 |
history[-1][1] += character
|
219 |
time.sleep(0.0025)
|
220 |
+
yield history
|
221 |
+
yield messages1
|
222 |
|
223 |
+
def Internet_Search(history, messages2):
|
224 |
messages2 = gr.State(messages1_state)
|
225 |
|
226 |
message=history[-1][0]
|
|
|
254 |
for character in response.content:
|
255 |
history[-1][1] += character
|
256 |
time.sleep(0.0025)
|
257 |
+
yield history, messages2
|
258 |
|
259 |
+
def Chart_Generator(history, messages3):
|
260 |
messages3 = gr.State(messages1_state)
|
261 |
|
262 |
message = history[-1][0]
|
|
|
298 |
for character in combined_content:
|
299 |
history[-1][1] += character
|
300 |
time.sleep(0.0025)
|
301 |
+
yield history, messages3
|
302 |
|
303 |
+
def Link_Scratch(history, messages4):
|
304 |
messages4 = gr.State(messages1_state)
|
305 |
|
306 |
combined_message = history[-1][0]
|
|
|
347 |
for character in response_message:
|
348 |
history[-1][1] += character
|
349 |
time.sleep(0.0025)
|
350 |
+
yield history, messages4
|
351 |
|
352 |
def insert_line_breaks(text, every=8):
|
353 |
return '\n'.join(text[i:i+every] for i in range(0, len(text), every))
|
|
|
363 |
else:
|
364 |
raise gr.Error("( Supported File Types Only : PDF , CSV , TXT , DOCX , PPTX , XLSX , JSON , HTML , XML )")
|
365 |
|
366 |
+
def File_Interact(history, filepath, messages5):
|
367 |
messages5 = gr.State(messages1_state)
|
368 |
|
369 |
combined_message = history[-1][0]
|
|
|
406 |
for character in response_message:
|
407 |
history[-1][1] += character
|
408 |
time.sleep(0.0025)
|
409 |
+
yield history, messages5
|
410 |
|
411 |
+
def Explore_WebSite(history, messages6):
|
412 |
messages6 = gr.State(messages1_state)
|
413 |
|
414 |
message=history[-1][0]
|
|
|
443 |
for character in response.content:
|
444 |
history[-1][1] += character
|
445 |
time.sleep(0.0025)
|
446 |
+
yield history, messages6
|
447 |
|
448 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
449 |
with gr.Row():
|
|
|
470 |
chatbot.like(print_like_dislike, None, None)
|
471 |
|
472 |
with gr.Tab("Internet-Search"):
|
473 |
+
messages2=gr.State(messages1_state)
|
474 |
chatbot = gr.Chatbot(
|
475 |
[],
|
476 |
elem_id="chatbot",
|
|
|
484 |
|
485 |
clear = gr.ClearButton([msg, chatbot])
|
486 |
|
487 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, [chatbot,messages2], [chatbot,messages2])
|
488 |
+
submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, [chatbot,messages2], [chatbot,messages2])
|
489 |
chatbot.like(print_like_dislike, None, None)
|
490 |
|
491 |
with gr.Tab("Chart-Generator"):
|
492 |
+
messages3=gr.State(messages1_state)
|
493 |
chatbot = gr.Chatbot(
|
494 |
[],
|
495 |
elem_id="chatbot",
|
|
|
504 |
|
505 |
clear = gr.ClearButton([msg, chatbot])
|
506 |
|
507 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, [chatbot,messages3], [chatbot,messages3])
|
508 |
+
submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, [chatbot,messages3], [chatbot,messages3])
|
509 |
chatbot.like(print_like_dislike, None, None)
|
510 |
|
511 |
with gr.Tab("Link-Scratch"):
|
512 |
+
messages4=gr.State(messages1_state)
|
513 |
chatbot = gr.Chatbot(
|
514 |
[],
|
515 |
elem_id="chatbot",
|
|
|
525 |
|
526 |
clear = gr.ClearButton([msg2, chatbot, msg1])
|
527 |
|
528 |
+
msg1.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, [chatbot,messages4], [chatbot,messages4])
|
529 |
+
msg2.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, [chatbot,messages4], [chatbot,messages4])
|
530 |
+
submit.click(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, [chatbot,messages4], [chatbot,messages4])
|
531 |
chatbot.like(print_like_dislike, None, None)
|
532 |
|
533 |
with gr.Tab("File-Interact"):
|
534 |
+
messages5=gr.State(messages1_state)
|
535 |
chatbot = gr.Chatbot(
|
536 |
[],
|
537 |
elem_id="chatbot",
|
|
|
551 |
|
552 |
filepath.upload(display_file_name, inputs=filepath, outputs=file_output)
|
553 |
|
554 |
+
msg.submit(user3, [msg, chatbot, file_output], [msg, chatbot, file_output], queue=True).then(File_Interact, [chatbot, filepath, messages5],[chatbot, messages5])
|
555 |
+
submit.click(user3, [msg, chatbot, file_output], [msg, chatbot, file_output], queue=True).then(File_Interact, [chatbot, filepath, messages5],[chatbot, messages5])
|
556 |
chatbot.like(print_like_dislike, None, None)
|
557 |
|
558 |
with gr.Tab("Explore-WebSite"):
|
559 |
+
messages6=gr.State(messages1_state)
|
560 |
chatbot = gr.Chatbot(
|
561 |
[],
|
562 |
elem_id="chatbot",
|
|
|
570 |
|
571 |
clear = gr.ClearButton([msg, chatbot])
|
572 |
|
573 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, [chatbot, messages6], [chatbot, messages6])
|
574 |
+
submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, [chatbot, messages6], [chatbot, messages6])
|
575 |
chatbot.like(print_like_dislike, None, None)
|
576 |
|
577 |
demo.queue(max_size=10, default_concurrency_limit=4)
|