From a2240a711c26e305d587b6b546b3b6c066e40650 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Sat, 6 Apr 2024 16:21:22 +0200 Subject: Update __init__.py --- g4f/gui/__init__.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'g4f') diff --git a/g4f/gui/__init__.py b/g4f/gui/__init__.py index 3f695200..16b03e4c 100644 --- a/g4f/gui/__init__.py +++ b/g4f/gui/__init__.py @@ -1,16 +1,20 @@ from ..errors import MissingRequirementsError +try: + from .server.app import app + from .server.website import Website + from .server.backend import Backend_Api + import_error = None +except ImportError as e: + import_error = e + def run_gui(host: str = '0.0.0.0', port: int = 8080, debug: bool = False) -> None: - try: - from .server.app import app - from .server.website import Website - from .server.backend import Backend_Api - except ImportError: - raise MissingRequirementsError('Install "flask" package for the gui') + if import_error is not None: + raise MissingRequirementsError(f'Install "gui" requirements | pip install g4f[gui] -U\n{import_error}') if debug: - import g4f - g4f.debug.logging = True + from g4f import debug + debug.logging = True config = { 'host' : host, 'port' : port, -- cgit v1.2.3