ffreemt commited on
Commit
adb2ab9
1 Parent(s): 4947e7b
Files changed (2) hide show
  1. README.md +1 -3
  2. app.py +15 -6
README.md CHANGED
@@ -6,9 +6,7 @@ colorTo: purple
6
  sdk: gradio
7
  sdk_version: 3.36.1
8
  app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- duplicated_from: FredZhang7/chat-test
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
6
  sdk: gradio
7
  sdk_version: 3.36.1
8
  app_file: app.py
9
+ pinned: true
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -59,7 +59,7 @@ model_cache_path = [elm for elm in Path(cache_loc).rglob("*") if Path(model_name
59
  logger.debug(f"{model_cache_path=}")
60
 
61
  if model_cache_path:
62
- model_size_gb = Path(model_cache_path[0]).stat().st_size / 2**30
63
  logger.info(f"{model_name=} {model_size_gb=:.2f} GB")
64
 
65
 
@@ -68,12 +68,21 @@ def respond(message, chat_history):
68
  chat_history.append((message, response))
69
  return "", chat_history
70
 
71
-
72
- with gr.Blocks() as block:
73
  chatbot = gr.Chatbot()
74
- msg = gr.Textbox()
75
 
76
- clear = gr.ClearButton([msg, chatbot])
77
- msg.submit(respond, [msg, chatbot], [msg, chatbot])
 
 
 
 
 
 
 
 
 
 
78
 
79
  block.queue().launch()
 
59
  logger.debug(f"{model_cache_path=}")
60
 
61
  if model_cache_path:
62
+ model_size_gb = model_cache_path[0].stat().st_size / 2**30
63
  logger.info(f"{model_name=} {model_size_gb=:.2f} GB")
64
 
65
 
 
68
  chat_history.append((message, response))
69
  return "", chat_history
70
 
71
+ theme = gr.themes.Soft(text_size="sm")
72
+ with gr.Blocks(theme=theme) as block:
73
  chatbot = gr.Chatbot()
 
74
 
75
+ with gr.Column():
76
+ with gr.Column(scale=12):
77
+ msg = gr.Textbox()
78
+ with gr.Column(scale=1, min_width=16):
79
+ btn = gr.Button()
80
+ with gr.Column(scale=1, min_width=16):
81
+ clear = gr.ClearButton([msg, chatbot])
82
+
83
+ # do not clear prompt
84
+ msg.submit(lambda x, y: [x] + respond(x, y)[1:], [msg, chatbot], [msg, chatbot])
85
+
86
+ btn.click(respond, [msg, chatbot], [msg, chatbot])
87
 
88
  block.queue().launch()