Просмотр исходного кода

--auto-launch and "Is typing..."

- Added `--auto-launch` arg to open web UI in the default browser when ready.
- Changed chat.py to display user input immediately and "*Is typing...*" as a temporary reply while generating text. Most noticeable when using `--no-stream`.
Xan 2 лет назад
Родитель
Сommit
96c51973f9
3 измененных файлов с 6 добавлено и 2 удалено
  1. 3 0
      modules/chat.py
  2. 1 0
      modules/shared.py
  3. 2 2
      server.py

+ 3 - 0
modules/chat.py

@@ -120,6 +120,9 @@ def chatbot_wrapper(text, max_new_tokens, do_sample, temperature, top_p, typical
     else:
         prompt = custom_generate_chat_prompt(text, max_new_tokens, name1, name2, context, chat_prompt_size)
 
+    #display user input and "*is typing...*" imediately
+    yield shared.history['visible']+[[visible_text, '*Is typing...*']]
+
     # Generate
     reply = ''
     for i in range(chat_generation_attempts):

+ 1 - 0
modules/shared.py

@@ -90,4 +90,5 @@ parser.add_argument('--listen', action='store_true', help='Make the web UI reach
 parser.add_argument('--listen-port', type=int, help='The listening port that the server will use.')
 parser.add_argument('--share', action='store_true', help='Create a public URL. This is useful for running the web UI on Google Colab or similar.')
 parser.add_argument('--verbose', action='store_true', help='Print the prompts to the terminal.')
+parser.add_argument('--auto-launch', action='store_true', default=False, help='Open the web UI in the default browser upon launch')
 args = parser.parse_args()

+ 2 - 2
server.py

@@ -372,9 +372,9 @@ else:
 
 shared.gradio['interface'].queue()
 if shared.args.listen:
-    shared.gradio['interface'].launch(prevent_thread_lock=True, share=shared.args.share, server_name='0.0.0.0', server_port=shared.args.listen_port)
+    shared.gradio['interface'].launch(prevent_thread_lock=True, share=shared.args.share, server_name='0.0.0.0', server_port=shared.args.listen_port, inbrowser=shared.args.auto_launch)
 else:
-    shared.gradio['interface'].launch(prevent_thread_lock=True, share=shared.args.share, server_port=shared.args.listen_port)
+    shared.gradio['interface'].launch(prevent_thread_lock=True, share=shared.args.share, server_port=shared.args.listen_port, inbrowser=shared.args.auto_launch)
 
 # I think that I will need this later
 while True: