can you make the clipboard monitor to not loop if the openai api base & key hasn't been set?

# Global variables
pause_monitoring = False
dark_mode = False
translated_dict = {}
previous_translated_content = ""

def translate_text(text_to_translate, prompt_template):
    prompt = prompt_template.format(text_to_translate=text_to_translate)
    completion = openai.ChatCompletion.create(
        model="gpt-3.5-turbo-0301",
        temperature=1,
        messages=[
            {
                "role": "user",
                "content": f"{prompt}",
            }
        ],
    )
    translated_text = (
        completion["choices"][0]
        .get("message")
        .get("content")
        .encode("utf8")
        .decode()
    )
    
    if log_translations:
        try:
            with open(translation_logfile, "a", encoding="utf-8") as f:
                f.write(f"{translated_text}\n")
        except FileNotFoundError:
            pass
            
    return translated_text

def toggle_pause_monitoring():
    global pause_monitoring
    pause_monitoring = not pause_monitoring
    pause_button.config(
        text="Resume" if pause_monitoring else "Pause",
        relief=tk.SUNKEN if pause_monitoring else tk.RAISED
    )

def clipboard_monitor():
    global prompt_text
    old_clipboard = ""

    while True:
        if not pause_monitoring:
            new_clipboard = pyperclip.paste()

            # Remove line breaks from new_clipboard
            # new_clipboard = new_clipboard.replace('\n', '').replace('\r', '')

            # Compare new_clipboard with old_clipboard to detect changes
            if new_clipboard != old_clipboard and new_clipboard.strip() != untranslated_textbox.get(1.0, tk.END).strip():
                old_clipboard = new_clipboard
                if new_clipboard in translated_dict:
                    translated_text = translated_dict[new_clipboard]
                else:
                    try:
                        prompt_text = prompt_textbox.get(1.0, tk.END).strip()
                        translated_text = translate_text(new_clipboard, prompt_text)
                    except Exception as e:
                        root.after(0, create_error_window, f"Connection Error: {e}")
                        continue

                    translated_dict[new_clipboard] = translated_text

                update_display(untranslated_textbox, new_clipboard)
                update_display(translated_textbox, translated_text)

        time.sleep(1)

root = tk.Tk()
root.title("Clipboard Translator")
root.geometry("400x200")

settings_data = load_settings()
openai.api_base = settings_data.get("api_base", "https://api.openai.com/v1")
openai.api_key = settings_data.get("api_key", "")
prompt_logfile = settings_data.get("prompt_logfile", "")
always_on_top = settings_data.get("always_on_top", False)
window_opacity = settings_data.get("window_opacity", 1.0)
font_settings = settings_data.get("font_settings", {"family": "Courier", "size": 10, "color": "black"})
log_translations = settings_data.get("log_translations", False)
translation_logfile = settings_data.get("translation_logfile", "")

translation_logfile, log_translations, translation_dict = check_log_file(translation_logfile, translated_dict)
prompt_logfile, prompt_text = check_prompt_file(prompt_logfile)

menu_bar = Menu(root)

# Add Options menu
options_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Options", menu=options_menu)
options_menu.add_command(label="Set OpenAI API", command=set_openai_api)
always_on_top_var = tk.BooleanVar(value=always_on_top)
options_menu.add_checkbutton(label="Always on top", variable=always_on_top_var, command=set_always_on_top)
dark_mode_var = tk.BooleanVar(value=False)
options_menu.add_checkbutton(label="Dark Mode", variable=dark_mode_var, command=toggle_dark_mode)
options_menu.add_command(label="Increase opacity", command=increase_opacity)
options_menu.add_command(label="Decrease opacity", command=decrease_opacity)
options_menu.add_command(label="Font", command=font_window)

prompt_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Prompt", menu=prompt_menu)
prompt_menu.add_command(label="Save", command=save)
prompt_menu.add_command(label="Save As", command=save_as)

root.config(menu=menu_bar)

paned_window = tk.PanedWindow(root, sashrelief="groove", sashwidth=5, orient="horizontal")
paned_window.pack(expand=True, fill="both")
untranslated_textbox = tk.Text(paned_window, wrap="word")
paned_window.add(untranslated_textbox)
translated_textbox = tk.Text(paned_window, wrap="word")
paned_window.add(translated_textbox)
prompt_textbox = tk.Text(paned_window, wrap="word")
paned_window.add(prompt_textbox)
update_display(prompt_textbox, prompt_text)

copy_button = tk.Button(root, text="Copy", command=copy_untranslated)
copy_button.place(relx=0, rely=1, anchor="sw")
retranslate_button = tk.Button(root, text="Translate", command=retranslate_text)
retranslate_button.place(relx=0.1, rely=1, anchor="sw")
toggle_button = tk.Button(root, text="Hide", command=toggle_translated, relief=tk.RAISED)
toggle_button.place(relx=0.5, rely=1, anchor="s")
pause_button = tk.Button(root, text="Pause", command=toggle_pause_monitoring, relief=tk.RAISED)
pause_button.place(relx=1, rely=1, anchor="se")

if __name__ == "__main__":
    exe_mode = getattr(sys, 'frozen', False)
    if exe_mode:
        sys.stderr = open("error_log.txt", "w")
    clipboard_monitor_thread = threading.Thread(target=clipboard_monitor)
    clipboard_monitor_thread.start()
    root.mainloop()

    if exe_mode:
        sys.stderr.close()