mou3az commited on
Commit
4e2df00
1 Parent(s): 1345109

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -217,7 +217,7 @@ def Chat_Message(history, messages1):
217
  for character in response.content:
218
  history[-1][1] += character
219
  time.sleep(0.0025)
220
- yield history, messages1
221
 
222
  def Internet_Search(history, messages2):
223
 
@@ -269,8 +269,8 @@ def Chart_Generator(history, messages3):
269
  prompt = HumanMessage(content=message_with_description)
270
  messages3.append(prompt)
271
 
272
- if len(messages3) >= 8:
273
- messages3 = messages3[-8:]
274
 
275
  response = chat_model.invoke(messages3)
276
  messages3.append(AIMessage(content=response.content))
@@ -459,8 +459,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
459
 
460
  clear = gr.ClearButton([msg, chatbot, messages1])
461
 
462
- msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chat_Message, [chatbot,messages1], [chatbot,messages1])
463
- submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chat_Message, [chatbot,messages1], [chatbot,messages1])
464
  chatbot.like(print_like_dislike, None, None)
465
 
466
  with gr.Tab("Internet-Search"):
@@ -476,7 +476,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
476
  msg = gr.Textbox(show_label=False, placeholder="Type a message...", scale=10, container=False)
477
  submit = gr.Button("➡️Send", scale=1)
478
 
479
- clear = gr.ClearButton([msg, chatbot])
480
 
481
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, [chatbot,messages2], [chatbot,messages2])
482
  submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, [chatbot,messages2], [chatbot,messages2])
@@ -496,7 +496,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
496
  msg = gr.Textbox(show_label=False, placeholder="To generate a chart: type #chart [your chart description ]. To discuss the chart: type your message directly...", scale=10, container=False)
497
  submit = gr.Button("➡️Send", scale=1)
498
 
499
- clear = gr.ClearButton([msg, chatbot])
500
 
501
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, [chatbot,messages3], [chatbot,messages3])
502
  submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, [chatbot,messages3], [chatbot,messages3])
@@ -517,7 +517,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
517
  msg2 = gr.Textbox(show_label=False, placeholder="Type a message...", scale=7, container=False)
518
  submit = gr.Button("➡️Send", scale=1)
519
 
520
- clear = gr.ClearButton([msg2, chatbot, msg1])
521
 
522
  msg1.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, [chatbot,messages4], [chatbot,messages4])
523
  msg2.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, [chatbot,messages4], [chatbot,messages4])
@@ -541,7 +541,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
541
  submit = gr.Button("➡️Send", scale=1)
542
  with gr.Row():
543
  file_output = gr.HTML("<div style='height: 20px; width: 30px;'></div>")
544
- clear = gr.ClearButton([msg, filepath, chatbot,file_output],scale=6)
545
 
546
  filepath.upload(display_file_name, inputs=filepath, outputs=file_output)
547
 
@@ -562,7 +562,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
562
  msg = gr.Textbox(show_label=False, placeholder="Type a message...", scale=10, container=False)
563
  submit = gr.Button("➡️Send", scale=1)
564
 
565
- clear = gr.ClearButton([msg, chatbot])
566
 
567
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, [chatbot, messages6], [chatbot, messages6])
568
  submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, [chatbot, messages6], [chatbot, messages6])
 
217
  for character in response.content:
218
  history[-1][1] += character
219
  time.sleep(0.0025)
220
+ yield history
221
 
222
  def Internet_Search(history, messages2):
223
 
 
269
  prompt = HumanMessage(content=message_with_description)
270
  messages3.append(prompt)
271
 
272
+ if len(messages3) >= 6:
273
+ messages3 = messages3[-6:]
274
 
275
  response = chat_model.invoke(messages3)
276
  messages3.append(AIMessage(content=response.content))
 
459
 
460
  clear = gr.ClearButton([msg, chatbot, messages1])
461
 
462
+ msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chat_Message, [chatbot,messages1], chatbot)
463
+ submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chat_Message, [chatbot,messages1], chatbot)
464
  chatbot.like(print_like_dislike, None, None)
465
 
466
  with gr.Tab("Internet-Search"):
 
476
  msg = gr.Textbox(show_label=False, placeholder="Type a message...", scale=10, container=False)
477
  submit = gr.Button("➡️Send", scale=1)
478
 
479
+ clear = gr.ClearButton([msg, chatbot, messages2])
480
 
481
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, [chatbot,messages2], [chatbot,messages2])
482
  submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Internet_Search, [chatbot,messages2], [chatbot,messages2])
 
496
  msg = gr.Textbox(show_label=False, placeholder="To generate a chart: type #chart [your chart description ]. To discuss the chart: type your message directly...", scale=10, container=False)
497
  submit = gr.Button("➡️Send", scale=1)
498
 
499
+ clear = gr.ClearButton([msg, chatbot, messages3])
500
 
501
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, [chatbot,messages3], [chatbot,messages3])
502
  submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Chart_Generator, [chatbot,messages3], [chatbot,messages3])
 
517
  msg2 = gr.Textbox(show_label=False, placeholder="Type a message...", scale=7, container=False)
518
  submit = gr.Button("➡️Send", scale=1)
519
 
520
+ clear = gr.ClearButton([msg2, chatbot, msg1, messages4])
521
 
522
  msg1.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, [chatbot,messages4], [chatbot,messages4])
523
  msg2.submit(user2, [msg2, chatbot, msg1], [msg2, chatbot, msg1], queue=True).then(Link_Scratch, [chatbot,messages4], [chatbot,messages4])
 
541
  submit = gr.Button("➡️Send", scale=1)
542
  with gr.Row():
543
  file_output = gr.HTML("<div style='height: 20px; width: 30px;'></div>")
544
+ clear = gr.ClearButton([msg, filepath, chatbot,file_output, messages5],scale=6)
545
 
546
  filepath.upload(display_file_name, inputs=filepath, outputs=file_output)
547
 
 
562
  msg = gr.Textbox(show_label=False, placeholder="Type a message...", scale=10, container=False)
563
  submit = gr.Button("➡️Send", scale=1)
564
 
565
+ clear = gr.ClearButton([msg, chatbot, messages6])
566
 
567
  msg.submit(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, [chatbot, messages6], [chatbot, messages6])
568
  submit.click(user, [msg, chatbot], [msg, chatbot], queue=True).then(Explore_WebSite, [chatbot, messages6], [chatbot, messages6])