ffreemt commited on
Commit
e28efb2
·
2 Parent(s): 3d67a24 90bc39f

Merge branch 'main' of https://huggingface.co/spaces/mikeee/multilingual-dokugpt

Browse files
Files changed (2) hide show
  1. app.py +7 -4
  2. main.py +8 -3
app.py CHANGED
@@ -489,7 +489,7 @@ def embed_files(progress=gr.Progress()):
489
  # search_kwargs={"k": 6} # defaukt k=4
490
  )
491
 
492
- prompt_template = """You're an AI version of the book and are supposed to answer quesions people
493
  have for the book. Thanks to advancements in AI people can
494
  now talk directly to books.
495
  People have a lot of questions after reading this book,
@@ -848,22 +848,25 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
848
  text2 = gr.Textbox("Gen embedding")
849
  process_btn = gr.Button("Click to embed")
850
 
851
- # reset_btn = gr.Button("Reset everything", visibile=False)
852
 
853
  with gr.Tab("Query docs"):
854
  # interactive chat
855
  chatbot = gr.Chatbot()
856
  msg = gr.Textbox(label="Query")
857
- clear = gr.Button("Clear")
 
 
858
 
859
  # actions
860
  def reset_all():
861
  """Reset ns."""
862
  global ns
863
  ns = deepcopy(ns_initial)
 
864
  return f"reset done: ns={ns}"
865
 
866
- # reset_btn.click(reset_all, [], text2)
867
 
868
  upload_button.upload(upload_files, upload_button, file_output)
869
  process_btn.click(process_files, [], text2)
 
489
  # search_kwargs={"k": 6} # defaukt k=4
490
  )
491
 
492
+ prompt_template = """You're an AI version of the book and are supposed to answer questions people
493
  have for the book. Thanks to advancements in AI people can
494
  now talk directly to books.
495
  People have a lot of questions after reading this book,
 
848
  text2 = gr.Textbox("Gen embedding")
849
  process_btn = gr.Button("Click to embed")
850
 
851
+ reset_btn = gr.Button("Reset everything", visibile=True)
852
 
853
  with gr.Tab("Query docs"):
854
  # interactive chat
855
  chatbot = gr.Chatbot()
856
  msg = gr.Textbox(label="Query")
857
+ with gr.Row():
858
+ submit_msg = gr.Button("Submit")
859
+ clear = gr.Button("Clear")
860
 
861
  # actions
862
  def reset_all():
863
  """Reset ns."""
864
  global ns
865
  ns = deepcopy(ns_initial)
866
+ logger.debug(f"reset {ns=}")
867
  return f"reset done: ns={ns}"
868
 
869
+ clear.click(reset_all, [], text2)
870
 
871
  upload_button.upload(upload_files, upload_button, file_output)
872
  process_btn.click(process_files, [], text2)
main.py CHANGED
@@ -71,19 +71,22 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
71
  text_embed = gr.Textbox("Generate embeddings")
72
  embed_btn = gr.Button("Click to embed")
73
 
74
- reset_btn = gr.Button("Reset everything", visible=False)
75
 
76
  with gr.Tab("Query docs"): # Tab1
77
  # interactive chat
78
  chatbot = gr.Chatbot()
79
  msg = gr.Textbox(label="Query")
80
- clear = gr.Button("Clear")
 
 
81
 
82
  # actions
83
  def reset_all():
84
  """Reset ns."""
85
  # global ns
86
  globals().update(**{"ns": deepcopy(ns_initial)})
 
87
  return f"reset done: ns={ns}"
88
 
89
  # Tab1
@@ -94,7 +97,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
94
 
95
  # Tab2
96
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
97
- clear.click(lambda: None, None, chatbot, queue=False)
 
 
98
 
99
  if __name__ == "__main__":
100
  demo.queue(concurrency_count=20).launch()
 
71
  text_embed = gr.Textbox("Generate embeddings")
72
  embed_btn = gr.Button("Click to embed")
73
 
74
+ reset_btn = gr.Button("Reset everything", visible=True)
75
 
76
  with gr.Tab("Query docs"): # Tab1
77
  # interactive chat
78
  chatbot = gr.Chatbot()
79
  msg = gr.Textbox(label="Query")
80
+ with gr.Row():
81
+ msg_submitbtn = gr.Button("Submit")
82
+ clear = gr.Button("Clear")
83
 
84
  # actions
85
  def reset_all():
86
  """Reset ns."""
87
  # global ns
88
  globals().update(**{"ns": deepcopy(ns_initial)})
89
+ logger.debug(f"reset to {ns=}")
90
  return f"reset done: ns={ns}"
91
 
92
  # Tab1
 
97
 
98
  # Tab2
99
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
100
+ msg_submitbtn.click(respond, [msg, chatbot], [msg, chatbot])
101
+ clear.click(lambda: None, None, chatbot, queue=True)
102
+
103
 
104
  if __name__ == "__main__":
105
  demo.queue(concurrency_count=20).launch()