From 27f3a78834e0fe331279d83e9eb5b6f9761ee5e2 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 16 Apr 2023 17:35:54 -0300 Subject: [PATCH] Better detect when no model is loaded --- modules/chat.py | 4 ++-- modules/text_generation.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/chat.py b/modules/chat.py index 34f7b2fd..7ef5eee2 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -120,7 +120,7 @@ def extract_message_from_reply(reply, state): def chatbot_wrapper(text, state, regenerate=False, _continue=False): - if shared.model_name == 'None': + if shared.model_name == 'None' or shared.model is None: print("No model is loaded! Select one in the Model tab.") yield shared.history['visible'] return @@ -198,7 +198,7 @@ def chatbot_wrapper(text, state, regenerate=False, _continue=False): def impersonate_wrapper(text, state): - if shared.model_name == 'None': + if shared.model_name == 'None' or shared.model is None: print("No model is loaded! Select one in the Model tab.") yield '' return diff --git a/modules/text_generation.py b/modules/text_generation.py index 6313785c..370130ed 100644 --- a/modules/text_generation.py +++ b/modules/text_generation.py @@ -125,7 +125,7 @@ def stop_everything_event(): def generate_reply(question, state, eos_token=None, stopping_strings=[]): - if shared.model_name == 'None': + if shared.model_name == 'None' or shared.model is None: print("No model is loaded! Select one in the Model tab.") yield formatted_outputs(question, shared.model_name) return