IC4T commited on
Commit
d9fe4fd
Β·
1 Parent(s): 686f1d9
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -43,6 +43,7 @@ target_source_chunks = int(os.environ.get('TARGET_SOURCE_CHUNKS',4))
43
  # MODEL_N_CTX=1000
44
  # TARGET_SOURCE_CHUNKS=4
45
 
 
46
 
47
  from constants import CHROMA_SETTINGS
48
  # embeddings_model_name = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
@@ -179,6 +180,13 @@ def predict(
179
  # chatbot = [(history[i], history[i + 1]) for i in range(0, len(history), 2)]
180
  # return chatbot, history
181
 
 
 
 
 
 
 
 
182
  def reset_textbox():
183
  return gr.update(value="")
184
 
@@ -249,7 +257,10 @@ with gr.Blocks(
249
  submit_btn = gr.Button(value="πŸš€ Send")
250
  with gr.Column():
251
  clear_btn = gr.Button(value="πŸ—‘οΈ Clear history")
252
-
 
 
 
253
  question.submit(
254
  predict,
255
  # [question, system_content, embeddings_model_name, persist_directory, model_type, model_path, model_n_ctx, target_source_chunks, chatbot, state],
@@ -278,4 +289,4 @@ with gr.Blocks(
278
  #demo.launch(server_name=args.server_name, server_port=args.server_port, share=args.share, debug=args.debug)
279
  # demo.queue(concurrency_count=5).launch()
280
 
281
- demo.launch(debug=True)
 
43
  # MODEL_N_CTX=1000
44
  # TARGET_SOURCE_CHUNKS=4
45
 
46
+ import psutil
47
 
48
  from constants import CHROMA_SETTINGS
49
  # embeddings_model_name = "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
 
180
  # chatbot = [(history[i], history[i + 1]) for i in range(0, len(history), 2)]
181
  # return chatbot, history
182
 
183
+ def get_system_memory():
184
+ memory = psutil.virtual_memory()
185
+ memory_percent = memory.percent
186
+ memory_used = memory.used / (1024.0 ** 3)
187
+ memory_total = memory.total / (1024.0 ** 3)
188
+ return {"percent": f"{memory_percent}%", "used": f"{memory_used:.3f}GB", "total": f"{memory_total:.3f}GB"}
189
+
190
  def reset_textbox():
191
  return gr.update(value="")
192
 
 
257
  submit_btn = gr.Button(value="πŸš€ Send")
258
  with gr.Column():
259
  clear_btn = gr.Button(value="πŸ—‘οΈ Clear history")
260
+
261
+ with gr.Column():
262
+ gr.JSON(get_system_memory, every=1)
263
+
264
  question.submit(
265
  predict,
266
  # [question, system_content, embeddings_model_name, persist_directory, model_type, model_path, model_n_ctx, target_source_chunks, chatbot, state],
 
289
  #demo.launch(server_name=args.server_name, server_port=args.server_port, share=args.share, debug=args.debug)
290
  # demo.queue(concurrency_count=5).launch()
291
 
292
+ demo.queue().launch(debug=True)